OAuth 2
Published in

OAuth 2

Transaction Authorization or why we need to re-think OAuth scopes

Have you ever come across limitations of the way OAuth expresses the requested scope of an access token? Well, I have several times in the course of the last couple of years in the areas of open banking and remote electronic signature creation.

Let’s take the example of a payment authorization: If you want to authorize a payment using OAuth, you need to pass amount, currency, recipient, and purpose to the authorization server. Otherwise, the authorization server cannot gather the user’s consent for that particular transaction and mint an access token that is really constrained to the transaction’s parameters (e.g., the amount). A data structure to carry this data could look like this (based on NextGenPSD2):

Another example is electronic signing where the user needs to authorize the creation of signatures for one or more documents. This effectively means to pass the type of signature (different types result in different legal consequences!), the list of document labels along with the respective hash values into the OAuth authorization process. Here is an example (based on the latest ETSi standard):

All this transaction data is needed to fully define the intended scope of the access token. Passing a fixed scope like „payment“ or “sign” is not enough.

Let’s face it: authorizing transactions using OAuth is a challenging use case, and it’s rather new. It goes beyond what had been done with OAuth so far.

OAuth Scope Parameter

So it does not come as a surprise that the structured data as described above won’t easily fit into the OAuth scope parameter. First of all, the syntax definition of the scope parameter [RFC 6749] does not allow to use backslashes and quotation marks. Well, one could Base64URI encode the JSON structure and put it into the scope parameter, something like this:

Looks a bit alien and has a significant downside — it will break most existing OAuth implementations since they directly process the parameter as space delimited set of string values. Now, the authorization server would first need to Base64URI decode the scope parameter and, at best, parse the result into a JSON document for further processing.

Additionally, the request URL might get really big and the request data is not protected from modifications by the user.

Are there other options?

Sure! Several patterns to carry rich authorization data in conformance with RFC 6749 have been implemented in the last couple of years, e.g., driven by PSD2 and eIDAS. Let’s take a look into them.

Lodging Intent Pattern

This pattern is, for example, used by UK Open Banking and NextGenPSD2. An extensive description can be found at the OpenID Foundation’s FAPI WG site.

This pattern basically uses a HTTP resource to represent the transaction authorization data and passes a link to this resource into the authorization process.

Let’s assume a client wants to conduct a payment transaction. In the first step, it creates a payment resource using the structure introduced above in a request like this:

The HTTP response contains the id of the resource.

This identifier is then used in the authorization request to refer the authorization server to this resource. UK Open Banking uses a special claim value to carry this data, NextGenPSD2 uses a dynamic scope value (like “payment:36fc67776”). The following example uses the latter approach.

The authorization server obtains the transaction details from this resource and use it to parameterize the authorization process.

Most significantly, the user must be presented with all the details in the user consent dialog and the authorization server also needs to convey this data to the respective resource server(s) with the access token issued as result of the process.

Open Banking implementation experience has shown that this kind of dynamically parameterized authorization process requires changes to most existing OAuth implementations.

For example, most implementations today require a static list of supported scope values that are mapped to fixed text for the user consent screen. That’s fine for requesting “read” access to a user’s profile since the description can be static. In case of a payment authorization, however, the authorization server needs to render a consent screen showing the actual transaction details, e.g. the amount, to the user for confirmation. Apparently, fixed scopes, simple text blocks, and a bit of css/template magic don’t work.

In some cases, the user will even be asked to select options, e.g. the account to withdraw the money from. And not to forget, this selection and the other transaction details need to be carried through the rest of the process to the resource server via access tokens and token introspection.

In my opinion, vendors face the challenge to provide a new kind of extensibility via programmatic extensions points and APIs so implementers can develop application-specific consents.

Important to keep in mind: This challenges are not specific to the lodging intent pattern but caused by the dynamic and rich nature of the use cases in open banking or signature creation.

So let’s come back to the lodging intent and its pros and cons:

  • Lodging intent complies to RFC 6749 (although most OAuth implementations so far did not support non-static scope values).
  • It keeps the (additional) authorization data out of the authorization request URI, i.e. it does not inflate authorization URLs and provides data integrity and authenticity without the need to sign data.
  • In my experience this pattern works very well, in particular if the resource represents a certain transaction over its various stages, e.g., setup, confirmation, submission and (potentially) cancellation of a payment.
  • But it somehow feels overdone if applied to just complex authorization in a non-transactional case, such as access to account information. I’m in doubt that the cost of implementing another resource „just“ to convey the authorization data is the simplest solution.

So let’s look for simpler solutions.

Scope-specific URI request parameters

OpenID Connect, for example, combines the static scope value “openid” with the additional JSON-encoded „claims“ parameter. This parameter might be used to, in detail, define the requested claims and their allocation to the ID Token and the User Info response.

Let’s map this to our payment example. We could use a scope value „payment“ and a corresponding URI query parameter with the same name like this:

  • As the first observation, this pattern requires the authorization server to be aware of the application-specific relationships between a scope values and a certain URI query parameters (e.g. “payment” and “payment”). I bet every OpenID Connect product has hard coded this for „openid” and „claims”. But is this desirable for additional applications, such as payments, as well? I don’t think so. As a vendor or maintainer, I would rather prefer to have a generic solution that can be customized to the application‘s needs. Using the same name for both the scope value and the parameter would be one option, in more sophisticated solutions the scope value could refer to the associated query parameter similar to the way the dynamic part of the scope value refers to a certain resource in the lodging intend pattern.
  • The pattern has further challenges: The requests will get quite voluminous, the authorization data is not protected against modifications, and JSON in URI query parameters just looks alien and isn’t that straightforward to handle.

Let’s first look how the secure transmission of the authorization data can be achieved.

Request object

OpenID Connect provides a solution with the request object mechanism, which is also making its way into OAuth through the JWT Secured Authorization Request (JAR) draft.

A request object allows a client to represent a request as a JSON Web Token (JWT). This JWT contains all OAuth authorization request parameters as top level elements and is signed and (optionally) encrypted.

The following example transforms our payment authorization request into a request object:

Looks good, but sending this JWT in the request URI would clearly intensify the URI size problem.

The request object mechanism therefore allows the client to host the request object and just pass the respective URI to the authorization request, which is shown in the following example.

The AS will then fetch the request data from this URI.

  • This pattern has clear advantages: rich authorization data can be sent in a JSON object with integrity and authenticity protection while keeping the request URI size pretty small (actually even smaller than with plain OAuth).
  • But there is also a downside to it: The client needs to maintain and expose request objects. This might look easy on first sight, but the client needs to be able to handle inbound requests from the authorization server and, potentially, store a large number of objects in its database including the need to properly clean them up.
  • It also means the availability and latency of the authorization process at the authorization server depends on the availability and latency of the client’s backend.
  • Moreover, server-side requests brings all the problems of server-side request forgery.

But help is approaching …

Pushed Request Object

… as OpenID Foundation’s Financial Grade API Working group specifies a new mechanisms to host request objects at the authorization server.

In order to utilize this mechanism, the client creates a request object and posts it to the authorization server as shown in the following example (using a JWT representing the payment request object as shown above).

Note: The client authenticates towards the AS by signing the request object.

The Authorization server responds with a request URN

The client then uses this URN in the following authorization request.

  • This approach solves all the problems mentioned in the last section. The client is relieved from the burden to maintain and expose request objects. The user experience at the authorization server no longer depends on availability and latency of client provided services and server-side request forgery went away.
  • And there are further advantages: The authorization server is able to authenticate the client and to check the integrity of the request before the actual authorization request is sent. This helps to refuse bad requests early and it significantly increases the trust an authorization server may place on the client’s identity in the authorization flow! This is new to OAuth 2 (and conceptually re-introduces OAuth 1 request tokens :-)).
  • In my opinion, pushed request objects and lodging intent share the same advantages while the pushed request object has the appeal of being a universal solution.
  • But the pushed request object as described so far still does not overcome one of the key disadvantages of the “scope-specific URI query parameter” pattern: It requires the authorization server to be aware of application specific relationships between scope values and URI query parameters (e.g. “payment” & “payment”) making a fully generic implementation of this pattern in OAuth products difficult to achieve.

So let’s recap why we landed here: the intent was to come up with solutions to carry rich authorization data in conformance to RFC 6749. And the limitations of the OAuth scope parameter caused the development of solution that split the data across scope values and additional data representations, either in a parameter or as external resource.

What if we approach the problem a bit more disruptive and extend OAuth? Why not just introducing a new kind of scope?

Structured Scope

Let’s call it structured scope. And well, yes, it’s JSON-encoded and may contain multiple objects each of them describing the permissions requested on a certain API or resource.

The following example shows the authorization details for the payment transaction within the new structured_scope element.

You see the scope definition is now self-contained, no need to wire scope values and parameters or external resources any longer because everything needed to parameterize the authorization request is provided in a single object.

The new syntax also allows to carry authorization data for different resources as named objects in a single authorization request as shown in the following example.

This example combines the request to get the confirmation to sign a contract for a mobile subscription along with the approval for a credit transfer to pay the new smartphone.

The AS is supposed to pass the structured_scope object (or the sub objects) to suitable extension modules that are able to render the respective user consent and add the required data to access tokens or token introspection responses.

To me combining pushed request objects and a structured scope looks like the optimal solution to solve the rich authorization challenge in OAuth.

  • It’s generic since new applications must only publish the name of its scope object. The authorization server then needs to know what extension module will process the respective new scope object.
  • It’s developer friendly (for both client and AS developers), secure, and less error prone than the other patterns discussed throughout this article.


In this article, I explained some of the pattern to support rich and transaction authorization with OAuth. All patterns presented are reasonable, but somehow also feel like workarounds to cope with the limitations of standard OAuth scopes.

I therefore propose to extend OAuth to natively supports the new use cases in open banking and electronic signing by introducing both structured scopes and pushed request objects.

What do you think?


I would like to thank Brian Campbell, Daniel Fett, Sebastian Ebling, and Dave Tonge for their feedback and advice.



Learnings, Patterns and Ideas around use of OAuth 2.0

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Torsten Lodderstedt

Torsten is CTO@yes.com, software architect with strong security interest, identity nerd, contributor to OAuth, OpenID, Open Banking & Electronic Signatures