Re: [OAUTH-WG] Token Mediating and session Information Backend For Frontend (TMI BFF)

Vittorio Bertocci <vittorio.bertocci@auth0.com> Sun, 14 February 2021 11:07 UTC

Return-Path: <vittorio.bertocci@auth0.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 059FD3A0BF7 for <oauth@ietfa.amsl.com>; Sun, 14 Feb 2021 03:07:31 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.198
X-Spam-Level:
X-Spam-Status: No, score=-0.198 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=auth0.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 YygIvC16Zch4 for <oauth@ietfa.amsl.com>; Sun, 14 Feb 2021 03:07:28 -0800 (PST)
Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 9538C3A0BF6 for <oauth@ietf.org>; Sun, 14 Feb 2021 03:07:28 -0800 (PST)
Received: by mail-pl1-x635.google.com with SMTP id r2so2141349plr.10 for <oauth@ietf.org>; Sun, 14 Feb 2021 03:07:28 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=auth0.com; s=google; h=from:to:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:accept-language:content-language :mime-version; bh=Gcp+Dg0dos2CHqWDsQMUQsj+7wHg+LEpBlOCqITm8sM=; b=Ly3c33DFK8MWOqSIqe7QvQY0VCyaLyT9mMlbWGph8BMoxUOIkgd2hl2gD98pmCu3LD oXV84OCOQQmlBwkm4KWPv9npR6OVzAEgKxMJ2ac8Atr7ld3zwVOe5HjgcyhUdHrtOLrW UtC5VUFDn9Teu9WVOQj9JqAifF6kYrNxjL61JPpXRjq4Bu79PE/sgowAn+WKvzloJgw4 5aknw1uNrRUBI8tVQo3v3cLEbgaYeeP8f1DtLyRkEPKH9nyqSO+kA7u3EDxCR8/VYLO5 mOAgpxfuqtPe/j6uy1peONlo6MvzjqGmU5CpBFJrqR1BaEoQ8+96WzJa+O7LcOxSRrkc PvEw==
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:thread-topic:thread-index:date :message-id:references:in-reply-to:accept-language:content-language :mime-version; bh=Gcp+Dg0dos2CHqWDsQMUQsj+7wHg+LEpBlOCqITm8sM=; b=S4PjOjRgPNGTBwg/QYY5EA99dWP5NP3OZgDyDX7iIc2YM1LspQPLJ8kBRyM19sVvpy Jc6i11iIks+sAigBSrmPxM/4Ln34JG3H9X9bwwzGouw92TyhWbN26SDuCGhuwnzTQLQy 3yZrPi1fA8/71OnvpWF3UWE0s8NYOT7ZDQt4xnX8xaQHshjiMA0rMKBA/4h8i1pCyRht /Mj7t8M8AIh4xUVRZ0f7xnFOmvUEqYOnoSwgdzf5hKbhoFzI0NrrybXOVEIDqE+MK0OY E01eoYSJCfFCsV/o4jKsI78r9hV0l+FJ+aojDK5+uElFyAfJiqM76SWJupYioRZ6fBPu k5Fw==
X-Gm-Message-State: AOAM532oSoqu90u5JaBcQ4Gus7DvPNndOdEMg4NokZytUvfzL0QebC2i N79gecEMqYTMwcFlua1SbgtOrA==
X-Google-Smtp-Source: ABdhPJyEUk+qlAPp6Q6VjVVQeIEZNutv++iQvhULTOhWrqtReXbRXEVUj17VPe5YVtgvBE6WM1HbaQ==
X-Received: by 2002:a17:902:e211:b029:e2:843c:426e with SMTP id u17-20020a170902e211b02900e2843c426emr10579633plb.16.1613300847719; Sun, 14 Feb 2021 03:07:27 -0800 (PST)
Received: from CO6PR18MB4052.namprd18.prod.outlook.com ([2603:1036:301:402a::5]) by smtp.gmail.com with ESMTPSA id k69sm14755849pfd.4.2021.02.14.03.07.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Feb 2021 03:07:27 -0800 (PST)
From: Vittorio Bertocci <vittorio.bertocci@auth0.com>
To: Stoycho Sleptsov <stoycho.sleptsov@gmail.com>, "oauth@ietf.org" <oauth@ietf.org>
Thread-Topic: [OAUTH-WG] Token Mediating and session Information Backend For Frontend (TMI BFF)
Thread-Index: AQHXAYASMR57RiKGBkS9HwYUcalSA6pXAvsAgAB9K7Y=
X-MS-Exchange-MessageSentRepresentingType: 1
Date: Sun, 14 Feb 2021 11:07:26 +0000
Message-ID: <CO6PR18MB40526B1D2AAA259B11BF8C78AE899@CO6PR18MB4052.namprd18.prod.outlook.com>
References: <CO6PR18MB4052805653BFECD35E8A0E66AE8B9@CO6PR18MB4052.namprd18.prod.outlook.com> <CAGL0X-r93p=mTmQE+Q4j23_Ydu1AS7mHsd614Q0dpOPL7nJ4=A@mail.gmail.com>
In-Reply-To: <CAGL0X-r93p=mTmQE+Q4j23_Ydu1AS7mHsd614Q0dpOPL7nJ4=A@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
X-MS-Exchange-Organization-RecordReviewCfmType: 0
Content-Type: multipart/alternative; boundary="_000_CO6PR18MB40526B1D2AAA259B11BF8C78AE899CO6PR18MB4052namp_"
MIME-Version: 1.0
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/ANCkiFiOZrudfv4GKcjjFQWD97A>
Subject: Re: [OAUTH-WG] Token Mediating and session Information Backend For Frontend (TMI BFF)
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: Sun, 14 Feb 2021 11:07:31 -0000

Thanks Stoycho for your comment!
The TMI-BFF assumes that the interactive part of the flow (code grant for giving consent and getting access+refresh tokens, and anything necessary for establishing the session) occurs beforehand. It is not described in the spec itself, but it is expected that such flow (or extension grant with the same characteristics) happened.
HTH!
V.

From: OAuth <oauth-bounces@ietf.org> on behalf of Stoycho Sleptsov <stoycho.sleptsov@gmail.com>
Date: Saturday, February 13, 2021 at 19:39
To: "oauth@ietf.org" <oauth@ietf.org>
Subject: Re: [OAUTH-WG] Token Mediating and session Information Backend For Frontend (TMI BFF)

Hello Mr. Bertocci,

I am a novice yet at APIs and OAuth, but nevertheless am entrusted by the executives of our organisation to expose some of the capabilities of our system through APIs. For that I have set out to implement an OAuth server (based on the 2.1 draft), which is basically functional now, and the corresponding APIs (resource servers). Our team will also have to implement some initial frontend applications which will
consume those exposed resources. I was exactly at the point of considering how to organise the correspondence of the access token from the auth server to the frontend and from the frontend to the
resource servers, when I received as a very nice surprise the news about tmi-bff draft. It was such a relief, as the option to delegate access token acquisition to a backend component, while still accessing resource servers directly from the frontend, seemed most suitable and
well balanced for our case.

I have read the draft with great pleasure, but one thing concerns me in it.

In the description of the protocol flow (1.2), in the step of token request from backend to AS (step B), it mentions that the AS should "issue the requested token without requiring user interaction". Same
thing is reconfirmed in section 4, step 4: "the backend verifies whether it has the necessary artifacts to request it to the
authorization server without requiring user interaction".

But an initial interaction between the resource owner and the authorization server is required by the authorization code flow (section 1.3.1 of the draft-ietf-oauth-v2-1-01).

So where does this interaction fit in the tmi-bff protocol flow? Or tmi-bff is not supposed to be used with authorization code flow?

Thank you for your time,
hoping to hear from you,
Stoycho.

На пт, 12 фев 2021 г., 22:46 Vittorio Bertocci <vittorio.bertocci=40auth0.com@dmarc.ietf.org<mailto:40auth0.com@dmarc.ietf.org>> написа:
Dear all,
Brian and yours truly are proposing a new specification that shows how the user agent frontend of a web app can delegate token acquisition and persistence to its backend, and request such tokens when needed for direct access of protected resources from the frontend code.

The pattern is already in use, in proprietary form, by various modern development stacks, such as Next.JS. Variants of the pattern, often discussed under the catch-all term BFF (backend for frontend), have been often mentioned in this workgroup’s activity, but always left all implementation details to the reader.
We believe the pattern has merit, as corroborated by its growing adoption. By delegating access token acquisition to the backend, we avoid many of the often brittle moving parts (and implied attack surface) required to acquire access tokens from a user agent. The topology also relieves the frontend from the need of persisting tokens in local storage, a well known sore point of using OAuth directly in JavaScript, by relying on its backend storage and session to preserve tokens.

Although the specification is very simple, providing explicit guidance on the scenario offers many advantages.
- It makes it possible to create interoperable SDKs, where frontend dev stacks (any JS flavor) can be mixed and matched with compliant backend stacks (middlewares in node, java, ASP.NET<http://ASP.NET>, PHP etc)
- It allows us to provide guidance on how to properly tackle the scenario and warn implementers against security risks (scope escalations, using IDtokens instead of access tokens, etc)
- It allows us to discuss (and when appropriate, promote) this pattern as part of the browser apps security guidance, and position the scenario where frontend only calls API on its own backed (hence doesn’t need access tokens) simply as a special case of this more general pattern
- This approach makes mocking and testing apps very easy, possibly preventing developers from weakening the security of their system (eg turning on ROPG options)  or turning to risky practices like scraping

Needless to say, this specification doesn’t entirely eliminate the risks inherent to direct use of access tokens from a browser. But reality is that the pattern is in widespread use, and the circumstances leading to that (eg developers on a particular project only work with frontend stacks; components like reverse proxies might not always be viable; etc) aren’t going away any time soon. By providing simple guidance on this pattern, we can simplify the life of many developers while enshrining basic security hygiene in scenarios that would have otherwise be left to their own device.

Looking forward for your feedback!

B&V

On 2/12/21, 12:41, "internet-drafts@ietf.org<mailto:internet-drafts@ietf.org>" <internet-drafts@ietf.org<mailto:internet-drafts@ietf.org>> wrote:


    A new version of I-D, draft-bertocci-oauth2-tmi-bff-00.txt
    has been successfully submitted by Vittorio Bertocci and posted to the
    IETF repository.

    Name:               draft-bertocci-oauth2-tmi-bff
    Revision:   00
    Title:              Token Mediating and session Information Backend For Frontend
    Document date:      2021-02-12
    Group:              Individual Submission
    Pages:              16
    URL:            https://www.ietf.org/archive/id/draft-bertocci-oauth2-tmi-bff-00.txt
    Status:         https://datatracker.ietf.org/doc/draft-bertocci-oauth2-tmi-bff/
    Html:           https://www.ietf.org/archive/id/draft-bertocci-oauth2-tmi-bff-00.html
    Htmlized:       https://tools.ietf.org/html/draft-bertocci-oauth2-tmi-bff-00


    Abstract:
       This document describes how a JavaScript frontend can delegate access
       token acquisition to a backend component.  In so doing, the frontend
       can access resource servers directly without taking on the burden of
       communicating with the authorization server, persisting tokens, and
       performing operations that are fraught with security challenges when
       executed in a user agent, but are safe and well proven when executed
       by a confidential client running on a backend.




    Please note that it may take a couple of minutes from the time of submission
    until the htmlized version and diff are available at tools.ietf.org<http://tools.ietf.org>.

    The IETF Secretariat



_______________________________________________
OAuth mailing list
OAuth@ietf.org<mailto:OAuth@ietf.org>
https://www.ietf.org/mailman/listinfo/oauth