Auth Adapter

Auth adapter is a package that needs to be injected into Mosip's applications exposing REST API's inorder to secure them.

Auth Adapter includes following class definitions:


Holds the main configuration for authentication and authorization using spring security.


  • AuthenticationManager bean configuration:

    • This is assigned an AuthProvider that we implemented.

    • RETURNS an instance of the ProviderManager.

  • AuthFilter bean configuration:

    • This extends AbstractAuthenticationProcessingFilter.

    • Instance of the AuthFilter is created.

    • This filter comes in line after the AuthHeadersFilter.

    • Binds the AuthenticationManager instance created with the filter.

    • Binds the AuthSuccessHandler created with the filter.

    • RETURNS an instance of the AuthFilter.

  • RestTemplate bean configuration:

    • Binds the ClientInterceptor instance with the RestTemplate instance created.

    • RETURNS an instance of the RestTemplate.

  • Secures endpoints using antMatchers and adds filters in a sequence for execution.


AuthFilter is bound with AuthenticationManager to attempt authentication.

Attempt Authentication tasks:

  • Receives "Authorization" Header from request headers.

  • Use the assigned Authentication manager to authenticate with the token.


This filter is going to act as a CORS filter. It is assigned before AuthFilter in the filter chain.


  • Sets headers to allow cross origin requests.

  • Sets header to allow and expose "Authorization" header.


Contacts auth server to verify token validity.


  • Contacts auth server to verify token validity.

  • Stores the response body in an instance of MosipUser.

  • Updates token into SecurityContext.

  • Bind MosipUser instance details with the AuthUserDetails that extends Spring Security's UserDetails.


Handles successful authentication. If any action needs to be done after successful authentication, this is where you have to do it.


Captures and sends "UnAuthorized" error.


  • Used in AuthProvider for token details.

  • This extends UsernamePasswordAuthenticationToken class.


Used by spring security to store user details like roles and use this across the application for Authorization purpose.


It is used to intercept any http calls made using rest template from this application.


This is added to the list of interceptors in the RestTemplate bean created in the SecurityConfig.


  • Intercept all the requests from the application and do the below tasks.

  • Intercept a request to add auth token to the "Authorization" header.

  • Intercept a response to modify the stored token with the "Authorization" header of the response.


Mosip user is the standard spec that will be tuned based on the details stored in ldap for a user.


Adds latest token to the response headers before it is committed.

Last updated