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

*: provide better feedback for invalid secrets #37

Open
mccutchen opened this issue Aug 25, 2018 · 0 comments
Open

*: provide better feedback for invalid secrets #37

mccutchen opened this issue Aug 25, 2018 · 0 comments
Labels
good first issue Good for newcomers papercuts frustrations to fix but not necessarily a bug

Comments

@mccutchen
Copy link
Contributor

TL;DR

If an invalid COOKIE_SECRET value is given, sso should provide guidance for how to generate a valid one rather than a cryptic error message. Bonus points for providing a separate sso-gen-secret binary that will Just Work!

Let's make it as easy as possible for users to generate good, secure secrets!

A bit more context

The error message sso gives for an invalid COOKIE_SECRET value takes this general form (for abcd as the secret value):

{"error":"Invalid configuration:\n  cookie_secret must be 32 or 64 bytes to create an AES cipher but is 4 bytes. note: cookie secret was base64 decoded from \"abcd\"","level":"error","msg":"error validating opts","service":"sso-authenticator","time":"2018-08-25 00:15:04.82512"}

But we still get an error message if we try a 32 byte secret (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx):

{"error":"Invalid configuration:\n  cookie_secret must be 32 or 64 bytes to create an AES cipher but is 24 bytes. note: cookie secret was base64 decoded from \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"","level":"error","msg":"error validating opts","service":"sso-authenticator","time":"2018-08-25 00:17:33.82512"}

Having dug into this a bit, I know that sso is trying to base64-decode the given secret value (that's why it reports a length of 24 bytes above), but, as I'll illustrate in a follow-up issue, it can be difficult to generate a valid secret even with this knowledge.

Working example

Here's one way that works, assuming python is available (note the use of urlsafe_b64encode, which seems to agree with the golang decoder used in sso):

python -c 'import base64, os, sys; sys.stdout.write(base64.urlsafe_b64encode(os.urandom(32)))'
@mccutchen mccutchen added good first issue Good for newcomers papercuts frustrations to fix but not necessarily a bug labels Aug 25, 2018
@mreiferson mreiferson changed the title Provide better feedback for invalid secrets sso-{auth,proxy}: provide better feedback for invalid secrets Nov 26, 2018
@mreiferson mreiferson changed the title sso-{auth,proxy}: provide better feedback for invalid secrets *: provide better feedback for invalid secrets Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers papercuts frustrations to fix but not necessarily a bug
Projects
None yet
Development

No branches or pull requests

1 participant