I have a REST service which relies on an external system for authenticating the token but needs to do authorization(API level access using like @Secured) by itself.
Requirement:
- UI generates the token using an external system.
- UI makes REST calls with the token to my service.
- My service validates the token using the external system but authentication for API calls is done by my service
One possible solution was to do this using a filter:
- UI generates the token using an external system.
- UI makes REST calls with the token to my service.
- My service has a filter that invokes the external system with the token.
- The external system for valid token sends back the user details.
My service on successful call set's the SecurityContextHolder like
SecurityContextHolder.getContext().setAuthentication(new AuthorizedUser("test", Arrays.asList(new SimpleGrantedAuthority("test_role")), "test",null));
Is there any other way this can be achieved?