【问题标题】:How to open my application j hipster without authentication如何在没有身份验证的情况下打开我的应用程序 j hipster
【发布时间】:2017-07-12 14:31:26
【问题描述】:

我创建了名为 Bookstore 的 j hipster 应用程序。运行我的应用程序后,它将进行身份验证。我不需要这个身份验证。如果有什么方法可以在没有 j hipster 登录页面的情况下打开我的应用程序?

【问题讨论】:

    标签: java spring-security jwt jhipster spring-security-oauth2


    【解决方案1】:

    在路径“app/config”中有类 MicroserviceSecurityConfiguration.class 在这种情况下更改那里的权限

    ("/api/**").Authenticated()

    ("/api/**").permitAll()

    【讨论】:

    • 在较新的 JHipster 版本中,此更改应在生成的 config/SecurityConfiguration.java 类中完成。如果您只想为特定的 http 方法打开部分 api,例如能够获取未经身份验证的实体列表,请查看更多 antMatchers(httpMethod, path)
    【解决方案2】:

    禁用身份验证:

    • 在 SecurityConfiguration.java 中将 .antMatchers("/api/**").authenticated() 替换为 .antMatchers("/**").permitAll()
    • 从所有 *.html 中删除所有 *jhiHasAnyAuthority 的所有指令在所有 *.html 文件中
    • 从所有 *.html、[ngSwitch]="isAuthenticated() 的所有指令以及所有 *ngSwitchCase 中删除
    • 在所有 *service.ts 文件中的所有 checkLogin( 方法中返回 true
    • 请参阅有关授权的文档。
    • 我希望它更容易......

    【讨论】:

      【解决方案3】:

      假设您要构建一个保留 JHipster 管理功能的应用程序:

      • 删除您要公开的 HTML 元素上的 *jhiHasAnyAuthorities 指令
      • 处理 isAuthenticated() 的 *ngSwitch 指令也是如此,请参阅 doc about authorizations

      【讨论】:

        猜你喜欢
        • 2021-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-30
        • 2022-01-03
        • 1970-01-01
        • 2018-07-21
        • 1970-01-01
        相关资源
        最近更新 更多