0
votes

I have created a custom authentication flow to authenticate using an external provider. As per my understanding, here is the flow of execution.

  1. CustomAuthenticationHandler (extending DefaultAuthenticationFeedbackHandler & implementing AuthenticationHandler, AuthenticationFeedbackHandler): this extracts the credentials and calls the appropriate login module using JAAS configuration.
  2. CustomLoginModule (extending AbstractLoginModule). This calls the identity provider, assigns additional groups optionally.
  3. CustomIdentityProvider (implementing ExternalIdentityProvider): This is where authentication should happen by calling the auth API of my external provider.

The authentication is working fine, I mean

1 > 2 > 3 is working fine and I am able to call API and authenticate the user.

I am getting user information from API in (3) and I am passing it to (2) thru CustomUser (extending ExtenalUser).

My problem is I am unable to pass the user info from (2) to (1). I need this information in further processing of request, to display on UI.

How can I pass this data from (2) to (1) ?

What I have tried so far?

I have created a AuthInfo object and call setInfoInfo object of LoginModule class. It is not working. None ofthe custom params I set in the authInfo are available in the

public boolean authenticationSucceeded(HttpServletRequest request,
            HttpServletResponse response, AuthenticationInfo authInfo)

that I have over written in CustomAuthenticationHandler class. How can I get my custom params in CustomAuthenticationHandler?

1

1 Answers

1
votes

I do not think you need 2 and 3. In the extractCredentials method you can call API to authenticate and authenticationSucceeded method to assign user to groups.

If you want to use custom params to use then you need to do implement org.apache.sling.auth.core.spi.AuthenticationInfoPostProcessor this interface in your custom post authentication class.

You can get AuthInfo object in process method

@Component
@Service
public class CustomAuthPostProcess implements AuthenticationInfoPostProcessor {
 @Override
public void postProcess(final AuthenticationInfo authenticationInfo,
        final HttpServletRequest httpServletRequest,
        final HttpServletResponse httpServletResponse)
        throws LoginException {
 // Your logic
   }  
 }