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

enhancement: Secure OAuth Resource Storage #323

Merged

Conversation

sttts
Copy link
Contributor

@sttts sttts commented May 13, 2020

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 13, 2020
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2020
enhancements/authentication/oauth-resource-storage.md Outdated Show resolved Hide resolved
enhancements/authentication/oauth-resource-storage.md Outdated Show resolved Hide resolved
enhancements/authentication/oauth-resource-storage.md Outdated Show resolved Hide resolved
enhancements/authentication/oauth-resource-storage.md Outdated Show resolved Hide resolved

### Upgrade / Downgrade Strategy

- New kube-apiserver will authorize clients with old tokens (43 characters long)
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 the new Kube invalidate the old (not secure) tokens? If yes, does it have an impact on upgrades?

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 should it? They expire eventually (after a day by default).

or the output of etcdctl can be used to act as any oauth authenticated user in the
cluster.

A side-effect of the proposed compound tokens is that it allows to hide the secret part
Copy link
Contributor

Choose a reason for hiding this comment

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

hiding content on read is novel and violates standard kube conventions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we have explicitly rejected that repeatedly. The original designs for tokens discussed having a read index.


### Goals

- Change the `oauthaccesstokens` and `oauthauthorizetokens` storage format and schema such that
Copy link
Contributor

Choose a reason for hiding this comment

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

how short lived are oauthaccesstokens. I thought it was order of minutes.

Copy link
Contributor

Choose a reason for hiding this comment

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

the default expiry of oauthaccesstokens is set to a day in 4.x, oauthauthorizetokens usually last for only a few seconds as they are deleted upon oauthaccesstoken retrieval

pass 43 bytes bearer token, leading into the zero length case.

Old kube-apiserver (on downgrade) will try to lookup the token object via the whole token
and fail. I.e. on downgrade clients have to reauthenticate.
Copy link
Contributor

Choose a reason for hiding this comment

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

This section should also include details on the tokens' creation and handling in the oauth-server as this would also need some changes, see the storage implementation we use to plug into osin:
https://github.com/openshift/oauth-server/blob/31279d2cabc12e26f7ab716b5f65e055214d372f/pkg/osinserver/registrystorage/storage.go

As an example that stands out, OAuthAuthorizeTokens' storage is specifically used during the authorization code grant in https://github.com/openshift/oauth-server/blob/31279d2cabc12e26f7ab716b5f65e055214d372f/vendor/github.com/RangelReale/osin/access.go#L183-L183.

These changes will most likely be small, yet worth mentioning.

### Implementation Details/Notes/Constraints [optional]

The oauth authorizer in kube-apiserver in v4.6 will split the provided bearer token into
the first 43 bytes (256 bits, compare https://github.com/openshift/oauth-server/blob/3539e4065084dc0b5f35e43d7ea49631df99760d/pkg/server/crypto/random.go#L31-L35)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break some test cases and potentially some very rarely used features around direct token assignment. Please call that out.

I'd like to also place a character we expect at byte 44 so that when we change this in the future (and I bet we will), we'll have something clear to look for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to obfuscate. type:<token> works fine.

@sttts sttts force-pushed the sttts-oauth-storage-format branch 2 times, most recently from f12f663 to c75cfe5 Compare June 29, 2020 11:35
@sttts
Copy link
Contributor Author

sttts commented Jun 29, 2020

/retitle enhancement: Secure OAuth Resource Storage

@sttts sttts changed the title WIP: enhancements: Secure OAuth Resource Storage enhancement: Secure OAuth Resource Storage Jun 29, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 29, 2020
@sttts sttts force-pushed the sttts-oauth-storage-format branch from c75cfe5 to e44507f Compare June 29, 2020 11:40
@mfojtik
Copy link
Contributor

mfojtik commented Jul 1, 2020

/lgtm

@smarterclayton or @derekwaynecarr can you approve this?
/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 1, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2020
@sttts sttts force-pushed the sttts-oauth-storage-format branch from 1e373f3 to 4b2b0de Compare July 1, 2020 13:51
@mfojtik
Copy link
Contributor

mfojtik commented Jul 1, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2020
@mfojtik
Copy link
Contributor

mfojtik commented Jul 14, 2020

@openshift/openshift-architects second ping :-)

of the actual token (not decoded, but plain base64) encoded as base64. The bearer
token will also carry the prefix, but have the token in plain text.

In v4.(n-1) and in v4.n:
Copy link
Member

@eparis eparis Jul 14, 2020

Choose a reason for hiding this comment

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

My only concern would be what N and (N-1) are if a user attempts an emergency unsupported rollback to N-1. And if we are certain that their N-1 has support for sha256: tokens.

Copy link
Contributor Author

@sttts sttts Jul 14, 2020

Choose a reason for hiding this comment

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

Worst that can happen is that users have to relogin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear: this means that we add sha256 support in 4.n-1.x. If the customer does a downgrade to that, everything keeps working. If the the customer does a downgrade to 4.n-1.x-1, then users have to relogin, but otherwise things keep working. So it is similar as tokens that expire (after a day by default), but enforced by the unsupported downgrade.

@stlaz
Copy link
Contributor

stlaz commented Jul 14, 2020

/lgtm

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfojtik, stlaz, sttts

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mfojtik
Copy link
Contributor

mfojtik commented Jul 14, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 14, 2020
@openshift-merge-robot openshift-merge-robot merged commit e33b4ea into openshift:master Jul 14, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet