Re: [OAUTH-WG] Recommendations for OAuth 2.0 with Browser-Based Apps

Emond Papegaaij <emond.papegaaij@gmail.com> Wed, 08 May 2019 07:38 UTC

Return-Path: <emond.papegaaij@gmail.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B46E912008B for <oauth@ietfa.amsl.com>; Wed, 8 May 2019 00:38:08 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
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 ak1p-BepClla for <oauth@ietfa.amsl.com>; Wed, 8 May 2019 00:38:06 -0700 (PDT)
Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 849F312002F for <oauth@ietf.org>; Wed, 8 May 2019 00:38:06 -0700 (PDT)
Received: by mail-ed1-x533.google.com with SMTP id e56so21112113ede.7 for <oauth@ietf.org>; Wed, 08 May 2019 00:38:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=iGAXywihdZzc0vXYOyg28Wv6y1u3QQEhQYv2FP4EaAs=; b=XnuPlI1ElYrY+Hhu+OeiY8YF798Bm596d5LF77/XeSpFBscgpXeHbz6kQNA2HyzIlE +5/4AV0p+hbMhMQSJC43gSA5/vGRlWADXJqyXqvQ+4IBD/5EmYm4+br/yfLbiyFEoBMf h8kGXKErBWAkKswQiGoBiPGZULsz7v4uE1trXeyVocl4vTZpN/gAEkoIPMi+E6ybYdco ibEdsBQaSQVDbSKrvri77VhLLQWOHgDp1Gjj7+D4BeB3UzuhPYs+hHP/4c0MAm8/ZbP4 AlERjXhE+LxfzZRepGd66oY0e1T/7tMqjAPkhQIFKpVkh+y1nQLTAgTCQa3+koTfhMKm 9dsQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iGAXywihdZzc0vXYOyg28Wv6y1u3QQEhQYv2FP4EaAs=; b=XWlqq3K2g3Z1JPgRNK7+oimqnAkU2Bq3KyatjKUbn1MiGMnN8qec2ES6JIjrIEdHwK yv6z3M5Tu1LivOoia9lbRAH5VxzxDEg9QUKfmfg5c2iKdUyPKihsfL6rG365IPbSlW2C pWLbb4Ozuv5HaLqVFE3N3D1SadUbDicQKG41vzuPyPjxicyzgTBxlkZQacmCrXRxan95 9oYbrer5mm7CZ5xZ3758v52K35ggderAWAylYjqS5hZwTKzG4GNH8B+v4xjfaShpBzOt ECn6Ky1kaa5R5Ba7qiiJn59mIyCsPUG/hu2UYx04z4ijFpfQnxzmtIT1mkpHWjT5ep4q tKSw==
X-Gm-Message-State: APjAAAUHT08ySdztF2a6swmV6YIbsfmYBpVT6zIbjL2OeZcd5ISjCpzR FnKg5aOjc5VMWI5hTLaD4hAttxMtxb4=
X-Google-Smtp-Source: APXvYqz8owo+IYcVy2EO6sYM8b9LMnnHrKdgQpphw5Qyok7O7+iNc6mKtZC5ZfIrflVBEelHjaMKtg==
X-Received: by 2002:a17:906:6410:: with SMTP id d16mr28322349ejm.75.1557301084578; Wed, 08 May 2019 00:38:04 -0700 (PDT)
Received: from papegaaij.localnet ([195.35.227.200]) by smtp.gmail.com with ESMTPSA id o15sm4913645edj.44.2019.05.08.00.38.03 for <oauth@ietf.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 May 2019 00:38:03 -0700 (PDT)
From: Emond Papegaaij <emond.papegaaij@gmail.com>
To: oauth@ietf.org
Date: Wed, 08 May 2019 09:37:56 +0200
Message-ID: <2125064.3GpWMRz4CO@papegaaij>
In-Reply-To: <C0E40840-26FE-4BC9-8D13-B06D399E4A52@alkaline-solutions.com>
References: <11125817.AKI43N3Yza@papegaaij> <C0E40840-26FE-4BC9-8D13-B06D399E4A52@alkaline-solutions.com>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/hFlr_aYo6lXOgT2oNXtBs4KoHVM>
Subject: Re: [OAUTH-WG] Recommendations for OAuth 2.0 with Browser-Based Apps
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.29
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: Wed, 08 May 2019 07:38:09 -0000

Hi,

Thanks for your detailed reply. I've replied inline.

On maandag 6 mei 2019 22:42:09 CEST David Waite wrote:
> On May 6, 2019, at 1:42 PM, Emond Papegaaij <emond.papegaaij@gmail.com> 
wrote:
> > For a browser-based app, we try to follow the recommendations set in
> > draft-
> > ietf-oauth-browser-based-apps-01. This does allow us to create a secure
> > OAuth 2.0 browser-based application, but at the moment it comes at a cost
> > wrt. user experience when the access token expires. Our current solution
> > forces us to redirect the user to the authorization server for a new
> > authorization code. This will destroy most state the browser-based app
> > has, causing the user to loose data. We are looking for a way to get a
> > new access token in a secure way without disrupting the user.
> > As a refresh token is not issued to the app (as it should be), the
> > application is forced to do a front-channel re-authentication for an
> > authorization code. We are thinking of letting this front-channel
> > communication happen in a hidden iframe. Naturally, this can only be done
> > if no user interaction is required, hence we want to use the OIDC
> > prompt=none. Is this a viable way of doing this re-authentication? Can it
> > hurt to open up our authorization server for non- interactive
> > authorization requests inside an iframe? At the moment we do not allow
> > iframes at all.
> 
> Some AS implementations will block authentication in an iframe, but will
> allow you to use the OIDC prompt=none. This is already used quite often
> today by implicit apps. It is possible that AS implementations may allow
> iframes in the future, by detecting the frame is not covered with any
> buttons, and having the authentication be based on phishing-resistant
> authentication methods like W3C Web Authentication.

Fortunately for us, we build the AS as well, so we are in control here. It is 
a bit unfortunate that this does depend on OIDC. Doing user interaction in an 
iframe seems like a snake pit I'd rather not go into. I think it's also bad 
wrt the user interaction. We do not want user to enter their credentials on 
any site that looks like our AS. Users should only enter their credentials 
when the URL matches or AS.

> You could also trigger re-authorization with a user click, thus allowing
> opening the AS in a new window or tab. Once back on the site via callback,
> the temporary/pop-up window can do things like exchange the code for an
> access token, persist it, postMessage the original window, do window.close,
> etc.

This would work, but would really be a nuisance to the user. Especially with a 
token timeout of just one hour. Also, most of the times there would be no 
interaction, the user would just have to click a button. As a user I wouldn't 
understand why I have to do that all the time.

> On the other hand, refresh tokens IMHO are given quite a bit more fear in
> browser apps than warranted. It really depends on the AS - whether it can
> tie refresh tokens to the user’s authentication, or if they are tied to a
> long-term / persisted / "offline” authorization independent of an active
> user authentication. Currently, the latter is more common in
> implementations, and doesn’t make sense for browser applications. This
> doesn’t mean refresh tokens are automatically discounted for all
> environments.

How would you tie a refresh token to a user session on the AS? This would 
depend on the user visiting the AS on a regular basis and using a logout 
button when done. Most people simply close their browser when they're done, 
leaving the session open. Also, when making a call to the token endpoint to 
refresh the access token, there is no way of knowing that this call is 
actually initiated by the user, because it's done on a back channel. Perhaps 
this can be solved with DPOP with a keypair per browser, but this would really 
complicate the whole solution.

> Given the choice between an 8 hour access token, or a 10 minute access token
> and a refresh token that will expire at a maximum of 8 hours, the second
> provides quite a few more options to be more secure. (eg. checking backing
> user session and revocation, checking for updates to client blacklist, the
> rotation of the access token, rotating refresh tokens to prevent use by
> more than one client, expiring access on inactivity based on lag in
> refreshing, and so on).

I agree with you on this, but the spec currently states clearly that the AS 
should not issue refresh tokens to an SPA. Do you think this should be changed 
to something like: Authorization servers SHOULD NOT issue *offline* refresh 
tokens to browser-based applications. A refresh token should be tied to a user 
session on the AS.

> If the refresh token is tied to the AS concept of user session, then it
> mostly replaces the ‘hidden iframe’ use above - you’ll only have your
> refresh token expire when the AS is asking for user presence on the front
> channel, presumably for interaction. Although, I suppose in some
> environments there could be a non-interactive reauthentication/factor as
> well (such as kerberos, MTLS, or re-verifying user location via geoip)
> where a hidden iframe might still provide UX benefit.

In our case or AS might have to federate the authentication to some other AS, 
that would only work in an iframe. Therefore, I think we will go for the OIDC 
prompt=none in a hidden iframe. I'm not sure what to do if the AS reports that 
interaction is required, but at least the majority of the cases will be 
covered.

Best regards,
Emond Papegaaij