Java Code Examples for org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer#accessTokenConverter()
The following examples show how to use
org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer#accessTokenConverter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthSvrApplication.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 7 votes |
@Bean public AuthorizationServerConfigurer authorizationServerConfigurer( @Value("${client.web.name}") String clientName, @Value("${client.web.secret}") String clientSecret) { return new AuthorizationServerConfigurerAdapter() { @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient(clientName) .secret(passwordEncoder.encode(clientSecret)) .scopes("account", "message", "email") .authorizedGrantTypes("client_credentials"); } @Override public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { oauthServer.checkTokenAccess("isAuthenticated()"); } @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.accessTokenConverter(accessTokenConverter()); } }; }
Example 2
Source File: AuthorizationServerConfig.java From cloud-service with MIT License | 6 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(this.authenticationManager); endpoints.tokenStore(tokenStore()); // 授权码模式下,code存储 // endpoints.authorizationCodeServices(new JdbcAuthorizationCodeServices(dataSource)); endpoints.authorizationCodeServices(redisAuthorizationCodeServices); if (storeWithJwt) { endpoints.accessTokenConverter(accessTokenConverter()); } else { // 2019.07.13 将当前用户信息追加到登陆后返回数据里 endpoints.tokenEnhancer((accessToken, authentication) -> { addLoginUserInfo(accessToken, authentication); return accessToken; }); } }
Example 3
Source File: AuthorizationServerConfig.java From microservices-platform with Apache License 2.0 | 6 votes |
/** * 配置身份认证器,配置认证方式,TokenStore,TokenGranter,OAuth2RequestFactory * @param endpoints */ @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { if (jwtAccessTokenConverter != null) { if (tokenEnhancer != null) { TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers( Arrays.asList(tokenEnhancer, jwtAccessTokenConverter)); endpoints.tokenEnhancer(tokenEnhancerChain); } else { endpoints.accessTokenConverter(jwtAccessTokenConverter); } } endpoints.tokenStore(tokenStore) .authenticationManager(authenticationManager) .userDetailsService(userDetailsService) .authorizationCodeServices(authorizationCodeServices) .exceptionTranslator(webResponseExceptionTranslator); }
Example 4
Source File: OAuth2ServerConfig.java From open-capacity-platform with Apache License 2.0 | 5 votes |
/** * 配置身份认证器,配置认证方式,TokenStore,TokenGranter,OAuth2RequestFactory */ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { if (jwtTokenStore != null) { endpoints.tokenStore(jwtTokenStore).authenticationManager(authenticationManager) // 支持 .userDetailsService(userDetailsService); // password // grant // type; } else if (redisTokenStore != null) { endpoints.tokenStore(redisTokenStore).authenticationManager(authenticationManager) // 支持 .userDetailsService(userDetailsService); // password // grant // type; } if (jwtAccessTokenConverter != null) { endpoints.accessTokenConverter(jwtAccessTokenConverter); } endpoints.authorizationCodeServices(authorizationCodeServices); endpoints.exceptionTranslator(webResponseExceptionTranslator); }
Example 5
Source File: OAuth2AuthorizationServerConfiguration.java From spring-security-oauth2-boot with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { if (this.tokenConverter != null) { endpoints.accessTokenConverter(this.tokenConverter); } if (this.tokenStore != null) { endpoints.tokenStore(this.tokenStore); } if (this.details.getAuthorizedGrantTypes().contains("password")) { endpoints.authenticationManager(this.authenticationManager); } }
Example 6
Source File: AuthorizationServerConfig.java From platform with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints.authenticationManager(this.authenticationManager); endpoints.tokenStore(tokenStore()); endpoints.accessTokenConverter(accessTokenConverter()); // 默认情况下,只有第一次请求到的Refresh Token可用, // 后续刷新后获取到的Refresh Token都无法使用的 // 这里可以根据实际情况做选择 endpoints.reuseRefreshTokens(false); }
Example 7
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 8
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 9
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 10
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 11
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 12
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 13
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 14
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 15
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 16
Source File: AuthorizationServerConfiguration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // @formatter:off endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()); if (this.jwtEnabled) { endpoints .accessTokenConverter(accessTokenConverter()); } // @formatter:on }
Example 17
Source File: FebsAuthorizationServerConfigure.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints.tokenStore(tokenStore()) .userDetailsService(userDetailService) .authenticationManager(authenticationManager) .exceptionTranslator(exceptionTranslator); if (properties.getEnableJwt()) { endpoints.accessTokenConverter(jwtAccessTokenConverter()); } }
Example 18
Source File: AuthorizationServerConfiguration.java From spring-boot-demo with MIT License | 5 votes |
/** * 用来配置授权(authorization)以及令牌(token)的访问端点和令牌服务(token services) * * @param endpoints * @throws Exception */ @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // 配置tokenStore // endpoints.authenticationManager(authenticationManager).tokenStore(tokenStore()) // .accessTokenConverter(accessTokenConverter()).userDetailsService(userDetailsService); //指定认证管理器 endpoints.authenticationManager(authenticationManager); //指定token存储位置 endpoints.tokenStore(tokenStore()); endpoints.accessTokenConverter(accessTokenConverter()); endpoints.userDetailsService(userDetailsService); //自定义token生成方式 TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers(Arrays.asList(customerEnhancer(), accessTokenConverter())); endpoints.tokenEnhancer(tokenEnhancerChain); // 配置TokenServices参数 DefaultTokenServices tokenServices = (DefaultTokenServices) endpoints.getDefaultAuthorizationServerTokenServices(); tokenServices.setTokenStore(endpoints.getTokenStore()); tokenServices.setSupportRefreshToken(true); tokenServices.setClientDetailsService(endpoints.getClientDetailsService()); tokenServices.setTokenEnhancer(endpoints.getTokenEnhancer()); tokenServices.setAccessTokenValiditySeconds((int) TimeUnit.DAYS.toSeconds(1));//一天 endpoints.tokenServices(tokenServices); }
Example 19
Source File: AuthorizationServerConfiguration.java From demo-spring-boot-security-oauth2 with MIT License | 4 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(this.authenticationManager); endpoints.accessTokenConverter(accessTokenConverter()); endpoints.tokenStore(tokenStore()); }
Example 20
Source File: AuthorizationServerConfig.java From cloud-project with Apache License 2.0 | 4 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(this.authenticationManager); endpoints.accessTokenConverter(accessTokenConverter()); endpoints.tokenStore(tokenStore()); }