Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bearer response should also allow for access_token #229

Open
Deshke opened this issue Nov 3, 2020 · 1 comment
Open

bearer response should also allow for access_token #229

Deshke opened this issue Nov 3, 2020 · 1 comment

Comments

@Deshke
Copy link

Deshke commented Nov 3, 2020

via https://docs.docker.com/registry/spec/auth/token/#requesting-a-token

token: An opaque Bearer token that clients should supply to subsequent requests in the Authorization header.

access_token: For compatibility with OAuth 2.0, we will also accept token under the name access_token. At least one of these fields must be specified, but both may also appear (for compatibility with older clients). When both are specified, they should be equivalent; if they differ the client's choice is undefined.

diff --git a/api/v1/registry/client/auth/bearer/bearer.go b/api/v1/registry/client/auth/bearer/bearer.go
index 3a99170..fc1ea5b 100644
--- a/api/v1/registry/client/auth/bearer/bearer.go
+++ b/api/v1/registry/client/auth/bearer/bearer.go
@@ -9,7 +9,8 @@ import (
 
 // Token implementation for Bearer authentication
 type Token struct {
-       T string `json:"token"`
+       T string `json:"token,omitempty"`
+       A string `json:"access_token,omitempty"`
        E int    `json:"expires_in"`
 }
 
@@ -20,7 +21,10 @@ func (tk Token) Method() string {
 
 // String form of Bearer token
 func (tk Token) String() string {
-       return tk.T
+       if tk.A == "" {
+               return tk.T
+       }
+       return tk.A
 }

bit dirty but it does the trick @ivanilves

@ivanilves
Copy link
Owner

Hey @Deshke thanks for pointing this out! 🤝

You may either:

  • open a PR yourself (you are very welcome to open PRs here!)
  • ... or wait until I get my time slice to do it (eventually I always do, so don't worry anyway!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants