org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider Java Examples

The following examples show how to use org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider. 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: SecurityConfig.java    From devconf2019-authz with Apache License 2.0 5 votes vote down vote up
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
    SimpleAuthorityMapper grantedAuthorityMapper = new SimpleAuthorityMapper();
    grantedAuthorityMapper.setPrefix("ROLE_");
    grantedAuthorityMapper.setConvertToUpperCase(true);
    keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(grantedAuthorityMapper);
    auth.authenticationProvider(keycloakAuthenticationProvider);
}
 
Example #2
Source File: PersonApplication.java    From blog with Apache License 2.0 5 votes vote down vote up
/**
 * Registers the KeycloakAuthenticationProvider with the authentication manager.
 */
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();

    // adding proper authority mapper for prefixing role with "ROLE_"
    keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());

    auth.authenticationProvider(keycloakAuthenticationProvider);
}
 
Example #3
Source File: PersonApplication.java    From blog with Apache License 2.0 5 votes vote down vote up
/**
 * Registers the KeycloakAuthenticationProvider with the authentication manager.
 */
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();

    // adding proper authority mapper for prefixing role with "ROLE_"
    keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());

    auth.authenticationProvider(keycloakAuthenticationProvider);
}
 
Example #4
Source File: AtlasKeycloakAuthenticationProvider.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasKeycloakAuthenticationProvider() throws Exception {
  this.keycloakAuthenticationProvider = new KeycloakAuthenticationProvider();

  Configuration configuration = ApplicationProperties.get();
  this.groupsFromUGI = configuration.getBoolean("atlas.authentication.method.keycloak.ugi-groups", true);
  this.groupsClaim = configuration.getString("atlas.authentication.method.keycloak.groups_claim");
}
 
Example #5
Source File: SecurityConfig.java    From teiid-spring-boot with Apache License 2.0 5 votes vote down vote up
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
    auth.authenticationProvider(keycloakAuthenticationProvider);
    KeycloakDirectAccessGrantAuthenticationProvider authProvider = new KeycloakDirectAccessGrantAuthenticationProvider(
            keycloakConfigResolver());
    auth.authenticationProvider(authProvider);
}
 
Example #6
Source File: SecurityConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
    keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());
    auth.authenticationProvider(keycloakAuthenticationProvider);
}
 
Example #7
Source File: KeycloakWebSecurityConfigurerAdapter.java    From keycloak with Apache License 2.0 4 votes vote down vote up
protected KeycloakAuthenticationProvider keycloakAuthenticationProvider() {
    return new KeycloakAuthenticationProvider();
}