Spring Cloudに基づいていくつかの行の配置が完了しました.
4275 ワード
シングルポイント登録概念
シングルポイント登録(Single Sign On)は、SSOと略称し、現在流行している企業業務統合のソリューションの一つです.SSOの定義は、複数のアプリケーションシステムにおいて、ユーザが一度登録するだけで、すべての相互信頼されたアプリケーションシステムにアクセスできるというものです.登録ロジックは上の通りです.
Springファミリーバケツによる実現
技術の選択:
maven依存
入口類配置@@EnbaleOAuth 2 Sso
認証サーバの設定 SSOクライアントのindex. にアクセスする. SSOサービス端末のBaic認証 にリダイレクトする.アカウントのパスワードを入力して、元の要求のクライアントindexリソース にリダイレクトする.
締め括りをつけるクライアントがサービス端末403にアクセスする問題?ユーザーはROLE_を持つ必要があります.USERの権限は、具体的にログでエラーが確認できます. Possible CSRF detected-state parameter was present butのstate could be foundは現在session:neverまたはcotext pathによって解決されています. ソースコードは、gitee.com/log 4 j/Spring Cloud、Spring Security Oauth 2.0開発企業級認証と授権を参照してください.一般的なサービス監視、リンク追跡、ログ分析、キャッシュ管理、タスクスケジュールなどを提供して を実現します.
シングルポイント登録(Single Sign On)は、SSOと略称し、現在流行している企業業務統合のソリューションの一つです.SSOの定義は、複数のアプリケーションシステムにおいて、ユーザが一度登録するだけで、すべての相互信頼されたアプリケーションシステムにアクセスできるというものです.登録ロジックは上の通りです.
Springファミリーバケツによる実現
技術の選択:
Spring Boot
Spring Cloud
Spring Security oAuth2
クライアント:maven依存
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-security
org.springframework.security.oauth
spring-security-oauth2
org.springframework.security
spring-security-jwt
EnbaleOAuth 2 Ssoコメント入口類配置@@EnbaleOAuth 2 Sso
@SpringBootApplication
public class PigSsoClientDemoApplication {
public static void main(String[] args) {
SpringApplication.run(PigSsoClientDemoApplication.class, args);
}
}
設定ファイルsecurity:
oauth2:
client:
client-id: pig
client-secret: pig
user-authorization-uri: http://localhost:3000/oauth/authorize
access-token-uri: http://localhost:3000/oauth/token
scope: server
resource:
jwt:
key-uri: http://localhost:3000/oauth/token_key
sessions: never
SSO認証サーバ認証サーバの設定
@Configuration
@Order(Integer.MIN_VALUE)
@EnableAuthorizationServer
public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient(authServerConfig.getClientId())
.secret(authServerConfig.getClientSecret())
.authorizedGrantTypes(SecurityConstants.REFRESH_TOKEN, SecurityConstants.PASSWORD,SecurityConstants.AUTHORIZATION_CODE)
.scopes(authServerConfig.getScope());
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
endpoints
.tokenStore(new RedisTokenStore(redisConnectionFactory))
.accessTokenConverter(jwtAccessTokenConverter())
.authenticationManager(authenticationManager)
.exceptionTranslator(pigWebResponseExceptionTranslator)
.reuseRefreshTokens(false)
.userDetailsService(userDetailsService);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security
.allowFormAuthenticationForClients()
.tokenKeyAccess("isAuthenticated()")
.checkTokenAccess("permitAll()");
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter() {
JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
jwtAccessTokenConverter.setSigningKey(CommonConstant.SIGN_KEY);
return jwtAccessTokenConverter;
}
}
設定完了体験締め括りをつける