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

UPSTREAM: <carry>: oauth-authn: add implicit audience support #24461

Merged
merged 1 commit into from Jan 28, 2020

Conversation

sttts
Copy link
Contributor

@sttts sttts commented Jan 27, 2020

The TokenReview REST implementation expects that the authn chain returns audiences in the authn response. Authenticators that don't support audiences must return the default slice of audiences, e.g. the legacy service account authenticator does that. This PR adds that to our custom oauth authenticator.

Folliowing https://github.com/kubernetes/kubernetes/blob/master/pkg/serviceaccount/jwt.go#L283.

Compare https://github.com/kubernetes/kubernetes/pull/69582/files#r225535241.

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. vendor-update Touching vendor dir or related files labels Jan 27, 2020
@sttts
Copy link
Contributor Author

sttts commented Jan 27, 2020

/assign @marun @deads2k @stlaz

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2020
@sttts sttts force-pushed the sttts-oauth-implicit-audiences branch from 6e5f508 to 5e8d514 Compare January 27, 2020 19:15
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 27, 2020
@deads2k
Copy link
Contributor

deads2k commented Jan 27, 2020

I have to get to a computer to see, but this looks plausible.

/Approve

@sttts sttts force-pushed the sttts-oauth-implicit-audiences branch from 5e8d514 to 163c216 Compare January 27, 2020 20:15
@sttts
Copy link
Contributor Author

sttts commented Jan 27, 2020

Fixed the unit tests using the changed constructor.


auds := kauthenticator.Audiences(tokenAudiences).Intersect(requestedAudiences)
if len(auds) == 0 && len(a.implicitAuds) != 0 {
return nil, false, fmt.Errorf("token audiences %q is invalid for the target audiences %q", tokenAudiences, requestedAudiences)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll allow this because I think it will never happen, but the oidc example suggests return nil, false, nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's copied one-to-one from the service account authenticator.

@deads2k
Copy link
Contributor

deads2k commented Jan 27, 2020

/lgtm
/hold

holding on proof that the serial test is improve
/retest

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jan 27, 2020
@sttts
Copy link
Contributor Author

sttts commented Jan 27, 2020

/retest

@sttts
Copy link
Contributor Author

sttts commented Jan 27, 2020

GCP infra flakes

@marun
Copy link
Contributor

marun commented Jan 27, 2020

/retest

@marun
Copy link
Contributor

marun commented Jan 27, 2020

storage.go:100] error validating audience. want=["auth.openshift.io"] got=[]

@@ -55,6 +58,18 @@ func (a *tokenAuthenticator) AuthenticateToken(ctx context.Context, name string)
groupNames = append(groupNames, group.Name)
}

tokenAudiences := a.implicitAuds
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Consider simplifying:

    // Default to implicit audiences
    audiences := a.implicitAuds

    if len(a.implicitAuds) > 0 {
        // Only validate audiences when both implicit audiences and context-provided
        // audiences are present.

        requestedAudiences, ok := kauthenticator.AudiencesFrom(ctx)
        if ok {
            // Valid audiences for the token consist of the non-empty intersection
            // between the implicit and requested audiences.
            audiences = kauthenticator.Audiences(a.implicitAuds).Intersect(requestedAudiences)
            if len(audiences) == 0 {
                return nil, false, fmt.Errorf("token audiences %q is invalid for the target audiences %q", a.implicitAuds, requestedAudiences)
            }
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wanted to keep the structure of the service account authenticator

Copy link
Member

Choose a reason for hiding this comment

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

+1 to less nesting however visual-only that might appear

@marun
Copy link
Contributor

marun commented Jan 28, 2020

/retest

@marun
Copy link
Contributor

marun commented Jan 28, 2020

Now that #24458 was manually merged e2e-aws-serial should be capable of passing.

@marun
Copy link
Contributor

marun commented Jan 28, 2020

/retest

@marun
Copy link
Contributor

marun commented Jan 28, 2020

/retest

@sttts sttts force-pushed the sttts-oauth-implicit-audiences branch from 163c216 to 0d87344 Compare January 28, 2020 07:08
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2020
@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

#24458 merged to fix the imagetags issue.

Rebased.

@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

error validating audience. want=["auth.openshift.io"] got=[] is gone from the logs. So this PR fixes the TokenReview issue.

@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

/retest

GCP flakes

@stlaz
Copy link
Member

stlaz commented Jan 28, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2020
@stlaz
Copy link
Member

stlaz commented Jan 28, 2020

/test e2e-cmd

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, 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

@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

/retest

@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

/test e2e-cmd

@stlaz
Copy link
Member

stlaz commented Jan 28, 2020

/hold cancel
the serial test now passes

@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 Jan 28, 2020
@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

/retest

@sttts
Copy link
Contributor Author

sttts commented Jan 28, 2020

/ignore e2e-cmd

@mfojtik
Copy link
Member

mfojtik commented Jan 28, 2020

/override ci/prow/e2e-aws-serial
/override ci/prow/e2e-cmd
/override ci/prow/e2e-gcp
/override ci/prow/e2e-gcp-upgrade

@mfojtik
Copy link
Member

mfojtik commented Jan 28, 2020

force merging this as it make the queue stable again.

@openshift-ci-robot
Copy link

@mfojtik: Overrode contexts on behalf of mfojtik: ci/prow/e2e-aws-serial, ci/prow/e2e-cmd, ci/prow/e2e-gcp, ci/prow/e2e-gcp-upgrade

In response to this:

/override ci/prow/e2e-aws-serial
/override ci/prow/e2e-cmd
/override ci/prow/e2e-gcp
/override ci/prow/e2e-gcp-upgrade

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.

@mfojtik mfojtik merged commit 61dfe43 into openshift:master Jan 28, 2020
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 28, 2020

@sttts: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-cmd 0d87344 link /test e2e-cmd
ci/prow/e2e-aws-fips 0d87344 link /test e2e-aws-fips
ci/prow/e2e-gcp-upgrade 0d87344 link /test e2e-gcp-upgrade

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.

@deads2k
Copy link
Contributor

deads2k commented Jan 28, 2020

/retest

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/M Denotes a PR that changes 30-99 lines, ignoring generated files. vendor-update Touching vendor dir or related files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants