Skip to content

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Aug 24, 2017

@mfojtik this is needed to remove direct etcd access which bypasses any admission checks and auditing and prevents the future separation of processes.

@openshift-merge-robot openshift-merge-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 24, 2017
@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-api-review labels Aug 24, 2017
return baseMux, nil
}

func (c *OAuthServerConfig) RegisterTokenRequestEndpoint(context genericapiserver.PostStartHookContext) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This bit is nasty. The server won't report healthy until it succeeds though. We need to decide where this should logically live, but I think this is the part where we actually depend on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

huh... adding a handler to the mux post-startup seems weirder than adding a handler and having it respond with errors until populated with the necessary clients post-startup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

huh... adding a handler to the mux post-startup seems weirder than adding a handler and having it respond with errors until populated with the necessary clients post-startup

If you prefer. How about I cut the links in this pull and twiddle it after. This is the big money and rest is arguing over spoils.

return oauthServer.GenericAPIServer.PrepareRun().GenericAPIServer.Handler.FullHandlerChain, nil
return oauthServer.GenericAPIServer.PrepareRun().GenericAPIServer.Handler.FullHandlerChain,
map[string]apiserver.PostStartHookFunc{
"oauth.openshift.io-RegisterTokenRequestEndpoint": config.RegisterTokenRequestEndpoint,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't expecting handler registration in post-start hooks... what requires this to be async?

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 wasn't expecting handler registration in post-start hooks... what requires this to be async?

The creation of clients needs to be a post-start hook, the handler could give failures until they exist.

@@ -696,7 +699,7 @@ func newAuthenticator(config configapi.MasterConfig, restOptionsGetter restoptio

// OAuth token
if config.OAuthConfig != nil {
oauthTokenAuthenticator, err := getEtcdTokenAuthenticator(restOptionsGetter, userGetter, groupMapper)
oauthTokenAuthenticator, err := getEtcdTokenAuthenticator(accessTokenGetter, userGetter, groupMapper)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be able to drop this at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we be able to drop this at this point?

I wasn't anticipating dropping anything. I'll look back and see.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 25, 2017
@deads2k deads2k force-pushed the oauth-03-use-client branch from 7160376 to 6ad2935 Compare August 25, 2017 17:55
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 25, 2017
@deads2k deads2k force-pushed the oauth-03-use-client branch 2 times, most recently from 25878d0 to 5583ecb Compare August 25, 2017 19:31
@deads2k
Copy link
Contributor Author

deads2k commented Aug 26, 2017

Comments addressed

@deads2k
Copy link
Contributor Author

deads2k commented Aug 28, 2017

/retest

auth := action.(clienttesting.UpdateAction).GetObject().(*oapi.OAuthClientAuthorization)
if !reflect.DeepEqual(testCase.ExpectUpdatedAuthScopes, auth.Scopes) {
t.Errorf("%s: expected updated scopes %v, got %v", k, testCase.ExpectUpdatedAuthScopes, auth.Scopes)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

bit: break ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

auth := action.(clienttesting.CreateAction).GetObject().(*oapi.OAuthClientAuthorization)
if !reflect.DeepEqual(testCase.ExpectCreatedAuthScopes, auth.Scopes) {
t.Errorf("%s: expected created scopes %v, got %v", k, testCase.ExpectCreatedAuthScopes, auth.Scopes)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return oauthServer.GenericAPIServer.PrepareRun().GenericAPIServer.Handler.FullHandlerChain, nil
return oauthServer.GenericAPIServer.PrepareRun().GenericAPIServer.Handler.FullHandlerChain,
map[string]apiserver.PostStartHookFunc{
"oauth.openshift.io-EnsureBootstrapOAuthClients": config.EnsureBootstrapOAuthClients,
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be a const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldn't this be a const?

I don't think so. We aren't really expecting these to be stable or referred to.

osOAuthClientConfig.RedirectUrl = c.Options.MasterPublicURL + path.Join(oauthutil.OpenShiftOAuthAPIPrefix, tokenrequest.DisplayTokenEndpoint)

osOAuthClient, _ := osincli.NewClient(osOAuthClientConfig)
if len(*c.Options.MasterCA) > 0 {
rootCAs, err := cmdutil.CertPoolFromFile(*c.Options.MasterCA)
if err != nil {
glog.Fatal(err)
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k i hope this error is properly captured in upper level :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deads2k i hope this error is properly captured in upper level :)

it is

@@ -185,3 +194,42 @@ func (c *OAuthServerConfig) buildHandlerChainForOAuth(startingHandler http.Handl
handler = genericfilters.WithPanicRecovery(handler)
return handler
}

// TODO, this moves to the `apiserver.go` when we have it for this group
// TODO TODO, this actually looks a lot like a controller or an add-on manager style thing. Seems like we'd want to do this outside
Copy link
Contributor

Choose a reason for hiding this comment

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

metatodo? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

also lacks normal godoc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -137,3 +137,7 @@ func Matcher(label labels.Selector, field fields.Selector) kstorage.SelectionPre
func SelectableFields(obj *oauthapi.OAuthClientAuthorization) fields.Set {
return oauthapi.OAuthClientAuthorizationToSelectableFields(obj)
}

func ClientAuthorizationName(userName, clientName string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

godoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -99,6 +99,7 @@ var expectedIndex = []string{
// "/healthz/poststarthook/extensions/third-party-resources", // Do not enable this controller, we do not support it
"/healthz/poststarthook/generic-apiserver-start-informers",
"/healthz/poststarthook/kube-apiserver-autoregistration",
"/healthz/poststarthook/oauth.openshift.io-EnsureBootstrapOAuthClients",
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this camelcase while the rest is lowecase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why is this camelcase while the rest is lowecase?

we're working through what it should look like.

clientStorage, err := clientetcd.NewREST(optsGetter)
if err != nil {
t.Fatalf("unexpected error: %v", err)
t.Fatal(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

now we won't know this was unexpected :-)

@mfojtik
Copy link
Contributor

mfojtik commented Aug 28, 2017

just couple small nits, but the intent and how this was done LGTM

/approve no-issue

@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, mfojtik

The full list of commands accepted by this bot can be found here.

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

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@deads2k deads2k force-pushed the oauth-03-use-client branch from bc1998f to df6eccb Compare August 28, 2017 15:36
@deads2k
Copy link
Contributor Author

deads2k commented Aug 28, 2017

comments addressed. applying label.

@deads2k deads2k added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2017
@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue

@openshift-merge-robot openshift-merge-robot merged commit 26b5a8c into openshift:master Aug 28, 2017
@deads2k deads2k deleted the oauth-03-use-client branch January 24, 2018 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. retest-not-required size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants