Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Support auth protocol introduced by docker 1.8 #282

Merged
merged 3 commits into from
Sep 2, 2015
Merged

Support auth protocol introduced by docker 1.8 #282

merged 3 commits into from
Sep 2, 2015

Conversation

flavio
Copy link
Member

@flavio flavio commented Aug 20, 2015

NOTE WELL: This is some preliminary work to fix issue #276. I'm about to leave for my vacation. @mssola please take a look at the code and vet it. I can fix the broken tests once I'm back on the 1st of September (unless you really want to take care of that once you are back from your vacation).

The issue

The authorization protocol changed with Docker 1.8:

  • client does pull or push or whatever
  • daemon does ping to registry i.e. https://registry.ip/v2/
  • registry returns 401 along with realm and service, but not scope
  • daemon asks for a token from the auth server, with
    service=&scope=repository:namespace/image:push,pull

In other words, the daemon always asks for push,pull, even if you are
just doing a pull. The auth server is supposed to respond in the
following fashion:

  • If unauthenticated access is not allowed, return a 401 requiring
    user to authentictae
  • If unauthenticated access is allowed to that repo, return a web
    token

When user tries the token path against the auth server with credentials:

  • If invalid credentials, return 401
  • If valid credentials, always return a 200 with a JWT that has the
    maximum credentials allowed this user on this repository in this service
    that is a subset of the scope provided.

The daemon will always ask for push,pull, and - as long as I am validly
authenticated - the auth server should always return 200 with a valid
Web token. The Web token will list the max I am allowed.

  • If I am not allowed push or pull, then return a token with no access
  • If I am allowed pull but not push, then return a token with pull
    access only
  • If I am allowed pull and push, then return a token with push and
    pull access

The authorization protocol changed with Docker 1.8:
  * client does pull or push or whatever
  * daemon does ping to registry i.e. https://registry.ip/v2/
  * registry returns 401 along with realm and service, but not scope
  * daemon asks for a token from the auth server, with
    service=<registry>&scope=repository:namespace/image:push,pull

In other words, the daemon always asks for push,pull, even if you are
just doing a pull. The auth server is supposed to respond in the
following fashion:

  * If unauthenticated access is not allowed, return a 401 requiring
user to authentictae
  * If unauthenticated access is allowed to that repo, return a web
token

When user tries the token path against the auth server with credentials:

  * If invalid credentials, return 401
  * If valid credentials, always return a 200 with a JWT that has the
    maximum credentials allowed this user on this repository in this service
    that is a subset of the scope provided.

The daemon will always ask for push,pull, and - as long as I am validly
authenticated - the auth server should always return 200 with a valid
Web token. The Web token will list the max I am allowed.

  * If I am not allowed push or pull, then return a token with no access
  * If I am allowed pull but not push, then return a token with pull
    access only
  * If I am allowed pull and push, then return a token with push and
    pull access

This is some preliminary work to fix issue 276.
…d users

The commit 05eb390 introduces a regression in
which a logged in user can pull a repo from a private namespace that doesn't
belong to it.

The problem is that the delete_if method is screwing with the `each` iteration.
To avoid this, the returned scopes from `scope_handler` is a duplicate, instead
of being the same object.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
@mssola
Copy link
Collaborator

mssola commented Aug 27, 2015

Ok, I've pushed a fix for a regression in the first commit. With this, Portus should be able to handle the changes from docker 1.8. I haven't added more tests for it, I'll do it later today.

@mssola
Copy link
Collaborator

mssola commented Aug 27, 2015

And this should be it. Rubocop is not passing because I pushed yesterday some stricter rules for the style. We can merge this anyways and I'll fix the style on master directly.

LGTM. @flavio what do you think ?

Moreover, I've also added more documentation in the `authorize_scopes` method.
Finally, the `authorize_scopes` method will raise a `Pundit::NoAuthorizedError`
exception if no scopes can be authorized for the current user.

I've also updated the changelog file.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
@flavio
Copy link
Member Author

flavio commented Sep 2, 2015

Thanks @mssola !

flavio added a commit that referenced this pull request Sep 2, 2015
Support auth protocol introduced by docker 1.8
@flavio flavio merged commit ea4751e into master Sep 2, 2015
@flavio flavio deleted the issue-276 branch September 2, 2015 13:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants