详解基于春云几行配置完成单点登录开发

  

<强>单点登录概念

  

单点登录(单个符号>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-web   & lt;/dependency>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-security   & lt;/dependency>   & lt; dependency>   & lt; groupId> org.springframework.security.oauth   & lt; artifactId> spring-security-oauth3   & lt;/dependency>   & lt; dependency>   & lt; groupId> org.springframework.security   & lt; artifactId> spring-security-jwt   & lt;/dependency>   之前      

<强> EnableOAuth3Sso注解

  

入口类配置@@EnableOAuth3Sso

        @SpringBootApplication   公开课PigSsoClientDemoApplication {      公共静态void main (String [] args) {   SpringApplication.run (PigSsoClientDemoApplication.class, args);   }      }      之前      

<>强配置文件

        安全:   oauth3:   客户:   客户机id:猪   端秘密:猪   user-authorization-uri: http://localhost: 3000/oauth/授权   access-token-uri: http://localhost: 3000/oauth/令牌   范围:服务器   资源:   jwt:   key-uri: http://localhost: 3000/oauth/token_key   会话:永远不要      

<强> SSO认证服务器

  

<>强认证服务器配置

        @ configuration   @Order (Integer.MIN_VALUE)   @EnableAuthorizationServer   公开课PigAuthorizationConfig延伸AuthorizationServerConfigurerAdapter {   @Override   公共空间配置(ClientDetailsServiceConfigurer客户){抛出异常   clients.inMemory ()   .withClient (authServerConfig.getClientId ())   .secret (authServerConfig.getClientSecret ())   .authorizedGrantTypes (SecurityConstants。REFRESH_TOKEN、SecurityConstants.PASSWORD SecurityConstants.AUTHORIZATION_CODE)   .scopes (authServerConfig.getScope ());   }      @Override   公共空间配置(AuthorizationServerEndpointsConfigurer端点){   端点   .tokenStore(新RedisTokenStore (redisConnectionFactory))   .accessTokenConverter (jwtAccessTokenConverter ())   .authenticationManager (authenticationManager)   .exceptionTranslator (pigWebResponseExceptionTranslator)   .reuseRefreshTokens(假)   .userDetailsService (userDetailsService);   }      @Override   公共空间配置(AuthorizationServerSecurityConfigurer安全性){抛出异常   安全   .allowFormAuthenticationForClients ()   .tokenKeyAccess (“isAuthenticated ()”)   .checkTokenAccess (“permitAll () ");   }      @ bean   公共PasswordEncoder PasswordEncoder () {   返回新BCryptPasswordEncoder ();   }      @ bean   公共JwtAccessTokenConverter JwtAccessTokenConverter () {   JwtAccessTokenConverter JwtAccessTokenConverter=new JwtAccessTokenConverter ();   jwtAccessTokenConverter.setSigningKey (CommonConstant.SIGN_KEY);   返回jwtAccessTokenConverter;   }   }      之前      

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

详解基于春云几行配置完成单点登录开发