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

Allow anonymous registry access #9887

Merged
merged 2 commits into from
Jul 20, 2016
Merged

Allow anonymous registry access #9887

merged 2 commits into from
Jul 20, 2016

Conversation

liggitt
Copy link
Contributor

@liggitt liggitt commented Jul 15, 2016

Docker registry updates:

  • Allows registry auth to recognize bearer tokens in addition to basic auth
  • Responds to a missing Authorization header with a Bearer challenge, directing to a token handling endpoint
  • Adds a token handling endpoint to the registry image at /openshift/token:
    • Issues an anonymous token (literally "anonymous") to token requests that include no Authorization header
    • Validates a basic auth password sent to a token request as an API token, then echoes it as the granted token

Policy updates:

  • Adds an self-access-reviewer role (name up for grabs)
  • Grants that role to all users (authenticated and unauthenticated) by default

Use:

To allow anonymous users to pull images from a particular project:

oc policy add-role-to-user registry-viewer system:anonymous -n myproject

To allow anonymous users to pull images from all projects:

oadm policy add-cluster-role-to-user registry-viewer system:anonymous

@liggitt
Copy link
Contributor Author

liggitt commented Jul 15, 2016

[test]

@liggitt
Copy link
Contributor Author

liggitt commented Jul 15, 2016

@smarterclayton
Copy link
Contributor

Looks reasonably not crazy

// See https://docs.docker.com/registry/spec/auth/token/#/how-to-authenticate and https://tools.ietf.org/html/rfc6750#section-3
str := fmt.Sprintf("Bearer realm=%q", ac.realm)
if ac.service != "" {
str += fmt.Sprintf("service=%q", ac.service)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like comma is missing before service.

@soltysh
Copy link
Contributor

soltysh commented Jul 19, 2016

LGTM, but I'm wondering if that test failure is a flake or actual problem.

@liggitt
Copy link
Contributor Author

liggitt commented Jul 19, 2016

yeah, I had a different docker client version locally, so the message output was slightly different. updated the test.

@liggitt
Copy link
Contributor Author

liggitt commented Jul 19, 2016

conformance and integration flaked on #8571

@aweiteka
Copy link
Contributor

cc @brianwcook

@aweiteka
Copy link
Contributor

Grants that role to all users (authenticated and unauthenticated) by default

I'm confused why this role is granted to all users by default. I'm assuming all project images must be granted this access. Can you give an example command for how a project admin would enable unauthenticated pulls for their project?

SelfProvisionerRoleName = "self-provisioner"
BasicUserRoleName = "basic-user"
StatusCheckerRoleName = "cluster-status"
SelfAccessReviewerRoleName = "self-access-reviewer"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just self-access-viewer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because all the APIs that check access are *Review (SubjectAccessReview, etc)

@liggitt
Copy link
Contributor Author

liggitt commented Jul 19, 2016

I'm confused why this role is granted to all users by default

The self-access-reviewer role simply allows users to ask the API "can I do X?". It does not grant access to images.

Registry authorization works by asking the API (as the user doing the push/pull) "can I get imagestreams/layers in namespace foo?" or "can I update imagestreams/layers in namespace foo?". For anonymous pulls/pushes to work, anonymous users must be able to check anonymous access to a particular action.

I'm assuming all project images must be granted this access. Can you give an example command for how a project admin would enable unauthenticated pulls for their project?

For a particular project:

oc policy add-role-to-user registry-viewer system:anonymous -n myproject

For all projects:

oadm policy add-cluster-role-to-user registry-viewer system:anonymous

@liggitt
Copy link
Contributor Author

liggitt commented Jul 19, 2016

flaked six ways from Sunday, but passed all the e2e tests related to anonymous pulling/pushing. [merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jul 20, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6529/) (Image: devenv-rhel7_4627)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to d179662

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to d179662

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6530/)

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

Successfully merging this pull request may close these issues.

8 participants