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

The following examples show how to use org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer#tokenKeyAccess() . 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 java-tutorial with MIT License 5 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) {
    security.allowFormAuthenticationForClients();
    // 获取 token 的策略
    security.tokenKeyAccess("permitAll()");
    security.checkTokenAccess("isAuthenticated()");
}
 
Example 2
Source File: OAuth2AuthorizationServerConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
	security.passwordEncoder(NoOpPasswordEncoder.getInstance());
	if (this.properties.getCheckTokenAccess() != null) {
		security.checkTokenAccess(this.properties.getCheckTokenAccess());
	}
	if (this.properties.getTokenKeyAccess() != null) {
		security.tokenKeyAccess(this.properties.getTokenKeyAccess());
	}
	if (this.properties.getRealm() != null) {
		security.realm(this.properties.getRealm());
	}
}
 
Example 3
Source File: AuthorizationServerConfiguration.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Override
	public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
//		security.and().requestMatchers()
		AuthorizationServerProps authProps = oauth2Properties.getAuthorizationServer();
		if(authProps.isAllowFormAuthenticationForClients()){
			security.allowFormAuthenticationForClients();
			//FIX: AuthorizationServerSecurityConfigurer创建form验证filter的时,没有使用配置的oauth2AuthenticationEntryPoint
			security.addObjectPostProcessor(new ClientCredentialsTokenEndpointFilterPostProcessor());
		}
		
		if(authProps.isSslOnly()){
			security.sslOnly();
		}
		if(StringUtils.isNotBlank(authProps.getRealm())){
			security.realm(authProps.getRealm());
		}
		if(StringUtils.isNotBlank(authProps.getCheckTokenAccess())){
			security.checkTokenAccess(authProps.getCheckTokenAccess());
		}
		if(StringUtils.isNotBlank(authProps.getTokenKeyAccess())){
			security.tokenKeyAccess(authProps.getTokenKeyAccess());
		}
		
		if(oauth2AuthenticationEntryPoint!=null){
			security.authenticationEntryPoint(oauth2AuthenticationEntryPoint);
		}
		if(oauth2AccessDeniedHandler!=null){
			security.accessDeniedHandler(oauth2AccessDeniedHandler);
		}
		if(passwordEncoder!=null){
			security.passwordEncoder(passwordEncoder);
		}
	}
 
Example 4
Source File: OAuth2Config.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
    security.allowFormAuthenticationForClients();
    security.checkTokenAccess("isAuthenticated()");
    security.tokenKeyAccess("isAuthenticated()");
}
 
Example 5
Source File: OAuth2Config.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
    security.allowFormAuthenticationForClients();
    security.checkTokenAccess("isAuthenticated()");
    security.tokenKeyAccess("isAuthenticated()");
}
 
Example 6
Source File: SsoAuthConfig.java    From wangsy-january with Apache License 2.0 4 votes vote down vote up
/**
 * 认证服务器安全配置
 */
@Override
public void configure(AuthorizationServerSecurityConfigurer security) {
    // 访问服务器的tokenKey(下面的wangsy)时候需要身份认证
    security.tokenKeyAccess("isAuthenticated()");
}
 
Example 7
Source File: SsoAuthorizationServerConfig.java    From SpringAll with MIT License 4 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) {
    security.tokenKeyAccess("isAuthenticated()"); // 获取密钥需要身份认证
}
 
Example 8
Source File: OAuth2AuthorizationServer.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
    security.tokenKeyAccess("permitAll()");
}
 
Example 9
Source File: OAuth2AuthorizationServer.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
/**
 * Enables the usage of /oauth/token_key to retrieve the JWT signature (public key).
 */
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
    security.tokenKeyAccess("permitAll()");
}
 
Example 10
Source File: AuthorizationServerConfiguration.java    From demo-spring-boot-security-oauth2 with MIT License 4 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
	oauthServer.tokenKeyAccess("isAnonymous() || hasAuthority('ROLE_TRUSTED_CLIENT')");
	oauthServer.checkTokenAccess("hasAuthority('ROLE_TRUSTED_CLIENT')");
}
 
Example 11
Source File: AuthorizationServerConfiguration.java    From fw-spring-cloud with Apache License 2.0 2 votes vote down vote up
/**
 * springSecurity 授权表达式,
 *
 * @param security
 * @throws Exception
 */
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
    security.tokenKeyAccess("permitAll()");
    security.checkTokenAccess("isAuthenticated()");
}
 
Example 12
Source File: AuthorizationServerConfiguration.java    From fw-spring-cloud with Apache License 2.0 2 votes vote down vote up
/**
 * springSecurity 授权表达式,
 *
 * @param security
 * @throws Exception
 */
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
    security.tokenKeyAccess("isAuthenticated()");
}
 
Example 13
Source File: PcAuthorizationServerConfig.java    From paascloud-master with Apache License 2.0 2 votes vote down vote up
/**
 * Configure.
 *
 * @param security the security
 *
 * @throws Exception the exception
 */
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
	security.tokenKeyAccess("permitAll()");
	security.allowFormAuthenticationForClients();
}