日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
單點(diǎn)登錄(SSO),一看就會(huì),一做就錯(cuò)!

圖片來(lái)自 Pexels

十多年成都創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè),由一走到現(xiàn)在,當(dāng)中離不開(kāi)團(tuán)隊(duì)頑強(qiáng)的創(chuàng)業(yè)精神,離不開(kāi)伴隨我們同行的客戶(hù)與專(zhuān)業(yè)的合作伙伴,創(chuàng)力信息一直秉承以“見(jiàn)一個(gè)客戶(hù),了解一個(gè)行業(yè),交一個(gè)朋友”的方式為經(jīng)營(yíng)理念,提出“讓每一個(gè)客戶(hù)成為我們的終身客戶(hù)”為目標(biāo),以為用戶(hù)提供精細(xì)化服務(wù),全面滿(mǎn)足用戶(hù)需求為宗旨,誠(chéng)信經(jīng)營(yíng),更大限度為用戶(hù)創(chuàng)造價(jià)值。期待邁向下一個(gè)更好的十多年。

網(wǎng)上關(guān)于實(shí)現(xiàn) SSO 的文章一大堆,但是當(dāng)你真的照著寫(xiě)的時(shí)候就會(huì)發(fā)現(xiàn)根本不是那么回事兒,簡(jiǎn)直讓人抓狂,尤其是對(duì)于我這樣的菜鳥(niǎo)。

幾經(jīng)曲折,終于搞定了,決定記錄下來(lái),以便后續(xù)查看。先來(lái)看一下效果:

準(zhǔn)備

①單點(diǎn)登錄

最常見(jiàn)的例子是,我們打開(kāi)淘寶 APP,首頁(yè)就會(huì)有天貓、聚劃算等服務(wù)的鏈接,當(dāng)你點(diǎn)擊以后就直接跳過(guò)去了,并沒(méi)有讓你再登錄一次。

下面這個(gè)圖是我在網(wǎng)上找的,我覺(jué)得畫(huà)得比較明白:

可惜有點(diǎn)兒不清晰,于是我又畫(huà)了個(gè)簡(jiǎn)版的:

重要的是理解:

  • SSO 服務(wù)端和 SSO 客戶(hù)端直接是通過(guò)授權(quán)以后發(fā)放 Token 的形式來(lái)訪(fǎng)問(wèn)受保護(hù)的資源。
  • 相對(duì)于瀏覽器來(lái)說(shuō),業(yè)務(wù)系統(tǒng)是服務(wù)端,相對(duì)于 SSO 服務(wù)端來(lái)說(shuō),業(yè)務(wù)系統(tǒng)是客戶(hù)端。
  • 瀏覽器和業(yè)務(wù)系統(tǒng)之間通過(guò)會(huì)話(huà)正常訪(fǎng)問(wèn)。
  • 不是每次瀏覽器請(qǐng)求都要去 SSO 服務(wù)端去驗(yàn)證,只要瀏覽器和它所訪(fǎng)問(wèn)的服務(wù)端的會(huì)話(huà)有效它就可以正常訪(fǎng)問(wèn)。

利用 OAuth2 實(shí)現(xiàn)單點(diǎn)登錄

接下來(lái),只講跟本例相關(guān)的一些配置,不講原理,不講為什么。

眾所周知,在 OAuth2 在有授權(quán)服務(wù)器、資源服務(wù)器、客戶(hù)端這樣幾個(gè)角色,當(dāng)我們用它來(lái)實(shí)現(xiàn) SSO 的時(shí)候是不需要資源服務(wù)器這個(gè)角色的,有授權(quán)服務(wù)器和客戶(hù)端就夠了。

授權(quán)服務(wù)器當(dāng)然是用來(lái)做認(rèn)證的,客戶(hù)端就是各個(gè)應(yīng)用系統(tǒng),我們只需要登錄成功后拿到用戶(hù)信息以及用戶(hù)所擁有的權(quán)限即可。

之前我一直認(rèn)為把那些需要權(quán)限控制的資源放到資源服務(wù)器里保護(hù)起來(lái)就可以實(shí)現(xiàn)權(quán)限控制,其實(shí)是我想錯(cuò)了,權(quán)限控制還得通過(guò) Spring Security 或者自定義攔截器來(lái)做。

①Spring Security 、OAuth2、JWT、SSO

在本例中,一定要分清楚這幾個(gè)的作用:

首先,SSO 是一種思想,或者說(shuō)是一種解決方案,是抽象的,我們要做的就是按照它的這種思想去實(shí)現(xiàn)它。

其次,OAuth2 是用來(lái)允許用戶(hù)授權(quán)第三方應(yīng)用訪(fǎng)問(wèn)他在另一個(gè)服務(wù)器上的資源的一種協(xié)議,它不是用來(lái)做單點(diǎn)登錄的,但我們可以利用它來(lái)實(shí)現(xiàn)單點(diǎn)登錄。

在本例實(shí)現(xiàn) SSO 的過(guò)程中,受保護(hù)的資源就是用戶(hù)的信息(包括,用戶(hù)的基本信息,以及用戶(hù)所具有的權(quán)限)。

而我們想要訪(fǎng)問(wèn)這這一資源就需要用戶(hù)登錄并授權(quán),OAuth2 服務(wù)端負(fù)責(zé)令牌的發(fā)放等操作,這令牌的生成我們采用 JWT,也就是說(shuō) JWT 是用來(lái)承載用戶(hù)的 Access_Token 的。

最后,Spring Security 是用于安全訪(fǎng)問(wèn)的,這里我們我們用來(lái)做訪(fǎng)問(wèn)權(quán)限控制。

認(rèn)證服務(wù)器配置

Maven 依賴(lài):

 
 
 
 
  1.  
  2.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
  3.     4.0.0 
  4.      
  5.         org.springframework.boot 
  6.         spring-boot-starter-parent 
  7.         2.1.3.RELEASE 
  8.           
  9.      
  10.     com.cjs.sso 
  11.     oauth2-sso-auth-server 
  12.     0.0.1-SNAPSHOT 
  13.     oauth2-sso-auth-server 
  14.  
  15.      
  16.         1.8 
  17.      
  18.  
  19.      
  20.          
  21.             org.springframework.boot 
  22.             spring-boot-starter-data-jpa 
  23.          
  24.          
  25.             org.springframework.boot 
  26.             spring-boot-starter-data-redis 
  27.          
  28.          
  29.             org.springframework.boot 
  30.             spring-boot-starter-security 
  31.          
  32.          
  33.             org.springframework.security.oauth.boot 
  34.             spring-security-oauth2-autoconfigure 
  35.             2.1.3.RELEASE 
  36.          
  37.          
  38.             org.springframework.boot 
  39.             spring-boot-starter-thymeleaf 
  40.          
  41.          
  42.             org.springframework.boot 
  43.             spring-boot-starter-web 
  44.          
  45.          
  46.             org.springframework.session 
  47.             spring-session-data-redis 
  48.          
  49.          
  50.             mysql 
  51.             mysql-connector-java 
  52.             runtime 
  53.          
  54.          
  55.             org.projectlombok 
  56.             lombok 
  57.             true 
  58.          
  59.          
  60.             org.springframework.boot 
  61.             spring-boot-starter-test 
  62.             test 
  63.          
  64.          
  65.             org.springframework.security 
  66.             spring-security-test 
  67.             test 
  68.          
  69.  
  70.          
  71.             org.apache.commons 
  72.             commons-lang3 
  73.             3.8.1 
  74.          
  75.          
  76.             com.alibaba 
  77.             fastjson 
  78.             1.2.56 
  79.          
  80.  
  81.      
  82.  
  83.      
  84.          
  85.              
  86.                 org.springframework.boot 
  87.                 spring-boot-maven-plugin 
  88.              
  89.          
  90.      
  91.  
  92.  

這里面最重要的依賴(lài)是:spring-security-oauth2-autoconfigure。

application.yml:

 
 
 
 
  1. spring: 
  2.   datasource: 
  3.     url: jdbc:mysql://localhost:3306/permission 
  4.     username: root 
  5.     password: 123456 
  6.     driver-class-name: com.mysql.jdbc.Driver 
  7.   jpa: 
  8.     show-sql: true 
  9.   session: 
  10.     store-type: redis 
  11.   redis: 
  12.     host: 127.0.0.1 
  13.     password: 123456 
  14.     port: 6379 
  15. server: 
  16.   port: 8080 

AuthorizationServerConfig(重要):

 
 
 
 
  1. package com.cjs.sso.config; 
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired; 
  4. import org.springframework.context.annotation.Bean; 
  5. import org.springframework.context.annotation.Configuration; 
  6. import org.springframework.context.annotation.Primary; 
  7. import org.springframework.security.core.token.DefaultToken; 
  8. import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; 
  9. import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; 
  10. import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; 
  11. import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; 
  12. import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; 
  13. import org.springframework.security.oauth2.provider.token.DefaultTokenServices; 
  14. import org.springframework.security.oauth2.provider.token.TokenStore; 
  15. import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 
  16. import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; 
  17.  
  18. import javax.sql.DataSource; 
  19.  
  20. /** 
  21.  * @author ChengJianSheng 
  22.  * @date 2019-02-11 
  23.  */ 
  24. @Configuration 
  25. @EnableAuthorizationServer 
  26. public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { 
  27.  
  28.     @Autowired 
  29.     private DataSource dataSource; 
  30.  
  31.     @Override 
  32.     public void configure(AuthorizationServerSecurityConfigurer security) throws Exception { 
  33.         security.allowFormAuthenticationForClients(); 
  34.         security.tokenKeyAccess("isAuthenticated()"); 
  35.     } 
  36.  
  37.     @Override 
  38.     public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 
  39.         clients.jdbc(dataSource); 
  40.     } 
  41.  
  42.     @Override 
  43.     public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { 
  44.         endpoints.accessTokenConverter(jwtAccessTokenConverter()); 
  45.         endpoints.tokenStore(jwtTokenStore()); 
  46. //        endpoints.tokenServices(defaultTokenServices()); 
  47.     } 
  48.  
  49.     /*@Primary 
  50.     @Bean 
  51.     public DefaultTokenServices defaultTokenServices() { 
  52.         DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); 
  53.         defaultTokenServices.setTokenStore(jwtTokenStore()); 
  54.         defaultTokenServices.setSupportRefreshToken(true); 
  55.         return defaultTokenServices; 
  56.     }*/ 
  57.  
  58.     @Bean 
  59.     public JwtTokenStore jwtTokenStore() { 
  60.         return new JwtTokenStore(jwtAccessTokenConverter()); 
  61.     } 
  62.  
  63.     @Bean 
  64.     public JwtAccessTokenConverter jwtAccessTokenConverter() { 
  65.         JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter(); 
  66.         jwtAccessTokenConverter.setSigningKey("cjs");   //  Sets the JWT signing key 
  67.         return jwtAccessTokenConverter; 
  68.     } 
  69.  

說(shuō)明:

  • 別忘了 @EnableAuthorizationServer。
  • Token 存儲(chǔ)采用的是 JWT。
  • 客戶(hù)端以及登錄用戶(hù)這些配置存儲(chǔ)在數(shù)據(jù)庫(kù),為了減少數(shù)據(jù)庫(kù)的查詢(xún)次數(shù),可以從數(shù)據(jù)庫(kù)讀出來(lái)以后再放到內(nèi)存中。

WebSecurityConfig(重要):

 
 
 
 
  1. package com.cjs.sso.config; 
  2.  
  3. import com.cjs.sso.service.MyUserDetailsService; 
  4. import org.springframework.beans.factory.annotation.Autowired; 
  5. import org.springframework.context.annotation.Bean; 
  6. import org.springframework.context.annotation.Configuration; 
  7. import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 
  8. import org.springframework.security.config.annotation.web.builders.HttpSecurity; 
  9. import org.springframework.security.config.annotation.web.builders.WebSecurity; 
  10. import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 
  11. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 
  12. import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 
  13. import org.springframework.security.crypto.password.PasswordEncoder; 
  14.  
  15. /** 
  16.  * @author ChengJianSheng 
  17.  * @date 2019-02-11 
  18.  */ 
  19. @Configuration 
  20. @EnableWebSecurity 
  21. public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 
  22.  
  23.     @Autowired 
  24.     private MyUserDetailsService userDetailsService; 
  25.  
  26.     @Override 
  27.     protected void configure(AuthenticationManagerBuilder auth) throws Exception { 
  28.         auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder()); 
  29.     } 
  30.  
  31.     @Override 
  32.     public void configure(WebSecurity web) throws Exception { 
  33.         web.ignoring().antMatchers("/assets/**", "/css/**", "/images/**"); 
  34.     } 
  35.  
  36.     @Override 
  37.     protected void configure(HttpSecurity http) throws Exception { 
  38.         http.formLogin() 
  39.                 .loginPage("/login") 
  40.                 .and() 
  41.                 .authorizeRequests() 
  42.                 .antMatchers("/login").permitAll() 
  43.                 .anyRequest() 
  44.                 .authenticated() 
  45.                 .and().csrf().disable().cors(); 
  46.     } 
  47.  
  48.     @Bean 
  49.     public PasswordEncoder passwordEncoder() { 
  50.         return new BCryptPasswordEncoder(); 
  51.     } 
  52.  

自定義登錄頁(yè)面(一般來(lái)講都是要自定義的):

 
 
 
 
  1. package com.cjs.sso.controller; 
  2.  
  3. import org.springframework.stereotype.Controller; 
  4. import org.springframework.web.bind.annotation.GetMapping; 
  5.  
  6. /** 
  7.  * @author ChengJianSheng 
  8.  * @date 2019-02-12 
  9.  */ 
  10. @Controller 
  11. public class LoginController { 
  12.  
  13.     @GetMapping("/login") 
  14.     public String login() { 
  15.         return "login"; 
  16.     } 
  17.  
  18.     @GetMapping("/") 
  19.     public String index() { 
  20.         return "index"; 
  21.     } 
  22.  

自定義登錄頁(yè)面的時(shí)候,只需要準(zhǔn)備一個(gè)登錄頁(yè)面,然后寫(xiě)個(gè) Controller 令其可以訪(fǎng)問(wèn)到即可,登錄頁(yè)面表單提交的時(shí)候 method 一定要是 post,最重要的時(shí)候 action 要跟訪(fǎng)問(wèn)登錄頁(yè)面的 url 一樣。

千萬(wàn)記住了,訪(fǎng)問(wèn)登錄頁(yè)面的時(shí)候是 GET 請(qǐng)求,表單提交的時(shí)候是 POST 請(qǐng)求,其他的就不用管了。

 
 
 
 
  1.  
  2.  
  3.  
  4.      
  5.      
  6.     Ela Admin - HTML5 Admin Template 
  7.      
  8.      
  9.  
  10.      
  11.      
  12.      
  13.      
  14.  
  15.  
  16.  
  17.  
  18.  
  19.      
  20.          
  21.              
  22.                 歡迎來(lái)到王者榮耀 
  23.             
 
  •              
  •                  
  •                      
  •                          
  •                          
  •                     
  •  
  •                      
  •                          
  •                          
  •                     
  •  
  •                      
  •                         
  •                              Remember Me 
  •                          
  •                          
  •                             Forgotten Password? 
  •                          
  •                     
  •  
  •                     登錄 
  •                  
  •             
  •  
  •         
  •  
  •     
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  • 定義客戶(hù)端,如下圖:

    加載用戶(hù),登錄賬戶(hù):

     
     
     
     
    1. package com.cjs.sso.domain; 
    2.  
    3. import lombok.Data; 
    4. import org.springframework.security.core.GrantedAuthority; 
    5. import org.springframework.security.core.userdetails.User; 
    6.  
    7. import java.util.Collection; 
    8.  
    9. /** 
    10.  * 大部分時(shí)候直接用User即可不必?cái)U(kuò)展 
    11.  * @author ChengJianSheng 
    12.  * @date 2019-02-11 
    13.  */ 
    14. @Data 
    15. public class MyUser extends User { 
    16.  
    17.     private Integer departmentId;   //  舉個(gè)例子,部門(mén)ID 
    18.  
    19.     private String mobile;  //  舉個(gè)例子,假設(shè)我們想增加一個(gè)字段,這里我們?cè)黾右粋€(gè)mobile表示手機(jī)號(hào) 
    20.  
    21.     public MyUser(String username, String password, Collection authorities) { 
    22.         super(username, password, authorities); 
    23.     } 
    24.  
    25.     public MyUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection authorities) { 
    26.         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities); 
    27.     } 

    加載登錄賬戶(hù):

     
     
     
     
    1. package com.cjs.sso.service; 
    2.  
    3. import com.alibaba.fastjson.JSON; 
    4. import com.cjs.sso.domain.MyUser; 
    5. import com.cjs.sso.entity.SysPermission; 
    6. import com.cjs.sso.entity.SysUser; 
    7. import lombok.extern.slf4j.Slf4j; 
    8. import org.springframework.beans.factory.annotation.Autowired; 
    9. import org.springframework.security.core.authority.SimpleGrantedAuthority; 
    10. import org.springframework.security.core.userdetails.UserDetails; 
    11. import org.springframework.security.core.userdetails.UserDetailsService; 
    12. import org.springframework.security.core.userdetails.UsernameNotFoundException; 
    13. import org.springframework.security.crypto.password.PasswordEncoder; 
    14. import org.springframework.stereotype.Service; 
    15. import org.springframework.util.CollectionUtils; 
    16.  
    17. import java.util.ArrayList; 
    18. import java.util.List; 
    19.  
    20. /** 
    21.  * @author ChengJianSheng 
    22.  * @date 2019-02-11 
    23.  */ 
    24. @Slf4j 
    25. @Service 
    26. public class MyUserDetailsService implements UserDetailsService { 
    27.  
    28.     @Autowired 
    29.     private PasswordEncoder passwordEncoder; 
    30.  
    31.     @Autowired 
    32.     private UserService userService; 
    33.  
    34.     @Autowired 
    35.     private PermissionService permissionService; 
    36.  
    37.     @Override 
    38.     public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 
    39.         SysUser sysUser = userService.getByUsername(username); 
    40.         if (null == sysUser) { 
    41.             log.warn("用戶(hù){}不存在", username); 
    42.             throw new UsernameNotFoundException(username); 
    43.         } 
    44.         List permissionList = permissionService.findByUserId(sysUser.getId()); 
    45.         List authorityList = new ArrayList<>(); 
    46.         if (!CollectionUtils.isEmpty(permissionList)) { 
    47.             for (SysPermission sysPermission : permissionList) { 
    48.                 authorityList.add(new SimpleGrantedAuthority(sysPermission.getCode())); 
    49.             } 
    50.         } 
    51.  
    52.         MyUser myUser = new MyUser(sysUser.getUsername(), passwordEncoder.encode(sysUser.getPassword()), authorityList); 
    53.  
    54.         log.info("登錄成功!用戶(hù): {}", JSON.toJSONString(myUser)); 
    55.  
    56.         return myUser; 
    57.     } 

    驗(yàn)證:

    當(dāng)我們看到這個(gè)界面的時(shí)候,表示認(rèn)證服務(wù)器配置完成。

    兩個(gè)客戶(hù)端

    Maven 依賴(lài):

     
     
     
     
    1.  
    2.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    3.     4.0.0 
    4.      
    5.         org.springframework.boot 
    6.         spring-boot-starter-parent 
    7.         2.1.3.RELEASE 
    8.           
    9.      
    10.     com.cjs.sso 
    11.     oauth2-sso-client-member 
    12.     0.0.1-SNAPSHOT 
    13.     oauth2-sso-client-member 
    14.     Demo project for Spring Boot 
    15.  
    16.      
    17.         1.8 
    18.      
    19.  
    20.      
    21.          
    22.             org.springframework.boot 
    23.             spring-boot-starter-data-jpa 
    24.          
    25.          
    26.             org.springframework.boot 
    27.             spring-boot-starter-oauth2-client 
    28.          
    29.          
    30.             org.springframework.boot 
    31.             spring-boot-starter-security 
    32.          
    33.          
    34.             org.springframework.security.oauth.boot 
    35.             spring-security-oauth2-autoconfigure 
    36.             2.1.3.RELEASE 
    37.          
    38.          
    39.             org.springframework.boot 
    40.             spring-boot-starter-thymeleaf 
    41.          
    42.          
    43.             org.thymeleaf.extras 
    44.             thymeleaf-extras-springsecurity5 
    45.             3.0.4.RELEASE 
    46.          
    47.          
    48.             org.springframework.boot 
    49.             spring-boot-starter-web 
    50.          
    51.  
    52.          
    53.             com.h2database 
    54.             h2 
    55.             runtime 
    56.          
    57.          
    58.             org.projectlombok 
    59.             lombok 
    60.             true 
    61.          
    62.          
    63.             org.springframework.boot 
    64.             spring-boot-starter-test 
    65.             test 
    66.          
    67.          
    68.             org.springframework.security 
    69.             spring-security-test 
    70.             test 
    71.          
    72.      
    73.  
    74.      
    75.          
    76.              
    77.                 org.springframework.boot 
    78.                 spring-boot-maven-plugin 
    79.              
    80.          
    81.      
    82.  
    83.  

    application.yml:

     
     
     
     
    1. server: 
    2.   port: 8082 
    3.   servlet: 
    4.     context-path: /memberSystem 
    5. security: 
    6.   oauth2: 
    7.     client: 
    8.       client-id: UserManagement 
    9.       client-secret: user123 
    10.       access-token-uri: http://localhost:8080/oauth/token 
    11.       user-authorization-uri: http://localhost:8080/oauth/authorize 
    12.     resource: 
    13.       jwt: 
    14.         key-uri: http://localhost:8080/oauth/token_key 

    這里 context-path 不要設(shè)成 /,不然重定向獲取 code 的時(shí)候回被攔截。

    WebSecurityConfig:

     
     
     
     
    1. package com.cjs.example.config; 
    2.  
    3. import com.cjs.example.util.EnvironmentUtils; 
    4. import org.springframework.beans.factory.annotation.Autowired; 
    5. import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso; 
    6. import org.springframework.context.annotation.Configuration; 
    7. import org.springframework.security.config.annotation.web.builders.HttpSecurity; 
    8. import org.springframework.security.config.annotation.web.builders.WebSecurity; 
    9. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 
    10.  
    11.  
    12. /** 
    13.  * @author ChengJianSheng 
    14.  * @date 2019-03-03 
    15.  */ 
    16. @EnableOAuth2Sso 
    17. @Configuration 
    18. public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 
    19. &n
      當(dāng)前標(biāo)題:?jiǎn)吸c(diǎn)登錄(SSO),一看就會(huì),一做就錯(cuò)!
      網(wǎng)頁(yè)地址:http://www.dlmjj.cn/article/djphchs.html