【问题标题】:Access Rest API - JHipster访问 Rest API - JHipster
【发布时间】:2015-10-09 23:49:24
【问题描述】:

JHipster 默认带有 Spring Actuator。根据the document,我将能够使用类似 localhost/api 的 url 查看应用程序 Rest API。但是,即使我以管理员身份登录,当我尝试访问它时,由于“未授权(未授权)”而得到“访问被拒绝”。在 SecurityConfiguration 类中,我更改了以下方法

   @Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring()
        .antMatchers("/scripts/**/*.{js,html}")
        .antMatchers("/bower_components/**")
        .antMatchers("/i18n/**")
        .antMatchers("/assets/**")
        .antMatchers("/swagger-ui.html")
        .antMatchers("/api/**")   <-- new added
        .antMatchers("/api/register")
        .antMatchers("/api/activate")
        .antMatchers("/api/account/reset_password/init")
        .antMatchers("/api/account/reset_password/finish")
        .antMatchers("/test/**");
}

此更改只会产生异常。

那我怎样才能访问我的应用程序 Rest API?

【问题讨论】:

  • 你试过看代码吗?

标签: jhipster


【解决方案1】:

登录应用程序 -> Administration -> API

最好看jHipster tutorial

【讨论】:

  • 我忘了那个。我使用了Token授权,无法访问api。所以,我尝试使用 Spring Boot 提供的功能。
【解决方案2】:

我也使用 jhipster,为了能够使用 postMan 发送请求,我更改了 SecurityConfigurationSaml.java 类中的 PublicApiWebSecurityConfigurationAdapter 方法。我只需将 regexMatcher 添加到我正在执行请求的链接中。 我认为链接的安全性是在这个类上编码的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-19
    • 2016-09-11
    • 1970-01-01
    • 2017-09-28
    • 2014-11-28
    • 2015-04-23
    • 2017-02-09
    • 1970-01-01
    相关资源
    最近更新 更多