Re: [OAUTH-WG] Securing APIs with OAuth 2.0

Justin Richer <> Tue, 06 March 2012 16:39 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id C31F321F8609 for <>; Tue, 6 Mar 2012 08:39:50 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -6.582
X-Spam-Status: No, score=-6.582 tagged_above=-999 required=5 tests=[AWL=0.017, BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id 34ntJCsFIXt6 for <>; Tue, 6 Mar 2012 08:39:50 -0800 (PST)
Received: from ( []) by (Postfix) with ESMTP id 885D221F85AD for <>; Tue, 6 Mar 2012 08:39:48 -0800 (PST)
Received: from (localhost.localdomain []) by localhost (Postfix) with SMTP id 2AEEA21B0464; Tue, 6 Mar 2012 11:39:48 -0500 (EST)
Received: from IMCCAS03.MITRE.ORG ( []) by (Postfix) with ESMTP id 1A28C21B0BD9; Tue, 6 Mar 2012 11:39:48 -0500 (EST)
Received: from [] ( by IMCCAS03.MITRE.ORG ( with Microsoft SMTP Server (TLS) id 14.1.339.1; Tue, 6 Mar 2012 11:39:47 -0500
Message-ID: <>
Date: Tue, 6 Mar 2012 11:38:15 -0500
From: Justin Richer <>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version: 1.0
To: Sergey Beryozkin <>
References: <> <> <> <> <> <>
In-Reply-To: <>
Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding: 7bit
X-Originating-IP: []
Subject: Re: [OAUTH-WG] Securing APIs with OAuth 2.0
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: OAUTH WG <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 06 Mar 2012 16:39:51 -0000

> OK.
> Thanks for the explanations so far. It's very helpful.
> I'm prototyping the framework support for OAuth 2.0 and at this stage
> I'm trying to figure out what exactly the runtime itself can do and what
> has to be delegated to the custom code and thus how to design the api
> the runtime and the custom code will use to communicate with each other.

Makes sense. It's often hard to figure out exactly where to draw the 
lines of abstraction for fundamental libraries like this.

> Let me ask one more question, sorry if it's a silly one :-)
> So suppose a given client has been pre-authorized by the end user.
> Next, the client can get the pre-authorized token via the authorization
> code flow or the implicit code flow (ignoring the client_credentials one
> for the moment).
> Does it make sense to restrict which flow a given pre-authorized token
> can 'work' with ? Example, enforce that the pre-authorized token can
> only be issued to the clients initiating an authorization code flow but
> not to those trying an implicit one, or vice versa ?
> The reason I ask is that I'm thinking that the entity representing an
> access token should have a property indicating which grant type was used
> for this token being created in the first place. So if such a token
> were to represent the user pre-authorizing the client
> and then eventually given to a client via the authorization code or
> implicit code flow, then this token would actually need to
> be cloned each time for a specific grant type property be set, and
> this does not look optimal...

Several implementations that I've seen do restrict the flows that a 
given client is allowed to do. Any time you have a privileged client, 
such as one that's been auto-approved, it makes even more sense to lock 
it down in other avenues. You don't have to encode it into the token or 
code, but of course if you have a structured token format you may do 
that. Note that with the code flow, you probably don't actually generate 
the token until the client shows up with a valid code and client 
id/secret, but that's really a runtime optimization that's going to be 
specific for your setup.

All you really need is a flag at your AS that ties the given client id 
to a set of allowable grant types. When the client shows up at the AS 
endpoints, you look up this flag based on the client ID and verify that 
the flow you're doing matches up with what's allowed by configuration.

  -- Justin