OAuth2 をサポートする Spring Boot アプリケーションが動作しています。2 つのクライアントがあり、それぞれに独自のクライアント ID があります。
@Configuration
@EnableAuthorizationServer
protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
private static final String RESOURCE_ID = "my-rest-service";
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("clientOne")
.authorizedGrantTypes("password", "refresh_token")
.authorities("USER")
.scopes("read", "write")
.resourceIds(RESOURCE_ID)
.secret("123456"))
.and()
.withClient("clientTwo")
.authorizedGrantTypes("password", "refresh_token")
.scopes("read","write")
.resourceIds(RESOURCE_ID)
.secret("789654")
;
}
}
さらに、私は を持ってUser
いRole
ます。ロール ROLE_ONE を持つユーザーは、使用時にのみ認証トークンを取得できclientOne
、ROLE_TWO を持つユーザーのみがそれを取得するために使用できるようclientTwo
になりました。
そのロジックをどこに追加すればよいですか?