-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
There was a problem hiding this 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.
src/couch/src/couch_httpd_auth.erl
Outdated
"" -> | ||
[]; | ||
Claims -> | ||
{ok, Parsed} = couch_util:parse_term("[" ++ Claims ++ "]"), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
07854fa
to
459ef27
Compare
459ef27
to
0da9a0a
Compare
There was a problem hiding this 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 -> |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair, thanks for explaining!
caaafb6
to
ac5436d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
e.g; [jwt] required_claims = {iss, "https://example.com/issuer"}
ac5436d
to
4f7d1d9
Compare
Hey guys, in which version of couchdb will you release this fix or when will I be able to use it? |
e.g;
[jwt]
required_claims = {iss, "hello"}
fixes #2886