Package digilib.auth
Class OpenIdAuthnOps
java.lang.Object
digilib.auth.OpenIdAuthnOps
- All Implemented Interfaces:
AuthnOps
Implements AuthnOps using an OpenId Connect ID token.
The name of the configuration file is read from the digilib config parameter "auth-file".
The tag "digilib-oauth" is read from the configuration file:
<digilib-oauth>
<openid issuer="https://id.some.where" clientid="myclient" roles="someusers" keytype="jwk">
{"kty":"RSA","e":"AQAB","kid":"rsa1","n":"qjQ5U3wXzamg9R...idGpIiVilMDVBs"}
</openid>
</digilib-oauth>
A request with an "id_token" parameter containing a valid token signed with the configured key
including the configured issuer (iss) and clientid (aud) is granted the configured roles.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Fileprotected org.jose4j.jwt.consumer.JwtConsumerJwtConsumer to parse the token without validation to extract the issuerMap of validating JwtConsumers by issuer (URL)Map of (List of) roles by issuer (URL)protected static final org.slf4j.Loggergeneral logger for this classprotected StringName of the cookie that contains the token -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetUserRoles(DigilibRequest request) Return the list of roles associated with the user represented by request.booleanReturn if the implementation supports getUserRoles().voidinit(DigilibConfiguration dlConfig) Configure this AuthnOps instance.booleanisUserInRole(DigilibRequest request, String role) Test if the user represented by request has the given role.
-
Field Details
-
logger
protected static final org.slf4j.Logger loggergeneral logger for this class -
configFile
-
firstPassJwtConsumer
protected org.jose4j.jwt.consumer.JwtConsumer firstPassJwtConsumerJwtConsumer to parse the token without validation to extract the issuer -
idpJwtConsumers
Map of validating JwtConsumers by issuer (URL) -
idpRoles
Map of (List of) roles by issuer (URL) -
tokenCookieName
Name of the cookie that contains the token
-
-
Constructor Details
-
OpenIdAuthnOps
public OpenIdAuthnOps()
-
-
Method Details
-
init
Description copied from interface:AuthnOpsConfigure this AuthnOps instance.- Specified by:
initin interfaceAuthnOps- Parameters:
dlConfig- current DigilibConfiguration- Throws:
AuthOpException- Exception thrown on error.
-
hasUserRoles
public boolean hasUserRoles()Description copied from interface:AuthnOpsReturn if the implementation supports getUserRoles().- Specified by:
hasUserRolesin interfaceAuthnOps- Returns:
- true if the implementation supports getUserRoles().
-
getUserRoles
Description copied from interface:AuthnOpsReturn the list of roles associated with the user represented by request. Returns null if a list of roles is not available. Users of this API should check hasUserRoles().- Specified by:
getUserRolesin interfaceAuthnOps- Parameters:
request- current DigilibRequest- Returns:
- list of user's roles
- Throws:
AuthOpException- Exception thrown on error.
-
isUserInRole
Description copied from interface:AuthnOpsTest if the user represented by request has the given role.- Specified by:
isUserInRolein interfaceAuthnOps- Parameters:
request- Request with user information.role- role to be tested.- Returns:
- true if the user has the role.
- Throws:
AuthOpException- Exception thrown on error.
-