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

Don't fallback to cert when given invalid token #9617

Merged
merged 2 commits into from
Jul 2, 2016

Conversation

enj
Copy link
Contributor

@enj enj commented Jun 28, 2016

Fixes #4537

There are three variations for both token and cert: valid, invalid and not provided. This gives a total of nine combinations. The only combination that this PR changes is with an invalid token and a valid cert. The old behavior would authenticate using the cert; the new behavior considers this an error.

Both implementations currently return the anonymous user when no token and an invalid cert are provided. It is unclear if this is the correct behavior or if an error should be returned instead.

@@ -359,7 +361,7 @@ func newAuthenticator(config configapi.MasterConfig, restOptionsGetter restoptio
publicKeys = append(publicKeys, publicKey)
}
tokenAuthenticator := serviceaccount.JWTTokenAuthenticator(publicKeys, true, tokenGetter)
Copy link
Contributor

Choose a reason for hiding this comment

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

for sanity, name the local vars something specific like serviceAccountTokenAuthenticator here, or oauthTokenAuthenticator/oauthTokenRequestAuthenticators below

@enj enj force-pushed the dev/enj/issues/4537 branch from 6352c52 to a762701 Compare June 28, 2016 22:40
@enj
Copy link
Contributor Author

enj commented Jun 28, 2016

@liggitt I made the requested changes.

// token: noToken,
// cert: invalidCert,
// errorExpected: true,
// errorString: anonymousError, // TODO should this be unauthorizedError?
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 unauthorized error once we figure out how to actually test the scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@enj enj force-pushed the dev/enj/issues/4537 branch from a762701 to 4034c6f Compare June 28, 2016 23:19
@liggitt
Copy link
Contributor

liggitt commented Jun 29, 2016

[test]

@enj
Copy link
Contributor Author

enj commented Jun 29, 2016

Flake? [test]

@enj
Copy link
Contributor Author

enj commented Jun 29, 2016

@liggitt No idea why that test failed, it works fine locally.

@liggitt
Copy link
Contributor

liggitt commented Jun 30, 2016

flake on #9638
[test]

defer os.RemoveAll(fakecadir)
cacerts, err := util.CertificatesFromFile(masterOptions.ServingInfo.ClientCA)
if err != nil || len(cacerts) != 1 {
t.Fatalf("Unexpected error: %v", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically this could give an incorrect error message when err == nil but len(cacerts) != 1.

@enj enj force-pushed the dev/enj/issues/4537 branch from 2388cee to a9fe20d Compare July 1, 2016 15:05
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to a9fe20d

@liggitt
Copy link
Contributor

liggitt commented Jul 1, 2016

LGTM, [merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jul 1, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/5731/) (Image: devenv-rhel7_4509)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to a9fe20d

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/5689/)

@openshift-bot openshift-bot merged commit 95bfdd3 into openshift:master Jul 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants