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

Infrastructure changes for token timeouts #17614

Merged

Conversation

enj
Copy link
Contributor

@enj enj commented Dec 5, 2017

Remove duplicate Origin authenticator interfaces

This change removes the duplicate authenticator interfaces that are
no longer needed. The exact same interfaces exist upstream, so this
change is purely mechanical.

Signed-off-by: Monis Khan [email protected]


Add OAuth token and user validator interface

This change adds the OAuthTokenValidator interface for generically
validating an OAuthAccessToken and User. The expiration and UID
validation was pulled out from the tokenAuthenticator.
tokenAuthenticator simply takes OAuthTokenValidators as input, and
delegates validation to them. This allows all future validation to
simply append itself to the list of validators without requiring any
changes to tokenAuthenticator.

Signed-off-by: Monis Khan [email protected]


Wire up OAuth shared informer

This change wires up the OAuth informer to allow performant lookups
to be made for the OAuth resources.

Signed-off-by: Monis Khan [email protected]


Allow authenticator to return post start hooks

This change allows the authenticator to return post start hooks that
can be used to set up any infrastructure the authenticator needs.
It also makes sure that these resources are properly cleaned up when
the post start hooks are stopped.

Signed-off-by: Monis Khan [email protected]


/assign @simo5

@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 5, 2017
Copy link
Contributor

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

I like this (except the last commit really does not belong in the same PR).
Only minor nits to fix

@@ -13,3 +15,28 @@ type Assertion interface {
type Client interface {
AuthenticateClient(client api.Client) (user.Info, bool, error)
}

type OAuthTokenUserValidator interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be called OAuthTokenValidator
The fact one of the validators checks users does not change the generic nature of the validator.

return authenticator.OAuthTokenUserValidatorFunc(
func(token *oauth.OAuthAccessToken, _ *user.User) error {
if token.ExpiresIn > 0 {
if token.CreationTimestamp.Time.Add(time.Duration(token.ExpiresIn) * time.Second).Before(time.Now()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It be more readbale if the conversion of token.ExpiresIn to a duration would be doen via a helper function

func TestAuthenticateTokenExpired(t *testing.T) {
fakeOAuthClient := oauthfake.NewSimpleClientset(
&oapi.OAuthAccessToken{
ObjectMeta: metav1.ObjectMeta{Name: "token", CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * time.Hour)}},
ObjectMeta: metav1.ObjectMeta{Name: "token1", CreationTimestamp: metav1.Time{Time: time.Now().Add(-1 * time.Hour)}}, // expired
Copy link
Contributor

Choose a reason for hiding this comment

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

these comments are so far they look silly, what about adding just one explanatory comment on the line before &oapi.OAuthAccessToken{ ?
Like:
// Add expired token with 10 minutes expiration time

tokens oauthclient.OAuthAccessTokenInterface
users userclient.UserResourceInterface
groupMapper identitymapper.UserToGroupMapper
validator authenticator.OAuthTokenUserValidator
Copy link
Contributor

Choose a reason for hiding this comment

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

should probably be plural: validators

@@ -0,0 +1,182 @@
package sortedset
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be called something like rankedset, a soretedset is a different thing
Also prese move this whole commit to a different PR, as it has nothing to do with the rest of infrastrcture changes

enj added 4 commits December 5, 2017 17:13
This change removes the duplicate authenticator interfaces that are
no longer needed.  The exact same interfaces exist upstream, so this
change is purely mechanical.

Signed-off-by: Monis Khan <[email protected]>
This change adds the OAuthTokenValidator interface for generically
validating an OAuthAccessToken and User.  The expiration and UID
validation was pulled out from the tokenAuthenticator.
tokenAuthenticator simply takes OAuthTokenValidators as input, and
delegates validation to them.  This allows all future validation to
simply append itself to the list of validators without requiring any
changes to tokenAuthenticator.

Signed-off-by: Monis Khan <[email protected]>
This change wires up the OAuth informer to allow performant lookups
to be made for the OAuth resources.

Signed-off-by: Monis Khan <[email protected]>
This change allows the authenticator to return post start hooks that
can be used to set up any infrastructure the authenticator needs.
It also makes sure that these resources are properly cleaned up when
the post start hooks are stopped.

Signed-off-by: Monis Khan <[email protected]>
@enj enj force-pushed the enj/f/token_timeout_foundation branch from 804c8d6 to f27d947 Compare December 5, 2017 22:18
@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 5, 2017
@simo5
Copy link
Contributor

simo5 commented Dec 5, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 5, 2017
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enj, simo5

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

@simo5
Copy link
Contributor

simo5 commented Dec 5, 2017

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 17480, 17614).

@openshift-merge-robot openshift-merge-robot merged commit c863312 into openshift:master Dec 6, 2017
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. 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.

4 participants