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

Added Addon Authn Pattern proposal #29714

Closed
wants to merge 1 commit into from

Conversation

erictune
Copy link
Member

@erictune erictune commented Jul 28, 2016

This change is Reviewable

@k8s-github-robot k8s-github-robot added kind/design Categorizes issue or PR as related to design. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Jul 28, 2016
@erictune erictune force-pushed the addon-auth-pattern branch from 493876d to c2945d6 Compare July 28, 2016 01:02
@erictune
Copy link
Member Author

@kubernetes/sig-auth @bryk

@k8s-github-robot k8s-github-robot added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jul 28, 2016
1. Dashboard is running with service `dashboard` in namespace `kube-system`.
1. User runs `kubectl proxy -p 8001 &`.
- Same as before.
1. User enters this into their browser navigation bar: `http://localhost:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/?add-auth=true#/workload`
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... Cannot kubectl proxy inject the header? E.g., currently when I do kubectl get pods it is equivalent to running curl -k -v -XGET -H "Authorization: Basic <redacted>==" https://<redacted>/api/v1/namespaces/default/pods. What if kubectl injected this auth:basic header to user's requests?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does inject the Authorization header with the user's long-lived, unscoped token. We want Dashboard to see a short-lived, scoped token.

@liggitt
Copy link
Member

liggitt commented Aug 2, 2016

is it unreasonable to require TLS between the API proxy and the pod? if we did that, the proxy could add a header containing user information, and identify itself to the pod using a client certificate (enabled in #26634). Pods could verify the client certificate on the request, then use the user information in the header.

@erictune
Copy link
Member Author

erictune commented Aug 2, 2016

@liggitt

I like the idea of TLS, and I like the idea of the API server presenting a client cert.

The reason I didn't include TLS in this proposal is I didn't know a nice way to generate and distribute a server cert for the "pod", signed by a CA that the apiserver would recognize. And I don't want to solve the general problem of cert distribution this month.

Do you see any way to skirt the issue of distributing a valid TLS cert to the pod-as-a-server?

@erictune
Copy link
Member Author

erictune commented Aug 2, 2016

Okay, I just read #26634. I that PR, the apiserver, as a client, accepts an invalid cert from the pod-as-server. Let me comment on that PR.

@bryk
Copy link
Contributor

bryk commented Aug 8, 2016

is it unreasonable to require TLS between the API proxy and the pod?

Sounds good to me, as long as it is feasible to implement. @erictune What do you think after reviewing the PR #26634?

@apelisse apelisse removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Aug 11, 2016
@erictune erictune force-pushed the addon-auth-pattern branch from c2945d6 to 26bdaf3 Compare August 16, 2016 19:23
@erictune
Copy link
Member Author

Updated to use client cert and #26634.

@erictune erictune added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Aug 23, 2016
@bgrant0607
Copy link
Member

@enisoc, you may be interested

1. User runs `kubectl proxy -p 8001 &`.
- Same as before.
1. User enters this into their browser navigation bar: `http://localhost:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/?add-auth=true#/workload`
- Difference is the addition of the `add-auth=true` query parameter, which is handled by the APIserver.
Copy link
Member

Choose a reason for hiding this comment

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

What will the URL look like if the target service already has its own query parameters?

For example, what if the URL before add-auth is:

http://localhost:8001/api/v1/proxy/namespaces/default/services/my-dashboard/page?arg=value

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, what I said won't work. I've changed this to not use a query parameter, but instead use an annotation on the service. This makes more sense than requiring the user to specify it, since the need for authentication headers is a property of the service.

@k8s-bot
Copy link

k8s-bot commented Aug 30, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message will repeat several times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

@erictune erictune force-pushed the addon-auth-pattern branch from 26bdaf3 to efba0ac Compare August 30, 2016 05:48
@erictune
Copy link
Member Author

ok-to-test

@bgrant0607
Copy link
Member

cc @pwittrock @deads2k

@bgrant0607
Copy link
Member

Could this also be used for monitoring (e.g., heapster) and logging (e.g., elasticsearch), or is the dashboard the main use case right now?

@erictune erictune force-pushed the addon-auth-pattern branch from efba0ac to 76d57af Compare August 31, 2016 21:57
@erictune
Copy link
Member Author

Other use case: federation apiserver hosted on one of the clusters of a
federation (currently it has no authn integration)

On Wed, Aug 31, 2016 at 2:11 PM, Brian Grant notifications@github.com
wrote:

Other obvious use cases:

  • heapster
  • other monitoring solutions (e.g., kube-state-metrics)
  • logging (elasticsearch)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#29714 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHuudo0NtGnvPCGzGq7FTdO3ovYkErlOks5qle37gaJpZM4JWxY9
.

@erictune
Copy link
Member Author

Good point Solly, I updated to include this at the end of the doc.

On Wed, Aug 31, 2016 at 2:58 PM, Eric Tune etune@google.com wrote:

Other use case: federation apiserver hosted on one of the clusters of a
federation (currently it has no authn integration)

On Wed, Aug 31, 2016 at 2:11 PM, Brian Grant notifications@github.com
wrote:

Other obvious use cases:

  • heapster
  • other monitoring solutions (e.g., kube-state-metrics)
  • logging (elasticsearch)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#29714 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHuudo0NtGnvPCGzGq7FTdO3ovYkErlOks5qle37gaJpZM4JWxY9
.

@k8s-bot
Copy link

k8s-bot commented Aug 31, 2016

GCE e2e build/test passed for commit 76d57af.

@floreks
Copy link
Member

floreks commented Sep 19, 2016

I'm willing to help with this proposal. Still there are some things that are a bit vague to me and my background regarding security is not that great but as I'm going through the code It's getting more clear.

Few questions:

  1. Should it be brand new authn plugin or should some existing one be altered?
  2. Should apiserver only authenticate requests to service proxy based on user certificate (if signed by same CA?) and forward them further thus letting application authorize it?
  3. How should apiserver get X-Remote-User header in order to inject it into the request? Check CN of the certificate?

There will be more once I dive into the code :)

Some detailed scenario would help me understand it better if someone has time to write one.

@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Sep 19, 2016

Should apiserver only authenticate requests to service proxy based on user certificate (if signed by same CA?) and forward them further thus letting application authorize it?

Presumably, it would work based on any auth method, then the strip the actual auth info, and the application would just use X-Remote-User (and the service proxy's certificate to guarantee that the request is genuine).

How should apiserver get X-Remote-User header in order to inject it into the request? Check CN of the certificate?

This would be information passed through by the auth system, presumably -- it populates a nice UserInfo struct (I think that's the name, IIRC) that has all that required info. Take a look at the authentication interface in the code for more details.

@floreks
Copy link
Member

floreks commented Sep 20, 2016

Presumably, it would work based on any auth method, then the strip the actual auth info, and the application would just use X-Remote-User (and the service proxy's certificate to guarantee that the request is genuine).

Then apiserver authn should pretty much stay as it is and after that there should be new part(plugin?) that either proxies request directly to the application (should we skip apiserver authz and admission controller or only authz?) or uses default path (authz + admission controller) before passing it further.

This would be information passed through by the auth system, presumably -- it populates a nice UserInfo struct (I think that's the name, IIRC) that has all that required info. Take a look at the authentication interface in the code for more details.

Thanks! I've found that in the code and you're right. user.Info is already filled with data on request authn.

@erictune
Copy link
Member Author

erictune commented Oct 3, 2016

@pwittrock
We had talked about the UX issues around proxying to web pages on kube

@bgrant0607
Copy link
Member

cc @smawson @louiscryan

@k8s-github-robot
Copy link

Adding label:do-not-merge because PR changes docs prohibited to auto merge
See http://kubernetes.io/editdocs/ for information about editing docs

@k8s-github-robot k8s-github-robot added kind/design Categorizes issue or PR as related to design. kind/old-docs do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. labels Dec 1, 2016
@bryk
Copy link
Contributor

bryk commented Dec 12, 2016

cc @rf232

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] Needs approval from an approver in each of these OWNERS Files:

We suggest the following people:
cc @brendandburns
You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@liggitt liggitt added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Mar 8, 2017
@k8s-github-robot
Copy link

This PR hasn't been active in 90 days. Closing this PR. Please reopen if you would like to work towards merging this change, if/when the PR is ready for the next round of review.

cc @bgrant0607 @erictune @smarterclayton

You can add 'keep-open' label to prevent this from happening again, or add a comment to keep it open another 90 days

@foxish foxish reopened this Apr 14, 2017
1. User enters this into their browser navigation bar: `http://localhost:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/#/workload`
- This causes the API server to proxy a single HTTP request.
- The effect of the two proxies is that an HTTP request on localhost:8001 becomes an HTTP request for `/#/workloads` on port 80 on the pod IP of one of the Pods that backs services `dashboard` in namespace `kube-system`. So far so good.
1. *NEW* When the API server proxies a request to a service with annotation `alpha.service-proxy.kubernetes.io/proxy-authentication`, it does the following extra steps:
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels odd that the proxy-authentication annotation only works when proxy-ing through the API server, would it make sense to implement this lower in the stack (at the same level as kube-proxy for example) such that if the annotation is applied, a proxy-authn add-on will do the exact same logic as the proposed solution for the API server.

This way, this annotation is a lot more powerful since it will seamlessly be applied regardless of how the end-user chooses to access a service.

1. User enters this into their browser navigation bar: `http://localhost:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/#/workload`
- This causes the API server to proxy a single HTTP request.
- The effect of the two proxies is that an HTTP request on localhost:8001 becomes an HTTP request for `/#/workloads` on port 80 on the pod IP of one of the Pods that backs services `dashboard` in namespace `kube-system`. So far so good.
1. *NEW* When the API server proxies a request to a service with annotation `alpha.service-proxy.kubernetes.io/proxy-authentication`, it does the following extra steps:
Copy link
Member

Choose a reason for hiding this comment

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

Is there a backwards compat or performance reason to make it opt-in? Could the api server always add the header?

@k8s-github-robot
Copy link

This PR hasn't been active in 90 days. Closing this PR. Please reopen if you would like to work towards merging this change, if/when the PR is ready for the next round of review.

cc @bgrant0607 @erictune @smarterclayton

You can add 'keep-open' label to prevent this from happening again, or add a comment to keep it open another 90 days

@amostech
Copy link

Is there an update on this functionality? I'm trying to expose the Dashboard through address 0.0.0.0 port 8001 but sending the Authorization: Bearer XXXXX always gives a message Unauthorized anyways. How to access dashboard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. kind/design Categorizes issue or PR as related to design. release-note-none Denotes a PR that doesn't merit a release note. sig/auth Categorizes an issue or PR as relevant to SIG Auth. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.