org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer Java Examples
The following examples show how to use
org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer.
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: Oauth2AuthorizationServerConfig.java From spring-security-oauth2-demo with GNU General Public License v3.0 | 6 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("oauth2") .secret("$2a$10$uLCAqDwHD9SpYlYSnjtrXemXtlgSvZCNlOwbW/Egh0wufp93QjBUC") .resourceIds("oauth2") .authorizedGrantTypes("password", "authorization_code", "refresh_token", "sms") .authorities("ROLE_ADMIN", "ROLE_USER") .scopes("all") .accessTokenValiditySeconds(Math.toIntExact(Duration.ofHours(1).getSeconds())) .refreshTokenValiditySeconds(Math.toIntExact(Duration.ofHours(1).getSeconds())) .redirectUris("http://example.com") .and() .withClient("test") .secret("$2a$10$wlgcx61faSJ8O5I4nLiovO9T36HBQgh4RhOQAYNORCzvANlInVlw2") .resourceIds("oauth2") .authorizedGrantTypes("password", "authorization_code", "refresh_token", "sms") .authorities("ROLE_ADMIN", "ROLE_USER") .scopes("all") .accessTokenValiditySeconds(Math.toIntExact(Duration.ofHours(1).getSeconds())) .refreshTokenValiditySeconds(Math.toIntExact(Duration.ofHours(1).getSeconds())) .redirectUris("http://example.com"); }
Example #3
Source File: OAuth2Config.java From spring-cloud-study with Apache License 2.0 | 6 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.jdbc(dataSource); // clients.inMemory() // .withClient("order-client") // .secret(passwordEncoder.encode("order-secret-8888")) // .authorizedGrantTypes("refresh_token", "authorization_code", "password") // .accessTokenValiditySeconds(3600) // .scopes("all") // .and() // .withClient("user-client") // .secret(passwordEncoder.encode("user-secret-8888")) // .authorizedGrantTypes("refresh_token", "authorization_code", "password") // .accessTokenValiditySeconds(3600) // .scopes("all"); }
Example #4
Source File: SophiaAuthorizationServerConfig.java From sophia_scaffolding with Apache License 2.0 | 6 votes |
/** * 配置客户端详情信息,客户端详情信息在这里进行初始化,通过数据库来存储调取详情信息 */ @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { InMemoryClientDetailsServiceBuilder builder = clients.inMemory(); if (ArrayUtils.isNotEmpty(securityProperties.getOauth2().getClients())) { for (OAuth2ClientProperties client : securityProperties.getOauth2().getClients()) { builder .withClient(client.getClientId()) .secret(new BCryptPasswordEncoder().encode(client.getClientSecret())) // .resourceIds("admin","auth") //设置token的有效期,不设置默认12小时 .accessTokenValiditySeconds(client.getAccessTokenValidatySeconds()) //设置刷新token的有效期,不设置默认30天 .refreshTokenValiditySeconds(client.getRefreshTokenValiditySeconds()) .redirectUris("http://www.baidu.com") .authorizedGrantTypes("authorization_code","client_credentials", "refresh_token", "password") .scopes("all", "read", "write") .autoApprove(true); } } }
Example #5
Source File: AuthServerConfigurer.java From tutorials with MIT License | 6 votes |
@Override public void configure( ClientDetailsServiceConfigurer clients) throws Exception { clients .inMemory() .withClient("authserver") .secret(passwordEncoder.encode("passwordforauthserver")) .redirectUris("http://localhost:8080/login") .authorizedGrantTypes("authorization_code", "refresh_token") .scopes("myscope") .autoApprove(true) .accessTokenValiditySeconds(30) .refreshTokenValiditySeconds(1800); }
Example #6
Source File: AuthorizationServerConfig.java From tutorials with MIT License | 6 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients .inMemory() .withClient("baeldung") .secret(passwordEncoder().encode("baeldung")) .authorizedGrantTypes("client_credentials", "password", "authorization_code") .scopes("openid", "read") .autoApprove(true) .and() .withClient("baeldung-admin") .secret(passwordEncoder().encode("baeldung")) .authorizedGrantTypes("authorization_code", "client_credentials", "refresh_token") .scopes("read", "write") .autoApprove(true); }
Example #7
Source File: OAuth2ServerConfig.java From open-capacity-platform with Apache License 2.0 | 6 votes |
/** * 配置应用名称 应用id * 配置OAuth2的客户端相关信息 */ @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { // if(clientDetailsService!=null){ // clients.withClientDetails(clientDetailsService); // }else{ // clients.inMemory().withClient("neusoft1").secret("neusoft1") // .authorizedGrantTypes("authorization_code", "password", // "refresh_token").scopes("all") // .resourceIds(SERVER_RESOURCE_ID).accessTokenValiditySeconds(1200) // .refreshTokenValiditySeconds(50000) // .and().withClient("neusoft2").secret("neusoft2") // .authorizedGrantTypes("authorization_code", "password", // "refresh_token").scopes("all") // .resourceIds(SERVER_RESOURCE_ID).accessTokenValiditySeconds(1200) // .refreshTokenValiditySeconds(50000) // ; // } clients.withClientDetails(redisClientDetailsService); redisClientDetailsService.loadAllClientToCache(); }
Example #8
Source File: AuthorizationConfig.java From Using-Spring-Oauth2-to-secure-REST with MIT License | 6 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients .inMemory() .withClient("trusted-app") .authorizedGrantTypes("client_credentials", "password", "refresh_token") .authorities(Role.ROLE_TRUSTED_CLIENT.toString()) .scopes("read", "write") .resourceIds(resourceId) .accessTokenValiditySeconds(10) .refreshTokenValiditySeconds(30000) .secret("secret") .and() .withClient("register-app") .authorizedGrantTypes("client_credentials") .authorities(Role.ROLE_REGISTER.toString()) .scopes("registerUser") .accessTokenValiditySeconds(10) .refreshTokenValiditySeconds(10) .resourceIds(resourceId) .secret("secret"); }
Example #9
Source File: AuthorizationServerConfig.java From spring-boot-demo with MIT License | 6 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("client1") .resourceIds(RESOURCE_ID) .authorizedGrantTypes("authorization_code", "refresh_token", "implicit") .authorities("ROLE_CLIENT") .scopes("get_user_info", "get_childlist") .secret("secret") .redirectUris("http://localhost:8081/client/account/redirect") .autoApprove(true) .autoApprove("get_user_info") .and() .withClient("client2") .resourceIds(RESOURCE_ID) .authorizedGrantTypes("authorization_code", "refresh_token", "implicit") .authorities("ROLE_CLIENT") .scopes("get_user_info", "get_childlist") .secret("secret") .redirectUris("http://localhost:8082/client/account/redirect"); }
Example #10
Source File: FwAuthorizationConfiguration.java From fw-cloud-framework with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient(authServerConfiguration.getClientId()) .secret(authServerConfiguration.getClientSecret()) .authorizedGrantTypes(SecurityConstant.REFRESH_TOKEN, SecurityConstant.PASSWORD, SecurityConstant.AUTHORIZATION_CODE) .scopes(authServerConfiguration.getScope()) // true 直接跳转到客户端页面,false 跳转到用户确认授权页面 .autoApprove(true); }
Example #11
Source File: SecurityApp.java From Microservices-Building-Scalable-Software with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clientDetailsServiceConfigurer) throws Exception { // Using hardcoded inmemory mechanism because it is just an example clientDetailsServiceConfigurer.inMemory() .withClient("client") .secret("clientsecret") .authorizedGrantTypes("authorization_code", "refresh_token", "implicit", "password", "client_credentials") .scopes("apiAccess"); }
Example #12
Source File: OAuthConfiguration.java From spring-glee-o-meter with GNU General Public License v3.0 | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient(clientId) .secret(passwordEncoder.encode(clientSecret)) .accessTokenValiditySeconds(accessTokenValiditySeconds) .refreshTokenValiditySeconds(refreshTokenValiditySeconds) .authorizedGrantTypes(authorizedGrantTypes) .scopes("read", "write") .resourceIds("api"); }
Example #13
Source File: OauthAuthorizationServerConfig.java From codeway_service with GNU General Public License v3.0 | 5 votes |
/** * 配置客户端应用 * 如果要实现类似GitHub、Google那种支持开发者申请APP或者有多个不同系统的可以将此处改为从数据库动态取数据加载。 */ @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { // clients.jdbc(this.dataSource).clients(this.clientDetails()); // 从数据加载 clients.inMemory() .withClient("XcWebApp")//客户端id .secret("XcWebApp")//密码,要保密 .accessTokenValiditySeconds(CommonConst.TIME_OUT_DAY)//访问令牌有效期 .refreshTokenValiditySeconds(CommonConst.TIME_OUT_DAY)//刷新令牌有效期 //授权客户端请求认证服务的类型authorization_code:根据授权码生成令牌, // client_credentials:客户端认证,refresh_token:刷新令牌,password:密码方式认证 .authorizedGrantTypes("authorization_code", "client_credentials", "refresh_token", "password") .scopes("app");//客户端范围,名称自定义,必填 }
Example #14
Source File: OAuth2Config.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("gray-server") .secret("V@JA-#i+6BkDhhq9") .authorizedGrantTypes("client_credentials", "refresh_token", "default") .accessTokenValiditySeconds(3600 * 24 * 30) .refreshTokenValiditySeconds(3600 * 24 * 30 * 2) ; }
Example #15
Source File: PolymerAuthConfig.java From spring-polymer-demo with Artistic License 2.0 | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("polymer-ui-server") .secret("polymer-ui-secret") .authorizedGrantTypes("authorization_code", "refresh_token", "password") .scopes("openid"); }
Example #16
Source File: AuthorizationServerConfig.java From Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("normal-app") .authorizedGrantTypes("authorization_code", "implicit") .authorities("ROLE_CLIENT") .scopes("read", "write") .resourceIds(resourceId) .accessTokenValiditySeconds(accessTokenValiditySeconds) .refreshTokenValiditySeconds(refreshTokenValiditySeconds) .and() .withClient("trusted-app") .authorizedGrantTypes("client_credentials", "password", "refresh_token") .authorities("ROLE_TRUSTED_CLIENT") .scopes("read", "write") .resourceIds(resourceId) .accessTokenValiditySeconds(accessTokenValiditySeconds) .refreshTokenValiditySeconds(refreshTokenValiditySeconds) .secret("secret") .and() .withClient("register-app") .authorizedGrantTypes("client_credentials") .authorities("ROLE_REGISTER") .scopes("read") .resourceIds(resourceId) .secret("secret") .and() .withClient("my-client-with-registered-redirect") .authorizedGrantTypes("authorization_code") .authorities("ROLE_CLIENT") .scopes("read", "trust") .resourceIds("oauth2-resource") .redirectUris("http://anywhere?key=value"); }
Example #17
Source File: OAuth2AuthorizationServer.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { //@formatter:off clients.inMemory() .withClient("clientapp") .secret("123456") .redirectUris("http://localhost:9000/callback") .authorizedGrantTypes("authorization_code") .scopes("read_profile", "read_contacts"); //@formatter:on }
Example #18
Source File: OAuth2ServerConfiguration.java From todo-spring-angular with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients .inMemory() .withClient(propertyResolver.getProperty("clientid")) .scopes("read", "write") .authorities("USER") .authorizedGrantTypes("password", "refresh_token") .secret(propertyResolver.getProperty("secret")) .accessTokenValiditySeconds(propertyResolver.getProperty("tokenValidityInSeconds", Integer.class, 1800)); }
Example #19
Source File: AuthServerConfig.java From spring-boot-examples with Apache License 2.0 | 5 votes |
@Override public void configure(final ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("SampleClientId") .secret(passwordEncoder.encode("secret")) .authorizedGrantTypes("authorization_code") .scopes("user_info") .autoApprove(true) .redirectUris("http://localhost:8301/login", "http://localhost:8302/login"); }
Example #20
Source File: AuthorizationServerConfig.java From moserp with Apache License 2.0 | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("web") .authorizedGrantTypes("authorization_code", "client_credentials", "refresh_token", "password", "implicit") .scopes("read", "write", "openid") .accessTokenValiditySeconds(3000) .and() .withClient("android") .authorizedGrantTypes("authorization_code", "client_credentials", "refresh_token", "password", "implicit") .scopes("read", "write", "openid") .accessTokenValiditySeconds(3000) ; }
Example #21
Source File: AuthServerConfig.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
@Override public void configure(final ClientDetailsServiceConfigurer clients) throws Exception { ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder>.ClientBuilder builder = clients .inMemory().withClient(this.details.getClientId()); builder.secret(this.details.getClientSecret()) .resourceIds(this.details.getResourceIds().toArray(new String[0])) .authorizedGrantTypes( this.details.getAuthorizedGrantTypes().toArray(new String[0])) .authorities(AuthorityUtils .authorityListToSet(this.details.getAuthorities()) .toArray(new String[0])) .scopes(this.details.getScope().toArray(new String[0])); if (this.details.getAutoApproveScopes() != null) { builder.autoApprove( this.details.getAutoApproveScopes().toArray(new String[0])); } if (this.details.getAccessTokenValiditySeconds() != null) { builder.accessTokenValiditySeconds( this.details.getAccessTokenValiditySeconds()); } if (this.details.getRefreshTokenValiditySeconds() != null) { builder.refreshTokenValiditySeconds( this.details.getRefreshTokenValiditySeconds()); } if (this.details.getRegisteredRedirectUri() != null) { builder.redirectUris( this.details.getRegisteredRedirectUri().toArray(new String[0])); } }
Example #22
Source File: OAuth2JwtConfig.java From java8-spring-cloud-microservice-demo with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("default-client") .secret("sssshhh") .authorizedGrantTypes("password") .authorities("ROLE_ADMIN", "USER") .scopes("read", "write", "report") .resourceIds("default-resources") .accessTokenValiditySeconds(99999); }
Example #23
Source File: SecurityApp.java From Mastering-Microservices-with-Java-9-Second-Edition with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clientDetailsServiceConfigurer) throws Exception { // Using hardcoded inmemory mechanism because it is just an example clientDetailsServiceConfigurer.inMemory() .withClient("client") .secret("clientsecret") .authorizedGrantTypes("authorization_code", "refresh_token", "implicit", "password", "client_credentials") .scopes("apiAccess"); }
Example #24
Source File: AuthorizationServerConfig.java From mall with Apache License 2.0 | 5 votes |
/** * 客户端配置 */ @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory().withClient("client_2") .authorizedGrantTypes("password", "refresh_token") .scopes("select") .secret("$2a$10$ijOPEDarOjkdahi3xpslIu6.cMpBVqYWpbGTkCh0h7Kjt4.NWQwkK"); }
Example #25
Source File: OAuth2AuthorizationServer.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients .inMemory() .withClient("clientapp") .secret("123456") .scopes("read_profile") .authorizedGrantTypes("password", "authorization_code"); }
Example #26
Source File: AuthorizationServerConfig.java From syhthems-platform with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.withClientDetails(clientDetailsService) /*.withClient("syhthems-web") .secret(passwordEncoder.encode("sunriseydy-syhthems-web-secret")) .authorizedGrantTypes("password", "refresh_token") .scopes("web") .autoApprove(true)*/; }
Example #27
Source File: AuthServiceApplication.java From building-microservices with Apache License 2.0 | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("android") .authorizedGrantTypes("authorization_code", "password", "implicit") .scopes("read", "write", "openid") .secret("secret") .and() .withClient("html5") .authorizedGrantTypes("authorization_code", "password", "implicit") .scopes("read", "write", "openid") .secret("secret"); }
Example #28
Source File: OAuth2AuthorizationServer.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { //@formatter:off clients.inMemory() .withClient("clientapp") .secret("123456") .redirectUris("http://localhost:9000/callback") .authorizedGrantTypes("authorization_code", "implicit", "password") .scopes("read_profile", "read_contacts"); //@formatter:on }
Example #29
Source File: OAuth2AuthorizationServer.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.inMemory() .withClient("clientapp") .secret("123456") .scopes("read_profile") .authorizedGrantTypes( "password", "authorization_code"); }
Example #30
Source File: SecurityApp.java From Mastering-Microservices-with-Java-9-Second-Edition with MIT License | 5 votes |
@Override public void configure(ClientDetailsServiceConfigurer clientDetailsServiceConfigurer) throws Exception { clientDetailsServiceConfigurer.inMemory() .withClient("client") .secret("clientsecret") .authorizedGrantTypes("authorization_code", "refresh_token", "implicit", "password", "client_credentials") .scopes("apiAccess"); }