シングルサインオンコンセプト
SSOと呼ばれるシングルサインオンは、エンタープライズビジネス統合に最も人気のあるソリューションの1つです。 SSOの定義は、複数のアプリケーションシステムでは、ユーザーが相互に信頼できるすべてのアプリケーションシステムにアクセスするために1回ログインするだけでいいということです。ログインロジックは上記の図に示されています
スプリングファミリーバケットに基づく実装
技術選択:
クライアント:
メイブン依存関係
<Dependency> groupId> org.springframework.boot </groupid> <artifactid> spring-boot-starter-web </artifactid> </dependency> <dependency> groupid> org.springframework.boot </groupid> <artifactid> spring-boot-startertertertertertertertertertid </artifactid </artifactid> <groupid> org.springframework.security.oauth </groupid> <artifactid> spring-security-oauth2 </artifactid> </dependency> <dependency> groupid> org.security </groupid> <artifactid> spring-jwt </artifactid> </shidency>
enababeoauth2ssoアノテーション
エントリークラス構成@@ enableoauth2sso
@SpringBootApplicationPublic Class PIGSSOCLIENTDEMOAPPLICATION {public static void main(string [] args){springApplication.run(gigssoclientdemoapplication.class、args); }}構成ファイル
セキュリティ:OAUTH2:クライアント:クライアント-ID:PIGクライアントセクレット:PIGユーザー承認 - URI:http:// localhost:3000/oauth/authorize access-token-uri:http:// localhost:3000/oauth/token scope:server resource:jwt:key-uri:http:// otis:3// 一度もない
SSO認証サーバー
認証サーバー構成
@configuration@order(integer.min_value)@enableauthorizationserverpublic class pigauthorizationconfig extends authorationserverconfigureradapter {@override public void configure(clientdetailsserviceconfigurer clients)スロー例外.secret(authserverconfig.getClientsecret()).authorizedgranttypes(securityconstants.refresh_token、securityconstants.password、securityconstants.authorization_code).scopes(autherverconfig.getscope(); } @Override public void configure(authorationserverendpointsconfigurer endpoints){endpoints .tokenstore(new redistokenstore(redisconnectionFactory)).ACCESSTOKENCENVERTER(JWTACCESSTOKENCENVERTER().AUTHENTICATIONMANAGER(認証マネージャー)。 .reuserefreshtokens(false).userdetailsservice(userdetailsservice); } @Override public void configure(authorizationserversecurityconfigurer security)throws exception {security .allowformauthenticationforclients().tokenkeyaccess( "isauthenticated()")。 } @bean publice passwordencoder passwordencoder(){return new bcryptpasswordencoder(); } @bean public jwtacstokenconverter jwtaccesstokenconverter(){jwtaccesstokenconverter jwtaccestokenconverter = new JWTACCESSTOKENVERTER(); jwtaccesstokenconverter.setsiingkey(commonConstant.sign_key); jwtaccesstokenconverterを返します。 }}上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。