国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - 詳解基于Spring Cloud幾行配置完成單點登錄開發(fā)

詳解基于Spring Cloud幾行配置完成單點登錄開發(fā)

2021-03-30 14:50冷冷gg Java教程

這篇文章主要介紹了詳解基于Spring Cloud幾行配置完成單點登錄開發(fā),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

單點登錄概念

單點登錄(Single Sign On),簡稱為 SSO,是目前比較流行的企業(yè)業(yè)務(wù)整合的解決方案之一。SSO的定義是在多個應(yīng)用系統(tǒng)中,用戶只需要登錄一次就可以訪問所有相互信任的應(yīng)用系統(tǒng)。登錄邏輯如上圖

基于Spring 全家桶的實現(xiàn)

技術(shù)選型:

  1. Spring Boot
  2. Spring Cloud
  3. Spring Security oAuth2

客戶端:

maven依賴

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.security.oauth</groupId>
  <artifactId>spring-security-oauth2</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.security</groupId>
  <artifactId>spring-security-jwt</artifactId>
</dependency>

EnableOAuth2Sso 注解

入口類配置@@EnableOAuth2Sso

?
1
2
3
4
5
6
7
8
@SpringBootApplication
public class PigSsoClientDemoApplication {
 
  public static void main(String[] args) {
    SpringApplication.run(PigSsoClientDemoApplication.class, args);
  }
 
}

配置文件

?
1
2
3
4
5
6
7
8
9
10
11
12
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認(rèn)證服務(wù)器

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@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;
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://juejin.im/post/5a6e771e5188253dc3323b6b

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 成人午夜电影网 | 99久久99久久精品 | 日日精品 | 欧美疯狂性受xxxxx另类 | 欧美日韩国产精品一区 | 天天操天天碰 | 一区二区精品视频 | 日韩精品无码一区二区三区 | 成人片免费看 | 中文字幕在线精品 | 亚洲天堂中文字幕 | 日韩中文视频 | 免费观看www7722午夜电影 | 91精品在线播放 | 精品久久精品久久 | 精品视频一区二区 | 国产激情偷乱视频一区二区三区 | 久久香蕉国产视频 | 日韩欧美三级在线观看 | 亚洲一区精品在线 | 欧美成人免费在线视频 | 色版视频在线观看 | 国产成人一区 | 久草av在线播放 | 亚洲成人久久久久 | av电影一区 | 四虎免费看黄 | 午夜激情在线 | 一区二区三区动漫 | 夜夜摸夜夜操 | 亚洲精品久久久久一区二区三区 | 在线视频 亚洲 | 伊人黄| 国产成人黄色片 | 日韩精品一二三 | 黄色天堂| 久久人人网 | 成人精品视频免费 | 亚洲免费在线看 | 欧美在线资源 | 91精品久久久久久综合五月天 |