【发布时间】:2018-08-09 17:29:19
【问题描述】:
-
当我访问我的 api 时:http://xx/api/v1/reference,点击 大摇大摆,我得到:Unable to infer base url 我该如何解决这个问题? 在我的课堂上,我有:
@Configuration @EnableWebSecurity @Order(1) public class SecurityJavaConfig extends WebSecurityConfigurerAdapter { @Value("${yourapp.http.auth-token-header-name}") private String principalRequestHeader; @Value("${yourapp.http.auth-token}") private String principalRequestValue; @Override protected void configure(HttpSecurity httpSecurity) throws Exception { APIKeyAuthFilter filter = new APIKeyAuthFilter(principalRequestHeader); filter.setAuthenticationManager(new AuthenticationManager() { @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { String principal = (String) authentication.getPrincipal(); if (!principalRequestValue.equals(principal)) { throw new BadCredentialsException("The API key was not found or not the expected value."); } authentication.setAuthenticated(true); return authentication; } }); httpSecurity. antMatcher("/api/**"). csrf().disable(). sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS). and(). addFilter(filter).authorizeRequests().anyRequest().authenticated(); }}
我知道已经发布了几个这样的问题: 没有人回答我的问题。显然,这已在 Springfox 2.8.1-SNAPSHOT 中修复。谁能给我一个适用于 Springfox 2.8.0 的解决方案?
【问题讨论】:
标签: java spring rest spring-security swagger