访问Rest API - JHipster
问题描述:
JHipster默认带有Spring Actuator。根据the document,我将能够使用像localhost/api这样的url来查看应用程序Rest API。然而,当我尝试访问它时,由于“未经授权(未授权)”,我得到了“拒绝访问”,即使我以管理员身份登录。在类SecurityConfiguration中,我更改以下方法访问Rest API - JHipster
@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?
答
登录到应用程序 - >Administration
- >API
这是更好地观看jHipster tutorial。
+0
我忘了那个。我使用了令牌授权并且无法访问api。所以,我尝试使用Spring Boot提供的功能。 – vic
答
我也使用jhipster,为了能够发送postMan请求,我更改了类SecurityConfigurationSaml.java中的PublicApiWebSecurityConfigurationAdapter方法。我只需要添加一个regexMatcher到我正在做我的请求的链接。 我认为链接的安全性是在这个类上编码的。
你有没有试过看代码? – pmverma