OAuth2アプローチを使用してアプリケーションを開発するのは初めてです。私は特定のチュートリアルに基づいて始めました。私はこれから進んでいます(http://websystique.com/spring-security/secure-spring-rest-api-using-oauth2/)。redisを使用してspring-security-oauth2を使用してトークンを永続化する方法
アプリケーションをクラスタ化されたWebSphereにデプロイするので、インメモリが理解できない限り(... clients.inMemory()。withClient ...)。
私はRedis(私の最初の使い方も同様)を使用したいと思うし、特定のno-xml java設定アプリケーションでsettupする方法がちょっと混乱しています。
xmlで特定の同様の質問がありましたが、最初の試行ではまだ北ではありません(Redis Token Store)。興味深いことに、ここでは、オーナーが「Spring Security OAuth、つまり2.8.0はRedisTokenStoreを提供します」と話しましたが、最新のmvnリリースバージョンとして「2.0.12.RELEASE」が見つかりました。
私のまっすぐな質問は次のようなものです。メモリ内の代わりにRedisに依存するようにコードを調整するにはどうすればいいですか?
RedisTokenStoreを設定する方法についてのご意見をお待ちしております。
さらに、このようなコメントを追加するのが簡単な場合は、「.passwordEncoder」と「.secret」の違いは何ですか?コードコーディングでは、ハードコードされた式(固定値)で ".secret"を使用していますが、jdbcを "springframework.security.crypto.bcrypt.BCryptPasswordEncoderで埋め込まれた.passwordEncoderで埋め込まれた"という例がほとんどありません。私は ".secret"か ".passwordEncoder"のどちらかを使うと思います。私は秘密が固定値を表し、passwordEncoderはダイナミックなものを意味すると思うのですか?
ここ
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
private static String REALM="MY_OAUTH_REALM";
@Autowired
private TokenStore tokenStore;
@Autowired
private UserApprovalHandler userApprovalHandler;
@Autowired
@Qualifier("authenticationManagerBean")
private AuthenticationManager authenticationManager;
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("abc-trusted-client")
.authorizedGrantTypes("password", "authorization_code", "refresh_token", "implicit")
.authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
.scopes("read", "write", "trust")
.secret("abc-secret")
.accessTokenValiditySeconds(120).//Access token is only valid for 2 minutes.
refreshTokenValiditySeconds(600);//Refresh token is only valid for 10 minutes.
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore).userApprovalHandler(userApprovalHandler)
.authenticationManager(authenticationManager);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer.realm(REALM+"/client");
}
}
これは、ありがとうございます! –