1. Deciding Whether to Implement an Authentication Callback Endpoint
You need to implement an authentication callback endpoint only if one or more of the following conditions are true:- You intend to use Authlete’s default authorization endpoint (
/auth/authorization/direct/service-api-key) implementation and you want your end users to provide their ID and password at the Authlete authorization page. - You intend to use Authlete’s default token endpoint (
/auth/token/direct/service-api-key) implementation and you want to support Resource Owner Password Credentials Grant to authenticate your end users via their ID and password.
When is an authentication callback not required?You don’t need to implement an authentication callback endpoint if your service authenticates end users itself and uses its Authlete API credentials to authenticate to Authlete and assert the end user’s identity.For example, if you are using the Authlete Web APIs such as
/auth/authorization and /auth/authorization/issue, then end-user authentication is completely under your control and there is no need to provide an authentication callback endpoint.Likewise, if you intend to support the OAuth 2.0 Resource Owner Password Credentials Grant (where the client obtains the end user’s ID and password and supplies it to the authorization server), you can manage end-user authentication and implement your own token endpoint using Authlete Web APIs such as /auth/token and /auth/token/issue.Finally, for the purpose of demonstrating the authorization flow, the default implementations accept a service’s Authlete API key & secret of the corresponding service as if it were the ID & password of an end-user. This is how you obtained an access token using your service’s API key and secret in the authorization page of the Getting Started experience. There is no need for an authentication callback endpoint, since Authlete can validate the service credentials directly.2. What is an Authentication Callback Endpoint?
Authentication callback is a Web API that validates an end-user’s credentials. Authlete calls the Web API when it needs to authenticate an end-user via their ID and password.3. Why Is an Authentication Callback Endpoint Needed?
By design, Authlete does not manage end-user accounts and credentials, and cannot perform end-user authentication. Therefore, Authlete delegates end-user authentication to your authentication callback endpoint. As mentioned above, if your service itself authenticates users and provides their ID via the Authlete Web APIs, you do not need an authentication callback endpoint.4. Settings
You must provide the location of your authentication callback endpoint in the Authlete Service Owner Console:- Login to the Service Owner Console. You will see a list of your services.
- Click the Edit button of the relevant service.
- Click the User Authentication tab.
- Enter the Authentication Callback parameters described below.
- Click the Update button to save the changes.
5. Authentication Callback Request
HTTP method
POST method
Content-Type
application/json
Basic Authentication
If you set non-empty values to “Authentication Callback API Key” and “Authentication Callback API Secret” of the service using Service Owner Console, requests from Authlete containAuthorization header for Basic Authentication.
Data Format
The authentication callback request body is in JSON format, and contains the properties listed in the table below (AuthenticationCallbackRequest.java in authlete-java-common corresponds to the current list of properties). There are probably many more properties than you might expect. However, unless you plan to support social login at the authorization page, or OpenID Connect, you only need to care aboutid and password.
6. Authentication Callback Response
An authentication callback endpoint is required to return a response that complies with the requirements described below.Content-Type
application/json; charset=UTF-8
Recommended HTTP headers
Cache-Control: no-store
Pragma: no-cache
Data Format
The body of an authentication callback response must be formatted as JSON. The expected properties are listed in the table below (AuthenticationCallbackResponse.java in authlete-java-common corresponds to the current list of properties). If you do not plan to support OpenID Connect, you can set theclaims property to null.
You are expected to collect values for each claim listed in the
claims property of the request. However, if values of requested claims are not available in your system (even though you have configured them as “Supported Claims”) or if you don’t want to provide claim values, the claims property in the response may be null.
Claims returned from an authentication callback endpoint are embedded in the ID token which will be returned from the authorization endpoint to the client application that made the authorization request. |