git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] credential: new attribute oauth_refresh_token

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 2, 2023, 16:19 UTC
Message-ID
<6451382f7aacf_1ba2d29490@chronos.notmuch>
In-Reply-To
<20230425064758.GD4061254@coredump.intra.peff.net>
Jeff King wrote:
Show 35 quoted lines
> On Fri, Apr 21, 2023 at 09:47:59AM +0000, M Hickford via GitGitGadget wrote:
> 
> > Git authentication with OAuth access token is supported by every popular
> > Git host including GitHub, GitLab and BitBucket [1][2][3]. Credential
> > helpers Git Credential Manager (GCM) and git-credential-oauth generate
> > OAuth credentials [4][5]. Following RFC 6749, the application prints a
> > link for the user to authorize access in browser. A loopback redirect
> > communicates the response including access token to the application.
> > 
> > For security, RFC 6749 recommends that OAuth response also includes
> > expiry date and refresh token [6]. After expiry, applications can use
> > the refresh token to generate a new access token without user
> > reauthorization in browser. GitLab and BitBucket set the expiry at two
> > hours [2][3]. (GitHub doesn't populate expiry or refresh token.)
> > 
> > However the Git credential protocol has no attribute to store the OAuth
> > refresh token (unrecognised attributes are silently discarded). This
> > means that the user has to regularly reauthorize the helper in browser.
> > On a browserless system, this is particularly intrusive, requiring a
> > second device.
> > 
> > Introduce a new attribute oauth_refresh_token. This is especially
> > useful when a storage helper and a read-only OAuth helper are configured
> > together. Recall that `credential fill` calls each helper until it has a
> > non-expired password.
> > 
> > ```
> > [credential]
> > 	helper = storage  # eg. cache or osxkeychain
> > 	helper = oauth
> > ```
> 
> OK. I don't have much knowledge of OAuth, but taking the notion of "this
> is a useful thing for oauth clients to store" as a given, the
> implementation seems reasonable.

I don't think this is specific to OAuth, I've seen different authorization methods use something like that.

In general you just need two variables: the refresh token, and the expiration time of the refresh token. The logic is very simple: if the refresh token has expired, you ask for a new one. This way you don't have to go through the authorization process again.

-- 
Felipe Contreras
Previous: Jeff King
Message 8 of 8 in “credential: new attribute oauth_refresh_token”
  1. credential: new attribute oauth_refresh_tokenM Hickford via GitGitGadget, Mar 14, 2023
  2. credential: new attribute oauth_refresh_tokenM Hickford via GitGitGadget, Apr 21, 2023
  3. Junio C HamanoApr 21, 2023
  4. M HickfordApr 24, 2023
  5. Jeff KingApr 25, 2023
  6. M HickfordApr 25, 2023
  7. Jeff KingMay 2, 2023
  8. Felipe ContrerasMay 2, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.