Java Code Examples for org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer#tokenStore()

The following examples show how to use org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer#tokenStore() . 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: OAuth2ClientConfig.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {

	if (jwtTokenStore != null) {
		resources.tokenStore(jwtTokenStore);
	} else if (redisTokenStore != null) {
		resources.tokenStore(redisTokenStore);
	}
	resources.stateless(true);

	resources.authenticationEntryPoint(authenticationEntryPoint);

	resources.expressionHandler(expressionHandler);
	resources.accessDeniedHandler(oAuth2AccessDeniedHandler);

}
 
Example 2
Source File: ZuulServerApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ResourceServerConfigurer resourceServerConfigurer() {
    return new ResourceServerConfigurer() {
        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests()
                .antMatchers("/api/acct/**").access("#oauth2.hasScope('account')")
                .antMatchers("/api/msg/**").access("#oauth2.hasScope('message')")
                .antMatchers("/api/email/**").access("#oauth2.hasScope('email')");
        }

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
            resources.tokenStore(tokenStore());
        }
    };
}
 
Example 3
Source File: ResourceServerConfiguration.java    From onetwo with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
	if(tokenStore!=null){
		resources.tokenStore(tokenStore);
	}
	String resourceId = oauth2Properties.getResourceServer().getResourceId();
	if(resourceId!=null){
		resources.resourceId(resourceId);//see OAuth2AuthenticationProcessingFilter#doFilter -> OAuth2AuthenticationManager#authenticate
	}
	if(oauth2AuthenticationEntryPoint!=null){
		resources.authenticationEntryPoint(oauth2AuthenticationEntryPoint);
	}
	if(oauth2AccessDeniedHandler!=null){
		resources.accessDeniedHandler(oauth2AccessDeniedHandler);
	}
}
 
Example 4
Source File: OauthConfig.java    From entref-spring-boot with MIT License 5 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // setup the resource id
    resources.resourceId(this.env.getProperty(Constants.ENV_OAUTH_RES_ID));

    // setup the token store
    resources.tokenStore(new JwkTokenStore(this.env.getProperty(Constants.ENV_OAUTH_KEYSET_URI)));
}
 
Example 5
Source File: EmailApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ResourceServerConfigurer resourceServerConfigurer() {
    return new ResourceServerConfigurer() {
        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests()
                .anyRequest().access("#oauth2.hasScope('email')");
        }

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
            resources.tokenStore(tokenStore());
        }
    };
}
 
Example 6
Source File: AcctApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ResourceServerConfigurer resourceServerConfigurer() {
    return new ResourceServerConfigurer() {
        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests()
                .anyRequest().access("#oauth2.hasScope('account')");
        }

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
            resources.tokenStore(tokenStore());
        }
    };
}
 
Example 7
Source File: MsgApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ResourceServerConfigurer resourceServerConfigurer() {
    return new ResourceServerConfigurer() {
        @Override
        public void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests()
                .anyRequest().access("#oauth2.hasScope('message')");
        }

        @Override
        public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
            resources.tokenStore(tokenStore());
        }
    };
}
 
Example 8
Source File: ResourceServerConfig.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.tokenStore(jwtTokenStore);
}
 
Example 9
Source File: ResourceServerConfig.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.tokenStore(jwtTokenStore);
}
 
Example 10
Source File: ResourceServerConfig.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.tokenStore(jwtTokenStore);
}
 
Example 11
Source File: ResourceServerConfig.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.tokenStore(jwtTokenStore);
}
 
Example 12
Source File: OAuth2ResourceServer.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.tokenStore(tokenStore());
}
 
Example 13
Source File: OAuth2ResourceServer.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources)
        throws Exception {
    resources.tokenStore(tokenStore());
}
 
Example 14
Source File: OAuth2ServerConfiguration.java    From spring-boot-oauth2-password-flow with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
    resources
            .tokenStore(new JwtTokenStore(jwtAccessTokenConverter));
}
 
Example 15
Source File: Oauth2AuthorizationServerApplication.java    From spring-oauth2-jwt-jdbc with MIT License 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources)
        throws Exception {
    resources.tokenStore(tokenStore);
}
 
Example 16
Source File: ResourceServer.java    From lolibox with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources)
        throws Exception {
    resources.tokenStore(tokenStore);
}