Skip to content

Make OAuth provider discoverable from within a Pod - #10845

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
enj:enj/f/oauth_pod_flow
Oct 20, 2016
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
enj:enj/f/oauth_pod_flow

Conversation

@enj

@enj enj commented Sep 8, 2016 •

Copy link
Copy Markdown
Contributor

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

Comment thread pkg/oauth/discovery/discovery.go Outdated
scope.UserListAllProjects,
},
ResponseTypesSupported: config.AllowedAuthorizeTypes,
GrantTypesSupported: config.AllowedAccessTypes,

Copy link
Copy Markdown
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

enj commented Sep 8, 2016

Copy link
Copy Markdown
Contributor Author

[test] since I changed existing code.

@enj

enj commented Sep 8, 2016

Copy link
Copy Markdown
Contributor Author

re[test] AWS error

@liggitt

liggitt commented Sep 10, 2016

Copy link
Copy Markdown
Contributor

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
Comment thread pkg/cmd/server/origin/master.go Outdated
initReadinessCheckRoute(root, "/healthz/ready", c.ProjectAuthorizationCache.ReadyForAccess)
initVersionRoute(container, "/version/openshift")

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

Copy link
Copy Markdown
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

liggitt commented Sep 12, 2016

Copy link
Copy Markdown
Contributor

@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

enj commented Sep 12, 2016

Copy link
Copy Markdown
Contributor Author

re[test] flake on #10080

@deads2k

deads2k commented Sep 13, 2016

Copy link
Copy Markdown
Contributor

@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

enj commented Sep 13, 2016

Copy link
Copy Markdown
Contributor Author

@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

deads2k commented Sep 13, 2016

Copy link
Copy Markdown
Contributor

@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

liggitt commented Sep 13, 2016

Copy link
Copy Markdown
Contributor

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

@deads2k

deads2k commented Sep 13, 2016

Copy link
Copy Markdown
Contributor

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

@deads2k

deads2k commented Sep 15, 2016

Copy link
Copy Markdown
Contributor

@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

@soltysh soltysh left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@soltysh soltysh left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

deads2k commented Oct 5, 2016

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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

enj commented Oct 7, 2016

Copy link
Copy Markdown
Contributor Author

re[test] flake #11114

Comment thread pkg/oauth/discovery/discovery.go Outdated
scope.UserListAllProjects,
},
ResponseTypesSupported: config.AllowedAuthorizeTypes,
GrantTypesSupported: osin.AllowedAccessType{osin.AUTHORIZATION_CODE}, // TODO use config.AllowedAccessTypes once our implementation handles other grant types

@liggitt liggitt Oct 7, 2016 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

API is approved

Comment thread pkg/oauth/discovery/discovery_test.go Outdated
},
GrantTypesSupported: osin.AllowedAccessType{
"authorization_code",
"__implicit",

Copy link
Copy Markdown
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

liggitt commented Oct 14, 2016

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

enj commented Oct 17, 2016

Copy link
Copy Markdown
Contributor Author

@mfojtik Ready for merge.

@mfojtik

mfojtik commented Oct 17, 2016

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

@enj

enj commented Oct 18, 2016

Copy link
Copy Markdown
Contributor Author

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

@mfojtik

mfojtik commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

[merge]

@mfojtik

mfojtik commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

flake #11240

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to fda7222

@openshift-bot

openshift-bot commented Oct 20, 2016 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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