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

Per-client access token expiration #14784

Merged
merged 2 commits into from
Sep 19, 2017
Merged

Per-client access token expiration #14784

merged 2 commits into from
Sep 19, 2017

Conversation

liggitt
Copy link
Contributor

@liggitt liggitt commented Jun 20, 2017

This allows overriding max access token age per OAuthClient.

https://trello.com/c/hNhBstvg

OAuthClient object gains a new field: accessTokenMaxAgeSeconds

  • When absent, the master-config value is used
  • When set to 0, tokens issued for that client do not expire
  • When set to a value > 0, tokens issued for that client are given the specified expiration time

@liggitt
Copy link
Contributor Author

liggitt commented Jun 20, 2017

[test]

@@ -84,6 +84,13 @@ func (w *clientWrapper) GetUserData() interface{} {
return w.client
}

func (w *clientWrapper) GetExpiration(defaultExpiration int32) int32 {
if w.client.AccessTokenMaxAgeSeconds != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be an upper bound beyond which users can't specify? Under admin control? Or can we convincingly argue that only admins should be able to edit OAuthClients?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they are admin-controlled today, especially since grant method can be set to auto accept per-client

@smarterclayton
Copy link
Contributor

I don't ha e any objections to this.

@enj
Copy link
Contributor

enj commented Jun 22, 2017

@openshift/security

@enj
Copy link
Contributor

enj commented Jun 22, 2017

So I know we want most of the OAuth objects to be user managible at some point. Not sure if I would want a user to able to ever change expiration though.


// AccessTokenMaxAgeSeconds overrides the default access token max age for tokens granted to this client.
// 0 means no expiration.
AccessTokenMaxAgeSeconds *int32
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume max int32 in seconds fits in max int64 in nanoseconds (time.Duration).

@@ -23,6 +24,10 @@ func NewAuthorizeAuthenticator(request authenticator.Request, handler Authentica
return &AuthorizeAuthenticator{request, handler, errorHandler}
}

type ClientExpiration interface {
GetExpiration(int32) int32
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to turn this into GetExpiration() int32? Taking in the default seems meh.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2017
@enj enj added this to the 3.7.0 milestone Jun 28, 2017
@enj
Copy link
Contributor

enj commented Jun 28, 2017

Trello card is still in backlog so moving this to 3.7.

@pweil- I assume that is fine.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 6f1b7b4

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 13, 2017
@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/3098/) (Base Commit: a108425) (PR Branch Commit: 6f1b7b4)

@openshift-merge-robot openshift-merge-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 24, 2017
@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 28, 2017
@soltysh
Copy link
Member

soltysh commented Aug 4, 2017

/unassign

@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 24, 2017
@liggitt
Copy link
Contributor Author

liggitt commented Aug 24, 2017

cc @openshift/sig-security

@liggitt liggitt assigned enj and simo5 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. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 30, 2017
@openshift-ci-robot openshift-ci-robot added 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 Sep 13, 2017
@liggitt
Copy link
Contributor Author

liggitt commented Sep 13, 2017

/retest

@liggitt
Copy link
Contributor Author

liggitt commented Sep 14, 2017

@enj PTAL

@@ -23,6 +23,13 @@ func NewAuthorizeAuthenticator(request authenticator.Request, handler Authentica
return &AuthorizeAuthenticator{request, handler, errorHandler}
}

type TokenMaxAgeSeconds interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not know if this is the best place to define this interface.

Maybe pkg/oauth/server/osinserver/interfaces.go?

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 do not know if this is the best place to define this interface.

why not? this is the only place the interface is used

Copy link
Contributor

Choose a reason for hiding this comment

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

I was not sure if we wanted to import github.com/openshift/origin/pkg/auth/oauth/handlers in pkg/oauth/server/osinserver/registrystorage/storage.go

@@ -82,6 +82,10 @@ func (w *clientWrapper) GetUserData() interface{} {
return w.client
}

func (w *clientWrapper) GetTokenMaxAgeSeconds() *int32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a type assertion for TokenMaxAgeSeconds interface.

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

}

// Use the server and CA info
anonConfig := restclient.Config{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use AnonymousClientConfig?

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

}

{
five := int32(5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is 5 seconds long enough for it to not flake during load?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made ten

@liggitt
Copy link
Contributor Author

liggitt commented Sep 17, 2017

comments addressed, PTAL

expires := created.Add(time.Duration(token.ExpiresIn) * time.Second)
expires := "never"
if token.ExpiresIn > 0 {
expires = created.Add(time.Duration(token.ExpiresIn) * time.Second).String()
Copy link
Contributor

Choose a reason for hiding this comment

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

printOAuthClient should be updated with AccessTokenMaxAgeSeconds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -23,6 +23,13 @@ func NewAuthorizeAuthenticator(request authenticator.Request, handler Authentica
return &AuthorizeAuthenticator{request, handler, errorHandler}
}

type TokenMaxAgeSeconds interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was not sure if we wanted to import github.com/openshift/origin/pkg/auth/oauth/handlers in pkg/oauth/server/osinserver/registrystorage/storage.go

@liggitt
Copy link
Contributor Author

liggitt commented Sep 18, 2017

I was not sure if we wanted to import github.com/openshift/origin/pkg/auth/oauth/handlers in pkg/oauth/server/osinserver/registrystorage/storage.go

I don't care for now... we can hoist the interface up to a common package and do an assertion there if it becomes an issue

@enj
Copy link
Contributor

enj commented Sep 18, 2017

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@enj
Copy link
Contributor

enj commented Sep 18, 2017

/retest

2 similar comments
@liggitt
Copy link
Contributor Author

liggitt commented Sep 18, 2017

/retest

@enj
Copy link
Contributor

enj commented Sep 19, 2017

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@enj
Copy link
Contributor

enj commented Sep 19, 2017

/retest

@enj
Copy link
Contributor

enj commented Sep 19, 2017

Flake #15900

@enj
Copy link
Contributor

enj commented Sep 19, 2017

/retest

@enj
Copy link
Contributor

enj commented Sep 19, 2017

Flake #16248

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 14784, 16418, 16406, 16431, 14796)

@openshift-merge-robot openshift-merge-robot merged commit 660aa12 into openshift:master Sep 19, 2017
@openshift-ci-robot
Copy link

@liggitt: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_install_update a72b77b link /test extended_conformance_install_update

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@liggitt liggitt deleted the per-client-expiration branch September 21, 2017 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved 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. needs-api-review 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.

None yet

9 participants