Re: [OAUTH-WG] Is it allow to add custom attribute to access token response?

John Bradley <ve7jtb@ve7jtb.com> Sun, 23 August 2015 18:37 UTC

Return-Path: <ve7jtb@ve7jtb.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C9BF31B2A16 for <oauth@ietfa.amsl.com>; Sun, 23 Aug 2015 11:37:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.6
X-Spam-Level:
X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O3U7UhqaQmM9 for <oauth@ietfa.amsl.com>; Sun, 23 Aug 2015 11:37:41 -0700 (PDT)
Received: from mail-qk0-f172.google.com (mail-qk0-f172.google.com [209.85.220.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 93F151B2A1A for <oauth@ietf.org>; Sun, 23 Aug 2015 11:37:41 -0700 (PDT)
Received: by qkda128 with SMTP id a128so7116036qkd.3 for <oauth@ietf.org>; Sun, 23 Aug 2015 11:37:40 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=AM99JafP2M5MdTOfPV7Ma4T8qva9/OEm8Tysp7Jx+Jk=; b=hd+43j0abCN2DGckybaizAz/obpidQIItXXLeGTV1epQprowie+MwkFLfP7/fbnOpn ciQ6rbrk/qWggOoAXsn7n9w83dLaxvJ4t1ZOjfhDh+00TZaugPqUJ91UeNqA33QWJTqD LtEojPhBpL44MHV0NECKUa7iuw5EBp+PMIVhsDKNEZpT9caBAPpvqqVyXj4JfH59ZjxO riuts7F4jv98kNUR1r4ozM6lcJj8pzZsxgGX8Uild9a1mHSXUghxs2iuRmZGdHO7s+f5 cf1t1ORc3fzDgHmJ8uA5wcKUBbN4KMzRR9Jx+gL5CF/RIzWNXspLO2bBJK0AZ/haRpnu mKJQ==
X-Gm-Message-State: ALoCoQmT3DmeFXNtBDtC0b2jhRA54silZrAaX1PKT7mN5zOUUpb/NteiBrQltaReiefsswGaPt1d
X-Received: by 10.55.195.198 with SMTP id r67mr8760782qkl.30.1440355060632; Sun, 23 Aug 2015 11:37:40 -0700 (PDT)
Received: from [192.168.8.100] ([181.202.150.98]) by smtp.gmail.com with ESMTPSA id k32sm7354930qkh.39.2015.08.23.11.37.38 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 23 Aug 2015 11:37:39 -0700 (PDT)
Content-Type: multipart/signed; boundary="Apple-Mail=_944E46BF-9E16-41A7-B3A8-6A5B2A3BED54"; protocol="application/pkcs7-signature"; micalg="sha1"
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
From: John Bradley <ve7jtb@ve7jtb.com>
In-Reply-To: <CAMbDefui+rzFNibYfwYto6sGiLLcLaL4GCfd2yVUqGS2BLtMTA@mail.gmail.com>
Date: Sun, 23 Aug 2015 15:37:36 -0300
Message-Id: <F0834D39-B1FE-4FE8-95CD-D87407EE6FC7@ve7jtb.com>
References: <CAMbDefvKeEdxTfj7CkoTbUwhdOYxMN+bvH3w6Vk81tMuKYTWPQ@mail.gmail.com> <0EF80C0D-55C2-4F1F-B741-87EDE63D3FD5@ve7jtb.com> <CAAP42hBa71xpCX9Zwm6bdfMYSur4JxGvLtd3q-9xLtQfLWO09A@mail.gmail.com> <CAMbDefui+rzFNibYfwYto6sGiLLcLaL4GCfd2yVUqGS2BLtMTA@mail.gmail.com>
To: Donghwan Kim <flowersinthesand@gmail.com>
X-Mailer: Apple Mail (2.2104)
Archived-At: <http://mailarchive.ietf.org/arch/msg/oauth/W5sCUJWNBNSEgYvJidkXch1Wgro>
Cc: "oauth@ietf.org" <oauth@ietf.org>
Subject: Re: [OAUTH-WG] Is it allow to add custom attribute to access token response?
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/oauth>, <mailto:oauth-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/oauth/>
List-Post: <mailto:oauth@ietf.org>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 23 Aug 2015 18:37:45 -0000

OIDC returns a signed JWT/id_token from the token endpoint that can contain all of that information (no extra round trips).   Setting a id_token as a cookie is not unusual.   I would not conflate the access token with session tokens.

John B.

> On Aug 23, 2015, at 3:32 PM, Donghwan Kim <flowersinthesand@gmail.com> wrote:
> 
> Hi folks,
> 
> First off, I appreciate your answers.
> 
> What I try to do with OAuth is to design a set of APIs which allow to write application without server in a standard-compliant way and I chose OAuth for the social web. Because the current API I work on uses a kind of Form-based authentication (https://en.wikipedia.org/wiki/Form-based_authentication <https://en.wikipedia.org/wiki/Form-based_authentication>), I started with Resource Owner Password Credentials first to support other grant types gracefully later. Here I faced the problem with authentication. (Now I realized that I may have abused OAuth according to your answers)
> 
> My thought is to use access_token as a session token containing values like roles not just a reference on server's memory indicating such values (traditional cookie). That means access_token should be a JSON Web Token (JWT) which contains usename (to log who did an action), roles (ACL, to determine this request has a proper permission), and so on. Then every server (or microservice unit) accepting request doesn't need to have not only session states in its memory (stateless), but also a dependency with auth server because access_token included in Authorization request header as bearer token contains all about authentication and authorization information. Having said that, because token would be not valid over time if values contained in the token might be changed e.g. role or due to OAuth's expiration mechanism, removing dependency with auth server is unlikely to be feasible practically IMO. (Then it would be better for access_token to be reference rather than a set of values)
> 
> As for the original question, as Bill pointed, it's okay to get user information by username through other separate endpoint for that purpose (like /userinfo from the context of OpenID Connect (OIDC)). Though, I wanted to reduce round-trip by adding a custom property to token endpoint's response.
> 
> Here's some questions:
> 
> 1. Is it an abuse of OAuth to use access_token as a session token which is a set of values not reference on server indicating values? or what if it is in the form of reference? As far as I read https://tools.ietf.org/html/rfc6749 <https://tools.ietf.org/html/rfc6749>, I didn't feel that access_token should not be like that. On the contrary, if I introduce another standard for authentication, API implementators should do more work and I didn't want to do that. In this case, support for OIDC can be regarded as enhancement of API like Google did https://developers.google.com/+/web/api/rest/openidconnect/ <https://developers.google.com/+/web/api/rest/openidconnect/>
> 
> If not or it doesn't sound that good, I'll take a look https://tools.ietf.org/html/draft-ietf-oauth-introspection-11 <https://tools.ietf.org/html/draft-ietf-oauth-introspection-11> and http://openid.net/specs/openid-connect-core-1_0.html <http://openid.net/specs/openid-connect-core-1_0.html> which you suggested. (Though I'm not comfortable that OIDC is also regarded abuse of OAuth according to http://security.stackexchange.com/a/44614 <http://security.stackexchange.com/a/44614>)
> 
> Thanks!
> 
> -- Donghwan
> 
> On Sat, Aug 22, 2015 at 1:42 AM, William Denniss <wdenniss@google.com <mailto:wdenniss@google.com>> wrote:
> As for your specific use-case though, as John said it's better to use OpenID Connect which provides a solution for what you are trying to do already.
> 
> That way you get an interoperable solution, and one that has been vetted by security experts. There is even a free test suite <http://openid.net/certification/testing/> for you to test your implementation.
> 
> On Fri, Aug 21, 2015 at 9:35 AM, John Bradley <ve7jtb@ve7jtb.com <mailto:ve7jtb@ve7jtb.com>> wrote:
> Requests to the token endpoint are URL form encoded not JSON in your example.
> 
> The use of the password credentials grant was to allow migration from HTTP basic, but it not recommended for privacy and security reasons.
> 
> OpenID Connect is a better way to authenticate users.
> 
> However assuming you have a closed system and don’t care about interoperability between clients and the Token endpoint, you could just add that parameter to your AS and the world will not end.
> 
> If you want to have interoperable clients then you should register the new element in the IANA registry Sec 11.2 of the spec.
> 
> Parameter name:
>       The name requested (e.g., “username").
> 
>    Parameter usage location:
>       token response.
> 
>    Change controller:
>       For Standards Track RFCs, state "IETF".  For others, give the name
>       of the responsible party.  Other details (e.g., postal address,
>       email address, home page URI) may also be included.
> You need to have a specification to do that.
> 
> I don’t see this as a good idea, but that is how you would do it.
> 
> Regards
> John B.
> 
> 
>> On Aug 20, 2015, at 11:15 AM, Donghwan Kim <flowersinthesand@gmail.com <mailto:flowersinthesand@gmail.com>> wrote:
>> 
>> Hi,
>> 
>> I would like to add a custom property representing the account who just authenticated to the access token response for the sake of convenience like login request's response. Then, an exchange of request and response will look like this:
>> 
>> POST /tokens HTTP/1.1
>> Host: api.example.com <http://api.example.com/>
>> Content-Type: application/json
>> 
>> {"grant_type":"password","username":"${username}","password":"${password}"}
>> 
>> HTTP/1.1 200 OK
>> Content-Type: application/json
>> Cache-Control: no-store
>> Pragma: no-cache
>> 
>> {
>>   "access_token":"${JSON web token}",
>>   "token_type":"Bearer",
>>   "account": {"username":"donghwan", ...}
>> }
>> 
>> However http://tools.ietf.org/html/rfc6749#section-5.1 <http://tools.ietf.org/html/rfc6749#section-5.1> says that
>> 
>> > The client MUST ignore unrecognized value names in the response.
>> 
>> Does it mean that I shouldn't add such property, 'account'? Though, I saw Instagram API adds such custom property to access token response for the same purpose from https://instagram.com/developer/authentication/ <https://instagram.com/developer/authentication/> (Please find 'snoopdogg' to see that token response.) If it's not allowed or desirable, how should I add such information to the access token response?
>> 
>> BTW, I have some questions on usage of JSON web token with OAuth. Can I post them here? If not, where should I do that?
>> 
>> Thanks,
>> 
>> -- Donghawn
>> _______________________________________________
>> OAuth mailing list
>> OAuth@ietf.org <mailto:OAuth@ietf.org>
>> https://www.ietf.org/mailman/listinfo/oauth <https://www.ietf.org/mailman/listinfo/oauth>
> 
> 
> _______________________________________________
> OAuth mailing list
> OAuth@ietf.org <mailto:OAuth@ietf.org>
> https://www.ietf.org/mailman/listinfo/oauth <https://www.ietf.org/mailman/listinfo/oauth>
> 
> 
>