Class OAuthSessionDelegatingBearerGenerator

java.lang.Object
com.peterphi.std.guice.web.rest.auth.oauth2.OAuthSessionDelegatingBearerGenerator
All Implemented Interfaces:
BearerGenerator

public class OAuthSessionDelegatingBearerGenerator extends Object implements BearerGenerator
Bearer Token Generator that automatically generates User Manager Delegation Tokens for outgoing service calls it is assigned to help with. It follows a simple ruleset:
  1. If this isn't a REST call, use own credentials (e.g. daemon operation)
  2. If this is a REST call but it's arriving from non-logged-in user then use own credentials (e.g. an openly-accessible landing page for a non-logged-in user)
  3. If this is a REST call but the caller is another service acting under their own authority, use own credentials
  4. If this is a REST call and not using OAuth (or User Manager API Tokens) then throw an exception and simply stop (generator is not intended for use in a mixed environment)
  5. Otherwise, create a delegation token (or pass along the one we received)