У меня есть две таблицы, в каждой из которых разные пользователи, есть два веб-приложения, которые связаны с моим SpringEnd, каждое приложение frontEnd имеет одну таблицу пользователей.Я хочу, чтобы пользователь каждой таблицы связывался с разными clientId и clientSecret.Я попытался создать два сервера авторизации, но, похоже, это не сработало.
public class ClientAuthorizationServerConfiguration extends
AuthorizationServerConfigurerAdapter {
@Autowired
private ClientConfigurationProperties clientConfiguration;
private TokenStore tokenStore = new InMemoryTokenStore();
@Autowired
@Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Autowired
private RepositoryClientDetailsService clientDetailsService;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints)
throws Exception {
endpoints
.tokenStore(this.tokenStore)
.authenticationManager(this.authenticationManager)
.userDetailsService(clientDetailsService);
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws
Exception {
clients
.inMemory()
.withClient(clientConfiguration.getClientId())
.authorizedGrantTypes("password", "refresh_token")
.authorities("USER")
.scopes("read", "write")
.resourceIds(ClientApiResourceServerConfiguration.RESOURCE_ID)
.secret("{noop}"+clientConfiguration.getClientSecret());
}
@Bean
@Primary
public DefaultTokenServices tokenServices() {
DefaultTokenServices tokenServices = new DefaultTokenServices();
tokenServices.setSupportRefreshToken(true);
tokenServices.setTokenStore(this.tokenStore);
return tokenServices;
}
@Bean
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
}
это мой второй сервер авторизации
@Configuration
@EnableAuthorizationServer
@Order(1)
public class AuthorizationServerConfiguration extends
AuthorizationServerConfigurerAdapter {
@Autowired
private ApplicationConfigurationProperties configuration;
@Autowired
private RepositoryClientDetailsService clientDetailsService;
private TokenStore tokenStore = new InMemoryTokenStore();
@Autowired
@Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Autowired
private RepositoryUserDetailsService userDetailsService;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints)
throws Exception {
endpoints
.tokenStore(this.tokenStore)
.authenticationManager(this.authenticationManager)
.userDetailsService(userDetailsService);
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws
Exception {
clients
.inMemory()
.withClient(configuration.getClientId())
.authorizedGrantTypes("password", "refresh_token")
.authorities("USER")
.scopes("read", "write")
.resourceIds(RestApiResourceServerConfiguration.RESOURCE_ID)
.secret("{noop}"+configuration.getClientSecret());
}
@Bean
@Primary
public DefaultTokenServices tokenServices() {
DefaultTokenServices tokenServices = new DefaultTokenServices();
tokenServices.setSupportRefreshToken(true);
tokenServices.setTokenStore(this.tokenStore);
return tokenServices;
}
@Bean
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
}