org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer Java Examples
The following examples show how to use
org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer.
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: AuthorizationServerConfig.java From lion with Apache License 2.0 | 6 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // 配置tokenServices参数 DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); /** * jwt 无状态方式 */ //tokenServices.setTokenEnhancer(jwtAccessTokenConverter()); tokenServices.setSupportRefreshToken(true); tokenServices.setClientDetailsService(clientDetails()); // 设置access_token有效时长12小时,默认12小时 tokenServices.setAccessTokenValiditySeconds(60 * 60 * 12); // 设置refresh_token有效时长7天,默认30天 tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 7); endpoints .userDetailsService(userDetailsService) .authenticationManager(authenticationManager) .tokenServices(tokenServices) // 自定义认证异常处理类 .exceptionTranslator(webResponseExceptionTranslator()); }
Example #2
Source File: AuthSvrApplication.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 6 votes |
@Bean public AuthorizationServerConfigurer authorizationServerConfigurer() { return new AuthorizationServerConfigurerAdapter() { @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("browserclient") .secret(passwordEncoder.encode("browserclient12345678")) .scopes("account", "message", "email") .resourceIds("resource") .authorizedGrantTypes("implicit") .redirectUris("http://localhost:8082/hello.html"); } @Override public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { oauthServer.checkTokenAccess("isAuthenticated()"); } @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(webSecurityConfigurerAdapter.authenticationManagerBean()) .userDetailsService(webSecurityConfigurerAdapter.userDetailsServiceBean()); } }; }
Example #3
Source File: AuthSvrApplication.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 6 votes |
@Bean public AuthorizationServerConfigurer authorizationServerConfigurer() { return new AuthorizationServerConfigurerAdapter() { @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("authcodeclient") .secret(passwordEncoder.encode("authcodeclient12345678")) .scopes("account", "message", "email") .resourceIds("resource") .authorizedGrantTypes("authorization_code", "refresh_token") .redirectUris("http://localhost:8082/HELLO"); } @Override public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { oauthServer.checkTokenAccess("isAuthenticated()"); } @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(webSecurityConfigurerAdapter.authenticationManagerBean()) .userDetailsService(webSecurityConfigurerAdapter.userDetailsServiceBean()); } }; }
Example #4
Source File: AuthorizationServerConfig.java From java-tutorial with MIT License | 6 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.tokenStore(jdbcTokenStore) .authenticationManager(authenticationManager) .userDetailsService(userDetailsService); if (jwtAccessTokenConverter != null && jwtTokenEnhancer != null) { TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); ArrayList enhancerList = new ArrayList(); enhancerList.add(jwtTokenEnhancer); enhancerList.add(jwtAccessTokenConverter); tokenEnhancerChain.setTokenEnhancers(enhancerList); endpoints.tokenEnhancer(tokenEnhancerChain) .accessTokenConverter(jwtAccessTokenConverter); } // 配置TokenServices参数 endpoints.tokenServices(defaultTokenServices()); }
Example #5
Source File: OAuth2Config.java From spring-auth-example with MIT License | 6 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.tokenStore(tokenStore()) .tokenEnhancer(jwtTokenEnhancer()) .authenticationManager(authenticationManager) .userDetailsService(userDetailsService); List<TokenGranter> tokenGranters = new ArrayList<>(); tokenGranters .add(new CustomResourceOwnerPasswordTokenGranter(authenticationManager, endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory())); tokenGranters.add(new RefreshTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory())); endpoints.tokenGranter(new CompositeTokenGranter(tokenGranters)); }
Example #6
Source File: OAuth2AuthorizationServerConfig.java From oauth-boot with MIT License | 6 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints // token 存储方式 .tokenStore(tokenStore) .authenticationManager(authenticationManager) // 不配置会导致token无法刷新 .userDetailsService(userDetailsService) .allowedTokenEndpointRequestMethods(HttpMethod.POST,HttpMethod.GET); // 判断当前是否使用jwt if(!(tokenStore instanceof RedisTokenStore) && this.converter!=null){ endpoints.accessTokenConverter(converter); } // 处理 ExceptionTranslationFilter 抛出的异常 endpoints.exceptionTranslator(bootWebResponseExceptionTranslator); endpoints.pathMapping("/oauth/confirm_access","/custom/confirm_access"); }
Example #7
Source File: OAuth2ServerConfiguration.java From angularjs-springboot-bookstore with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints .tokenStore(tokenStore()) .authenticationManager(authenticationManager); }
Example #8
Source File: AuthorizationServerConfiguration.java From cola-cloud with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints .tokenStore(new RedisTokenStore(redisConnectionFactory)) // .accessTokenConverter(jwtAccessTokenConverter()) .authenticationManager(authenticationManager) .exceptionTranslator(webResponseExceptionTranslator) .reuseRefreshTokens(false) .userDetailsService(integrationUserDetailsService); }
Example #9
Source File: OAuth2Configuration.java From spring-boot-2-oauth2-authorization-jwt with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.tokenStore(tokenStore()).tokenEnhancer(jwtAccessTokenConverter()) .authenticationManager(authenticationManager).userDetailsService(userDetailsService); if (checkUserScopes) endpoints.requestFactory(requestFactory()); }
Example #10
Source File: OAuth2Config.java From konker-platform with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers( Arrays.asList( tokenEnhancer(), accessTokenConverter() )); endpoints.authenticationManager(authenticationManager) .tokenStore(mongoTokenStore) .tokenEnhancer(tokenEnhancerChain) .allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST); }
Example #11
Source File: OAuthConfiguration.java From spring-glee-o-meter with GNU General Public License v3.0 | 5 votes |
@Override public void configure(final AuthorizationServerEndpointsConfigurer endpoints) { endpoints .accessTokenConverter(accessTokenConverter()) .userDetailsService(userService) .authenticationManager(authenticationManager); }
Example #12
Source File: OAuth2AuthorizationServer.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public void configure( AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints .authenticationManager(authenticationManager) .tokenStore(tokenStore()); }
Example #13
Source File: OAuth2Config.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // super.configure(endpoints); endpoints.tokenStore(tokenStore).tokenEnhancer(jwtAccessTokenConverter).authenticationManager(authenticationManager); endpoints.exceptionTranslator(null); // endpoints.getFrameworkEndpointHandlerMapping().setMappings("/oauth/confirm_access", "/oauth/confirm_access2"); //oatuh2 授权码确认页面 }
Example #14
Source File: FwAuthorizationConfiguration.java From fw-cloud-framework with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer(), jwtAccessTokenConverter())); endpoints.tokenStore(redisTokenStore()) .tokenEnhancer(tokenEnhancerChain) .authenticationManager(authenticationManager) .reuseRefreshTokens(false) .userDetailsService(userDetailsService); }
Example #15
Source File: OAuth2AuthorizationServerConfig.java From oauth2lab with MIT License | 5 votes |
@Override public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception { final TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer())); endpoints.tokenStore(tokenStore()) .tokenEnhancer(tokenEnhancerChain) .authenticationManager(authenticationManager); }
Example #16
Source File: JwkSetConfiguration.java From spring-cloud-demo with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints .authenticationManager(this.authenticationManager) .tokenStore(tokenStore()) .accessTokenConverter(accessTokenConverter()) .userDetailsService(userDetailsService); }
Example #17
Source File: OAuth2ServerConfiguration.java From java-microservice with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.tokenStore(jwtServerConfiguration.tokenStore()) .tokenEnhancer(jwtServerConfiguration.jwtTokenEnhancer()) .authenticationManager( (Authentication authentication) -> authenticationManager .getOrBuild() .authenticate(authentication) ); }
Example #18
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 #19
Source File: AuthorizationServerConfigration.java From Taroco with Apache License 2.0 | 5 votes |
/** * 授权服务器端点配置,如令牌存储,令牌自定义,用户批准和授权类型,不包括端点安全配置 */ @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints .authenticationManager(authenticationManager) .userDetailsService(userNameUserDetailsService) .tokenServices(defaultTokenServices()) .exceptionTranslator(exceptionTranslator) .authorizationCodeServices(redisAuthenticationCodeServices()); }
Example #20
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 #21
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 #22
Source File: Oauth2AuthorizationServerConfig.java From spring-boot-demo with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints.authenticationManager(authenticationManager) .userDetailsService(sysUserService) .tokenStore(tokenStore) .accessTokenConverter(jwtAccessTokenConverter); }
Example #23
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 #24
Source File: OAuth2AuthorizationServer.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints .authenticationManager(authenticationManager) .tokenStore(jwtTokenStore()) .accessTokenConverter(accessTokenConverter()); }
Example #25
Source File: AuthorizationServerConfig.java From black-shop with Apache License 2.0 | 5 votes |
/** * 设置redis读取token以及保存token. */ @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) { endpoints .allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST) .tokenStore(tokenStore()) .tokenEnhancer(tokenEnhancer()) .userDetailsService(blackUserDetailsService) .authenticationManager(authenticationManager) .reuseRefreshTokens(false) ; }
Example #26
Source File: OAuth2AuthorizationServerConfiguration.java From omh-dsu-ri with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints .tokenStore(tokenStore) .authenticationManager(authenticationManager); }
Example #27
Source File: UaaConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { //pick up all TokenEnhancers incl. those defined in the application //this avoids changes to this class if an application wants to add its own to the chain Collection<TokenEnhancer> tokenEnhancers = applicationContext.getBeansOfType(TokenEnhancer.class).values(); TokenEnhancerChain tokenEnhancerChain=new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers(new ArrayList<>(tokenEnhancers)); endpoints .authenticationManager(authenticationManager) .tokenStore(tokenStore()) .tokenEnhancer(tokenEnhancerChain) .reuseRefreshTokens(false); //don't reuse or we will run into session inactivity timeouts }
Example #28
Source File: OAuth2Config.java From konker-platform with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints.authenticationManager(authenticationManager) .tokenStore(mongoTokenStore) .allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST); }
Example #29
Source File: AuthServiceApplication.java From training with Apache License 2.0 | 5 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { endpoints .tokenStore(this.tokenStore()) .accessTokenConverter(jwtAccessTokenConverter()) .authenticationManager(this.authenticationManager); }
Example #30
Source File: AuthServerOAuth2Config.java From Building-Web-Apps-with-Spring-5-and-Angular with MIT License | 5 votes |
@Override public void configure(final AuthorizationServerEndpointsConfigurer endpoints) throws Exception { final TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer())); endpoints.tokenStore(tokenStore()) .tokenEnhancer(tokenEnhancerChain).authenticationManager(authenticationManager); }