Когда я даю доменное имя в accessTokenUri, оно не работает и сообщает об ошибке, но когда я предоставляю localhost, оно работает.Почему?
Сервер авторизации Config.java
@Configuration
@EnableAuthorizationServer
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security.tokenKeyAccess("permitAll()")
.checkTokenAccess("isAuthenticated()");
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients
.inMemory()
.withClient("QWE123")
.secret("abc")
.authorizedGrantTypes("password")
.scopes("user_info").accessTokenValiditySeconds(0)
.autoApprove(true);
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.authenticationManager(authenticationManager);
}
}
@EnableResourceServer
@Configuration
public class ResourceServerConfig extends WebSecurityConfigurerAdapter {
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Autowired
private UserDetailsService customUserDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login").permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.permitAll();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/user/**","/swagger-ui.html", "/v2/api-docs", "/swagger-resources/**");
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(customUserDetailsService).passwordEncoder(passwordEncoder());
}
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
App.properties
security:
basic:
enabled: false
oauth2:
resource:
filter-order: 3
ResourceServerConfig.java
@EnableOAuth2Sso
@Configuration
public class OauthConfig extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/")
.permitAll()
.anyRequest()
.authenticated();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/swagger-ui.html", "/v2/api-docs", "/swagger-resources/**");
}
}
@Configuration
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class Oauth2ResourceServerConfig extends GlobalMethodSecurityConfiguration {
@Override
protected MethodSecurityExpressionHandler createExpressionHandler() {
return new OAuth2MethodSecurityExpressionHandler();
}
}
App.properties
security:
basic:
enabled: false
oauth2:
client:
clientId: QWE123
clientSecret: abc
accessTokenUri: https://example.net/auth/oauth/token
userAuthorizationUri: https://example.net/auth/oauth/authorize
resource:
userInfoUri: https://example.net/auth/logged-in/principal
filter-order: 3
Ошибка:
2018-09-14 12: 00: 13.083 INFO 25836 --- [main] osjeaAnnotationMBeanExporter: Расположенный управляемый компонент 'environmentManager': регистрация на сервере JMX в качестве MBean [org.springframework.cloud.context.environment: name = environmentManager, type = EnvironmentManager] 2018-09-14 12: 00: 13.095 INFO 25836 --- [main] osjeaAnnotationMBeanExporter: Расположенный управляемый компонент 'restartEndpoint': регистрация на сервере JMX в качестве MBean [org.springframework.cloud.context.restart: name = restartEndpoint, type = RestartEndpoint] 2018-09-14 12: 00: 13.106 INFO 25836 --- [main] osjeaAnnotationMBeanExporter: Расположенный управляемый компонент 'refreshScope': регистрация на сервере JMX в качестве MBean[org.springframework.cloud.context.scope.refresh: name = refreshScope, type = RefreshScope] 2018-09-14 12: 00: 13.116 INFO 25836 --- [main] osjeaAnnotationMBeanExporter: Расположен managed bean 'configurationPropertiesRebinder': регистрация на сервере JMX в качестве MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=35d08e6c,type=ConfigurationPropertiesRebinder] 2018-09-14 12: 00: 13.123 INFO 25836[main] osjeaAnnotationMBeanExporter: Расположенный управляемый компонент 'refreshEndpoint': регистрация на сервере JMX в качестве MBean [org.springframework.cloud.endpoint: name = refreshEndpoint, type = RefreshEndpoint] 2018-09-14 12: 00: 13.424 INFO 25836 ---[main] oscsupport.DefaultLifecycleProcessor: запуск bean-компонентов в фазе 0 2018-09-14 12: 00: 13.482 INFO 25836 --- [main] oscsupport.DefaultLifecycleProcessor: запуск bean-компонентов в фазе 2147483647 2018-09-14 12: 00: 13.483 INFO25836 --- [main] dswpDocumentationPluginsBootstrapper: контекст обновлен 2018-09-14 12: 00: 13.509 INFO 25836 --- [main] dswpDocumentationPluginsBootstrapper: найдено 1 пользовательских плагинов документации 2018-09-14 12: 00: 13.530 INFO25836 --- [
main] sdswsApiListingReferenceScanner:Сканирование ссылок на списки API 2018-09-14 12: 00: 13.870 ИНФОРМАЦИЯ 25836 --- [
main] sbcetTomcatEmbeddedServletContainer: Tomcat запущен на портах: 8080 (http) 2018-09-14 12: 00: 13.882ИНФОРМАЦИЯ 25836 --- [
main] chdfsc.DfscServiceApplication: запуск приложения DfscServiceApplication через 44,8 секунды (JVM работает в течение 45,324) 2018-09-14 12: 01: 52.271 ИНФО 25836 --- [nio-8080-exec-1]oaccC [Tomcat]. [localhost]. [/ api]: Инициализация Spring FrameworkServlet 'dispatcherServlet' 2018-09-14 12: 01: 52.271 INFO 25836 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet:FrameworkServlet 'dispatcherServlet': инициализация запущена 2018-09-14 12: 01: 52.292 INFO 25836 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: FrameworkServlet 'dispatcherServlet': инициализация завершена за 21 мс 2018-09-14 12: 01: 52.990 WARN 25836 --- [nio-8080-exec-1] osbasorUserInfoTokenServices: Не удалось получить сведения о пользователе: class org.springframework.security.oauth2.client.resource.UserRedirectRequiredException,Чтобы получить одобрение пользователей, требуется переадресация
Я многое нашел по этому поводу, но безуспешно, не могли бы вы мне помочь?