OAuth STS Interface for Authorization Enforcement Points

Use the WS-Trust interface to directly contact an OAuth Security Token Service (STS) trust chain in ISAM to validate a request for an OAuth protected resource. An OAuth enforcement point intercepts requests for OAuth protected resources. The OAuth enforcement point also validates the request with ISAM, and passes the request through, if it is valid. If the request is not valid, the enforcement point denies access to the protected resource.

OAuth STS overview

We can develop our own customized policy enforcement point to work with the Security Token Service (STS) trust chain through the STS interface. Some examples of existing customized policy enforcement points are WebSphere Servlet Filter, Trust Association Interceptor (TAI), and a reverse proxy such as WebSEAL. As ISAM supports OAuth 2.0 federations, we can develop customized policy enforcement points to work with OAuth 2.0 federations. The following diagram illustrates the relationship between the OAuth STS trust chain and other OAuth components.

Figure 1. OAuth STS trust chain workflow
OAuth STS trust chain workflow

This section describes the process an OAuth enforcement point undertakes to transform an HTTP request for an OAuth protected resource into a WS-Trust message.

The transformation makes it possible for the STS to validate the request. It also describes the possible responses an enforcement point can receive from the STS and how to deal with them.

The following information about the policy decision point in ISAM must be made available to the enforcement point:

Authorization decision request

Configuration

For OAuth 2.0 requests, the enforcement point must know the ISAM OAuth 2.0 issuer address prefix (urn:ibm:ITFIM:oauth20:token:).

HTTP request

When an OAuth 2.0 client retrieves a protected resource with its access token, it constructs a request similar to any of the following examples. Each of these three examples is logically the same request. All that differs is the transmission mechanism (HTTP header, query string, post body) for sending the OAuth 2.0 bearer access token:

Authorization decision request The OAuth 2.0 enforcement point is responsible for the following actions:

The HTTP request is transformed into the following WS-Trust SOAP message:

OAuth 2.0 Token Validate Request (Request Security Token)

The following attributes are defined by the WS-Trust specification. They are used by ISAM to identify the federation associated with this request and to identify the type of OAuth 2.0 access token being used.

The access_token attribute with type urn:ibm:names:ITFIM:oauth:param is mandatory in the WS-Trust message sent to ISAM. It must be appended to the ContextAttributes section of the STSUniversalUser within the WS-Trust Request Security Token. If access_token attribute is missing from the request from the OAuth 2.0 client, the enforcement point does not validate the request with ISAM STS. It can instantly return an HTTP 400 Bad Request status code and optionally can include a description of the error in the body. If the access token is included in the authorization header in the Authorization: Bearer <token> format, the token must still be added to the ContextAttributes section of the STSUU. The same format must be used as if the access token was sent through a query string or post body.

The following attributes are not mandatory in the WS-Trust message sent to Security Verify Access STS for OAuth 2.0. However, they might be useful to a custom mapping rule that is executed by ISAM. It is recommended to append the following attributes to the ContextAttributes section of the STSUniversalUser within the WS-Trust Request Security Token and set the attribute type to urn:ibm:names:ITFIM:oauth:request.

Append any additional parameters the OAuth 2.0 enforcement point finds in the request, such as query or post body parameters that are not of OAuth 2.0, to the Context Attribute section of the STSUniversalUser within the WS-Trust Request Security Token. The type value is determined by the following table.

In OAuth 2.0 requests, these parameters are not required. However, they might be useful to a custom mapping rule that is executed by ISAM. So IBM recommends that you append them.

HTTP Parameter Location Attribute Type Value
URL Query String Parameters urn:ibm:names:ITFIM:oauth:query:param
HTTP Request Body Parameters urn:ibm:names:ITFIM:oauth:body:param

Post body parameters must be included only if the following conditions are met:

Authorization decision response

The SOAP message response from Security Verify Access (regardless of OAuth version) echoes all the context attributes sent in the original request and some extra response context attributes.

OAuth Token Validate Response (RSTR)

The following context attributes returned to the enforcement point by ISAM relate to the authorization decision. It also has the attribute type urn:ibm:names:ITFIM:oauth:response:decision highlighted in italics in the previous RSTR example. It is up to the enforcement point to decide Whether to down-stream these attributes to the OAuth protected resource.

These attributes are primarily for the use of the enforcement point itself to determine the authorization status.

Context attributes Description
authorized The value is set to TRUE if the OAuth request is valid and authorized; FALSE if otherwise.
expires The UTC time when the access token used in the request is no longer valid.

The following context attributes returned to the enforcement point by ISAM must be down-streamed from the enforcement point to the OAuth protected resource. They might be appended to the original HTTP request in any way deemed suitable by the enforcement point and the protected resource. This way, the protected resource can retrieve them (for example, as additional HTTP headers).

These context attributes have the attribute type urn:ibm:names:ITFIM:oauth:response:attribute (highlighted in bold in the previous RSTR example).

Custom mapping rules that are executed after the OAuth trust chain might also append attributes with this type. Therefore, any attribute with this type must be down-streamed to the requested protected resource.

Context attributes Description
access_token The OAuth access token used in the protected resource request.
client_type The type of client that this token was issued to, can be either public or confidential. Public clients are clients that do not have client credentials and therefore cannot authenticate to the authorization server.
oauth_token_client_id The unique identifier of the client to which the current access token was issued.
scope A list of strings representing the resource scope that is authorized by the user at the OAuth resource owner authorization step. The OAuth protected resource can use this attribute to determine which resources to return in the response. This attribute is only present for OAuth flows that include a user authorization step.
username The name of the user who authorized the OAuth token to access their protected resources on their behalf. With OAuth flows that do not involve a separate resource owner, this value is the client identifier.

Additional attributes with the type urn:ibm:names:ITFIM:oauth:response:attribute are sometimes appended by a custom mapping rule, such is the case with recovered_state and username_is_self in the example.

The state_id context attribute returned to the enforcement point by ISAM is used by a custom mapping rule that is executed after the OAuth trust chain. It has the attribute type urn:ibm:names:ITFIM:oauth:state (highlighted with an underline) and can be ignored by the enforcement point.

The state_id attribute is a unique identifier for the current OAuth token used to store state information.

If the state_id attribute is required by the OAuth protected resource, a custom mapping rule can be implemented to make a copy of this attribute. The type can be changed to urn:ibm:names:ITFIM:oauth:response:attribute from the custom mapping rule to ensure that it is down-streamed to the resource.

Error responses

We can customize the amount of OAuth request validation the enforcement point performs. Any validation it performs is repeated by ISAM. Doing some validation before sending an authorization request to ISAM might improve performance. The following validation must be performed by the enforcement point before sending a request to Security Verify Access.

The enforcement point must return an HTTP 401 Unauthorized status code to the OAuth client if the following scenario occurs:

The enforcement point must return an HTTP 503 Service Unavailable status code to the OAuth client if the following scenarios occur:

The enforcement point might also optionally return a WWW-Authenticate HTTP header to indicate its support for OAuth.

Flow chart

The following chart shows the expected workflow of an OAuth authorization enforcement point.

Figure 2. OAuth authorization enforcement point workflow
OAuth authorization enforcement point workflow


Parent topic: OAuth 2.0 and OIDC support