public interface AuthorizationRequestHandlerSpi
AuthorizationRequestHandler.
An implementation of this interface must be given to the constructor
of AuthorizationRequestHandler class.
| Modifier and Type | Method and Description |
|---|---|
javax.ws.rs.core.Response |
generateAuthorizationPage(com.authlete.common.dto.AuthorizationResponse info)
Generate an authorization page (HTML) to ask an end-user whether to
accept or deny an authorization request by a client application.
|
String |
getAcr()
Get the authentication context class reference (ACR) that was
satisfied when the current end-user was authenticated.
|
com.authlete.common.dto.Property[] |
getProperties()
Get extra properties to associate with an access token and/or an
authorization code.
|
long |
getUserAuthenticatedAt()
Get the time when the current end-user was authenticated in
milliseconds since Unix epoch (1970-01-01).
|
String |
getUserSubject()
Get the subject (= unique identifier) of the current end-user.
|
boolean |
isUserAuthenticated()
Check whether an end-user has already logged in or not.
|
boolean isUserAuthenticated()
This method is called only when an authorization request comes
with prompt=none. Therefore, if you have no mind to
support prompt=none, always return false. See
3.1.2.1. Authentication Request in OpenID
Connect Core 1.0 for details about prompt=none.
Below is an example implementation using Apache Shiro.
@Override public boolean isUserAuthenticated() { return SecurityUtils.getSubject().isAuthenticated(); }
true if an end-user has already logged in. Otherwise,
false. When false is returned, the client
application will receive error=login_required.long getUserAuthenticatedAt()
The value is used to check whether the elapsed time since the last
authentication has exceeded the maximum authentication age or not.
See max_age in "3.1.2.1. Authentication Request" in OpenID
Connect Core 1.0, and default_max_age in "2. Client Metadata" in OpenID Connect Dynamic Client Registration 1.0 for details.
This method is called only when an authorization request comes
with prompt=none. Therefore, if you have no mind to
support prompt=none, always return 0. See
3.1.2.1. Authentication Request in OpenID
Connect Core 1.0 for details about prompt=none.
Below is an example implementation using Apache Shiro.
@Override public long getUserAuthenticatedAt() { Session session = SecurityUtils.getSubject().getSession(false); if (session == null) { return 0; } return session.getStartTimestamp().getTime(); }
String getUserSubject()
This method is called only when an authorization request comes
with prompt=none. Therefore, if you have no mind to
support prompt=none, always return null. See
3.1.2.1. Authentication Request in OpenID
Connect Core 1.0 for details about prompt=none.
Below is an example implementation using Apache Shiro.
@Override public long getUserAuthenticatedAt() { return (String)SecurityUtils.getSubject().getPrincipal(); }
String getAcr()
The value returned by this method has an important meaning only
when an authorization requests acr claim as an essential
claim. Practically speaking, it is unlikely to happen. See "5.5.1.1. Requesting the "acr" Claim" in OpenID
Connect Core 1.0 if you are interested in the details.
This method is called only when an authorization request comes
with prompt=none. Therefore, if you have no mind to
support prompt=none, always return null. See
3.1.2.1. Authentication Request in OpenID
Connect Core 1.0 for details about prompt=none.
If you don't know what ACR is, return null.
javax.ws.rs.core.Response generateAuthorizationPage(com.authlete.common.dto.AuthorizationResponse info)
Key information that should be displayed in an authorization page is
stored in the info object. For example, the name of the client
application can be obtained by calling info.getClient().getClientName() method.
Likewise, requested scopes can be obtained as an array of Scope objects by calling info.getScopes() method.
In an authorization page, an end-user will finally decide either to
grant authorization to the client application or to reject the
authorization request. The authorization server should receive the
decision and call handle() method.
info - A response from Authlete's /api/auth/authorization API.
Key information that should be displayed in an authorization
page is stored in the object.com.authlete.common.dto.Property[] getProperties()
This method is expected to return an array of extra properties. The following is an example that returns an array containing one extra property.
@Override publicProperty[] getProperties() { return newProperty[] { newProperty("example_parameter", "example_value") }; }
Extra properties returned from this method will appear as top-level entries in a JSON response from an authorization server as shown in 5.1. Successful Response in RFC 6749.
Keys listed below should not be used and they would be ignored on the server side even if they were used. It's because they are reserved in RFC 6749 and OpenID Connect Core 1.0.
access_token
token_type
expires_in
refresh_token
scope
error
error_description
error_uri
id_token
Note that there is an upper limit on the total size of extra properties. On the server side, the properties will be (1) converted to a multidimensional string array, (2) converted to JSON, (3) encrypted by AES/CBC/PKCS5Padding, (4) encoded by base64url, and then stored into the database. The length of the resultant string must not exceed 65,535 in bytes. This is the upper limit, but we think it is big enough.
This method is called only when an authorization request comes with prompt=none. Therefore, if you have no mind to support prompt=none,
always return null. See 3.1.2.1.
Authentication Request in OpenID Connect Core
1.0 for details about prompt=none.
null is returned, any extra property will
not be associated.Copyright © 2016. All rights reserved.