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 File
protected org.jose4j.jwt.consumer.JwtConsumer
JwtConsumer 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.Logger
general logger for this classprotected String
Name 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.boolean
Return if the implementation supports getUserRoles().void
init
(DigilibConfiguration dlConfig) Configure this AuthnOps instance.boolean
isUserInRole
(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:AuthnOps
Configure this AuthnOps instance.- Specified by:
init
in interfaceAuthnOps
- Parameters:
dlConfig
- current DigilibConfiguration- Throws:
AuthOpException
- Exception thrown on error.
-
hasUserRoles
public boolean hasUserRoles()Description copied from interface:AuthnOps
Return if the implementation supports getUserRoles().- Specified by:
hasUserRoles
in interfaceAuthnOps
- Returns:
- true if the implementation supports getUserRoles().
-
getUserRoles
Description copied from interface:AuthnOps
Return 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:
getUserRoles
in interfaceAuthnOps
- Parameters:
request
- current DigilibRequest- Returns:
- list of user's roles
- Throws:
AuthOpException
- Exception thrown on error.
-
isUserInRole
Description copied from interface:AuthnOps
Test if the user represented by request has the given role.- Specified by:
isUserInRole
in 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.
-