Skip to content

Oauth2: add ability to decorate AuthenticationProvider when using OAuth2LoginConfigurer #17357

@vmotolyzhenko

Description

@vmotolyzhenko

Expected Behavior

Inside OAuth2LoginConfigurer during init method when postProcess method invoked for OidcAuthorizationCodeAuthenticationProvider do not cast it to OidcAuthorizationCodeAuthenticationProvider but use interface AuthenticationProvider to provide ability to decorate provider inside custom ObjectPostProcessor.

Current Behavior
Inside OAuth2LoginConfigurer during init method when postProcess method invoked for OidcAuthorizationCodeAuthenticationProvider the result object is casted to OidcAuthorizationCodeAuthenticationProvider

Code reference:

OAuth2UserService<OidcUserRequest, OidcUser> oidcUserService = getOidcUserService();
OidcAuthorizationCodeAuthenticationProvider oidcAuthorizationCodeAuthenticationProvider = new OidcAuthorizationCodeAuthenticationProvider(accessTokenResponseClient, oidcUserService);
			.....
oidcAuthorizationCodeAuthenticationProvider = this.postProcess(oidcAuthorizationCodeAuthenticationProvider);
http.authenticationProvider(oidcAuthorizationCodeAuthenticationProvider);

Context

I want to decorate AuthenticationProvider behaviour to invoke some logic before main provider and after.
Alternative is to extend OidcAuthorizationCodeAuthenticationProvider and make a decorator from this class but it looks bad, because i need to inject non null accessTokenResponseClient, oidcUserService parameters (some dummy implementations). Based on code improvement shouldn't be complex.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions