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

Make OAuth provider discoverable from within a Pod #10845

Merged
merged 1 commit into from
Oct 20, 2016

Conversation

enj
Copy link
Contributor

@enj enj commented Sep 8, 2016

Implementation of https://tools.ietf.org/html/draft-ietf-oauth-discovery-04

From within a pod:

root@test:/# curl -k https://openshift.default.svc/.well-known/oauth-authorization-server
{
  "issuer": "https://10.13.129.56:8443",
  "authorization_endpoint": "https://10.13.129.56:8443/oauth/authorize",
  "token_endpoint": "https://10.13.129.56:8443/oauth/token",
  "scopes_supported": [
    "user:full",
    "user:info",
    "user:check-access",
    "user:list-scoped-projects",
    "user:list-projects"
  ],
  "response_types_supported": [
    "code",
    "token"
  ],
  "grant_types_supported": [
    "authorization_code",
    "implicit"
  ],
  "code_challenge_methods_supported": [
    "plain",
    "S256"
  ]
}

cc @gabemontero @bparees

Trello ref:
https://trello.com/c/7uYQSTdR

scope.UserListAllProjects,
},
ResponseTypesSupported: config.AllowedAuthorizeTypes,
GrantTypesSupported: config.AllowedAccessTypes,
Copy link
Contributor

Choose a reason for hiding this comment

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

only include "authorization_code" for now. the others are included in the osin config, but the impl given to actually validate the other types (client-credentials, assertion, etc) just denies

@enj
Copy link
Contributor Author

enj commented Sep 8, 2016

[test] since I changed existing code.

@enj
Copy link
Contributor Author

enj commented Sep 8, 2016

re[test] AWS error

@liggitt
Copy link
Contributor

liggitt commented Sep 10, 2016

Let's keep the redirect uri stuff in a separate PR. The discovery bits are useful on their own

@enj enj force-pushed the enj/f/oauth_pod_flow branch from cae7b06 to 184e1d8 Compare September 12, 2016 13:55
@enj enj changed the title WIP: Make OAuth provider discoverable from within a Pod Make OAuth provider discoverable from within a Pod Sep 12, 2016
@@ -346,37 +347,76 @@ func (c *MasterConfig) InstallProtectedAPI(container *restful.Container) ([]stri
initControllerRoutes(root, "/controllers", c.Options.Controllers != configapi.ControllersDisabled, c.ControllerPlug)
initHealthCheckRoute(root, "/healthz")
initReadinessCheckRoute(root, "/healthz/ready", c.ProjectAuthorizationCache.ReadyForAccess)
initVersionRoute(container, "/version/openshift")

if err := initVersionRoute(container, "/version/openshift"); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you make this fatal?

@liggitt
Copy link
Contributor

liggitt commented Sep 12, 2016

@deads2k I'm wondering how this will fit with the oauth server split stuff we discussed

@enj enj force-pushed the enj/f/oauth_pod_flow branch 2 times, most recently from 22ec011 to 4068743 Compare September 12, 2016 16:10
@enj
Copy link
Contributor Author

enj commented Sep 12, 2016

re[test] flake on #10080

@deads2k
Copy link
Contributor

deads2k commented Sep 13, 2016

@deads2k I'm wondering how this will fit with the oauth server split stuff we discussed

You really want to build it like this? Even if you decide to do it like this, you should version this API.

@enj
Copy link
Contributor Author

enj commented Sep 13, 2016

@deads2k I am not sure if I would call this an API since you can't really perform any actions with it. That being said, the draft has no concept of versioning. Granted I suppose they could just make a new well known URI if they ever needed to make a backwards incompatible change. The data returned by this endpoint is essentially never supposed to change structure.

@deads2k
Copy link
Contributor

deads2k commented Sep 13, 2016

@deads2k I am not sure if I would call this an API since you can't really perform any actions with it.

You call it externally and rely on its output to behave consistently for the purposes of deserialization so that a client can semantically interpret it. API.

The data returned by this endpoint is essentially never supposed to change structure.

That rarely works out.

@liggitt
Copy link
Contributor

liggitt commented Sep 13, 2016

the URL and output are dictated by the rfc. curious how you would version that

@deads2k
Copy link
Contributor

deads2k commented Sep 13, 2016

Didn't realize it was for a spec. Your link to the spec is dead.

@deads2k
Copy link
Contributor

deads2k commented Sep 15, 2016

@enj Consider a world where the oauth server lives in a process that is separate from the API server. Because other authentication techniques exist, it could actually be in a pod. This has several repercussions:

  1. other than this endpoint, the api server doesn't have to know where the oauth server lives
  2. you won't be able to derive this information through self-inspection
  3. callers of this API will sometimes want externally routable URLs (when redirecting clients) and sometimes want internally routable URLs (when exchanging codes for tokens)

Items 1 and 2 suggest that you could try to find this information via API inspection (magic config map or magic service/route come to mind).

Item 3 could probably be punted on if we expect overall internal traffic to be low.

@soltysh soltysh self-assigned this Sep 20, 2016
@mfojtik mfojtik added this to the 1.4.0 milestone Sep 20, 2016
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Only two questions, the code itself looks good. As for @deads2k suggestion I'm opposed to versioning that endpoint.


// OauthAuthorizationServerMetadata holds OAuth 2.0 Authorization Server Metadata used for discovery
// https://tools.ietf.org/id/draft-ietf-oauth-discovery-04.html#rfc.section.2
type OauthAuthorizationServerMetadata struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the remaining metadata attributes? Why only those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I focused on the REQUIRED and RECOMMENDED metadata. A lot of the OPTIONAL ones are not supported by OpenShift (for example, jwks_uri and token_endpoint_auth_signing_alg_values_supported). Since @liggitt just added PKCE support, I could add code_challenge_methods_supported (but that may be out of scope and could certainly be added later). token_endpoint_auth_methods_supported, service_documentation, ui_locales_supported, op_policy_uri, op_tos_uri, protected_resources, etc may all be valid now or in the future, but are probably out of scope as well.

Issuer: masterPublicURL,
AuthorizationEndpoint: authorizeURL,
TokenEndpoint: tokenURL,
ScopesSupported: []string{ // Note: this list is incomplete, which is allowed per the draft spec
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these scopes and not others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't see an easy way for me to get any other scopes. I welcome suggestions for making this list more complete.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the remaining role scope is varying, since it contains actual role name and namespace. Well, we're complaint with the spec, since it allows not to advertise all. Thanks for the info

@enj enj force-pushed the enj/f/oauth_pod_flow branch from 4068743 to 087c823 Compare September 20, 2016 14:42
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

LGTM

Issuer: masterPublicURL,
AuthorizationEndpoint: authorizeURL,
TokenEndpoint: tokenURL,
ScopesSupported: []string{ // Note: this list is incomplete, which is allowed per the draft spec
Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the remaining role scope is varying, since it contains actual role name and namespace. Well, we're complaint with the spec, since it allows not to advertise all. Thanks for the info

@deads2k
Copy link
Contributor

deads2k commented Oct 5, 2016

@deads2k mentioned that this should return a different URL based on if the request comes from inside or outside the cluster. @openshift/api-review @jwforres @gabemontero

I'm not sure its that simple. Sometimes you want to discover externally routable names and sometimes you want to discover internally routable names. Assuming that internal components can hit externally routable names (like this does) gets us a long way.

@smarterclayton
Copy link
Contributor

Expectation is author set the route name to a resolvable one. Def add to
docs for this (and godoc)

On Oct 5, 2016, at 7:58 AM, David Eads [email protected] wrote:

@deads2k https://github.com/deads2k mentioned that this should return a
different URL based on if the request comes from inside or outside the
cluster. @openshift/api-review
https://github.com/orgs/openshift/teams/api-review @jwforres
https://github.com/jwforres @gabemontero https://github.com/gabemontero

I'm not sure its that simple. Sometimes you want to discover externally
routable names and sometimes you want to discover internally routable
names. Assuming that internal components can hit externally routable names
(like this does) gets us a long way.


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
#10845 (comment),
or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABG_p_A8DLW21-wvXEDmK_F0nB4du3u5ks5qw5DhgaJpZM4J3grZ
.

@enj enj force-pushed the enj/f/oauth_pod_flow branch 2 times, most recently from 922c14f to ef95e46 Compare October 6, 2016 18:32
@enj
Copy link
Contributor Author

enj commented Oct 7, 2016

re[test] flake #11114

scope.UserListAllProjects,
},
ResponseTypesSupported: config.AllowedAuthorizeTypes,
GrantTypesSupported: osin.AllowedAccessType{osin.AUTHORIZATION_CODE}, // TODO use config.AllowedAccessTypes once our implementation handles other grant types
Copy link
Contributor

@liggitt liggitt Oct 7, 2016

Choose a reason for hiding this comment

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

we also support implicit

@enj enj force-pushed the enj/f/oauth_pod_flow branch 2 times, most recently from ec40da1 to 53263fe Compare October 7, 2016 14:53
@smarterclayton
Copy link
Contributor

API is approved

},
GrantTypesSupported: osin.AllowedAccessType{
"authorization_code",
"__implicit",
Copy link
Contributor

Choose a reason for hiding this comment

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

"implicit", not "__implicit"

@liggitt
Copy link
Contributor

liggitt commented Oct 14, 2016

fix the implicit grant type, then LGTM

@enj enj force-pushed the enj/f/oauth_pod_flow branch from 53263fe to fda7222 Compare October 17, 2016 12:43
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to fda7222

@enj enj dismissed smarterclayton’s stale review October 17, 2016 13:00

API Approved by Clayton

@enj
Copy link
Contributor Author

enj commented Oct 17, 2016

@mfojtik Ready for merge.

@mfojtik
Copy link
Contributor

mfojtik commented Oct 17, 2016

[merge]

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10108/) (Base Commit: 2142bdb)

@enj
Copy link
Contributor Author

enj commented Oct 18, 2016

Flake on #11381
@mfojtik Please re-merge as that flake is fixed now.

@mfojtik
Copy link
Contributor

mfojtik commented Oct 20, 2016

[merge]

@mfojtik
Copy link
Contributor

mfojtik commented Oct 20, 2016

flake #11240

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to fda7222

@openshift-bot
Copy link
Contributor

openshift-bot commented Oct 20, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10327/) (Base Commit: 9ef2b7f) (Image: devenv-rhel7_5210)

@openshift-bot openshift-bot merged commit 1ec25ef into openshift:master Oct 20, 2016
@gabemontero
Copy link
Contributor

I pulled down the latest origin containing this merged PR and was able to successfully access .well-known/oauth-authorization-server from the jenkins oauth plugin !!

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

Successfully merging this pull request may close these issues.

8 participants