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

allow configurability of JWT claims that require a value #2888

Merged
merged 1 commit into from
May 18, 2020

Conversation

rnewson
Copy link
Member

@rnewson rnewson commented May 14, 2020

e.g;

[jwt]
required_claims = {iss, "hello"}

fixes #2886

Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

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

+1

Up to you on the config format.

"" ->
[];
Claims ->
{ok, Parsed} = couch_util:parse_term("[" ++ Claims ++ "]"),
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how much you care, but we don't usually mutate the value that we pass to parse_term (i.e., we require useres to add the square brackets in the config. Not sure if we care or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

the problem is 3.1.0 released with it being a comma-separate list of strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

I switched to a better format.

Copy link
Contributor

@jaydoane jaydoane left a comment

Choose a reason for hiding this comment

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

LGTM, and all relevant downstream tests pass.

Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

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

One ergonomic issue. Up to you if you think its a big deal as I don't know anything about jwt.

[list_to_existing_atom(C) || C <- List]
Re = "((?<key1>[a-z]+)|{(?<key2>[a-z]+)\s*,\s*\"(?<val>[^\"]+)\"})",
case re:run(Claims, Re, [global, {capture, [key1, key2, val], binary}]) of
nomatch ->
Copy link
Member

Choose a reason for hiding this comment

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

Seems like it'd be a good idea here to have a clause that notices when we are unable to match a configured value that's non-empty. Just something like nomatch when Claims /= "" -> log thing.

Copy link
Member

Choose a reason for hiding this comment

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

Why not mention claims in the http response? Seems odd to require folks to look in two places.

Copy link
Member Author

Choose a reason for hiding this comment

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

the user gets the http response, the admin gets the log message (who might also be the user). I didn't want to point at the specific misconfiguration to the user (who in this situation could be anyone, they might not have valid credentials). But I did want to mention that it's specific to JWT in case the user can use a different method, and so the admin has something more meaningful to report to user@ / github / etc.

Copy link
Member

Choose a reason for hiding this comment

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

fair, thanks for explaining!

@rnewson rnewson force-pushed the jwtf-iss-configurability branch 2 times, most recently from caaafb6 to ac5436d Compare May 18, 2020 17:23
Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

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

+1

@rnewson rnewson merged commit 4398d3b into master May 18, 2020
@rnewson rnewson deleted the jwtf-iss-configurability branch May 18, 2020 17:59
@gbshhennsi
Copy link

Hey guys, in which version of couchdb will you release this fix or when will I be able to use it?

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.

Error when marking the iss claim as required
5 participants