Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Defining a customBean authentication provider

 

In the application.properties file only one property is expected for a customBean authentication provider:

...

Code Block
@Component
public class MyCustomAuthenticationProvider implements AuthenticationProvider {
 
    @Override
    public Authentication authenticate(Authentication authentication) 
      throws AuthenticationException {
        String name = authentication.getName();
        String password = authentication.getCredentials().toString();
         
        if (shouldAuthenticateAgainstThirdPartySystem()) {
            // use the credentials and authenticate against the third-party system
            return new UsernamePasswordAuthenticationToken(name, password, new ArrayList<>());
        } else {
            return null;
        }
    }
 
    @Override
    public boolean supports(Class<?> authentication) {
        return authentication.equals(UsernamePasswordAuthenticationToken.class);
    }
}

@Configuration
public class SecurityConfigurationMyAuthProviderConfig {

    @Bean
    public AuthenticationProvider myAuthProvider01() {
        return new MyCustomAuthenticationProvider();
    }
}

Custom Authentication

By default, Blueriq authentication manager can map roles, teams and custom properties when creating the user object from the authentication data that implements the com.aquima.web.security.BlueriqAuthentication interface.

Providing a custom Authentication implementation

Custom authentication can be provided by implementing the com.blueriq.component.api.security.BlueriqAuthentication and can only be used by using a custom authentication provider.

...