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

Add support for roles to be obtained from JWTs. #2694

Merged
merged 16 commits into from
Mar 24, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for roles to be obtained from JWTs.
  • Loading branch information
atrauzzi committed Mar 24, 2020
commit 0921af40ee64775d18cd2514281b829ff4c3a4e1
8 changes: 7 additions & 1 deletion src/couch/src/couch_httpd_auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ jwt_authentication_handler(Req) ->
case lists:keyfind(<<"sub">>, 1, Claims) of
false -> throw({unauthorized, <<"Token missing sub claim.">>});
{_, User} -> Req#httpd{user_ctx=#user_ctx{
name=User
name=User,
roles=case lists:keyfind(<<"roles">>, 1, Claims) of
atrauzzi marked this conversation as resolved.
Show resolved Hide resolved
false -> [];
{_, Roles} ->
erlang:display(Roles),
atrauzzi marked this conversation as resolved.
Show resolved Hide resolved
re:split(Roles, "\s*,\s*", [{return, binary}])
end
}}
end;
{error, Reason} ->
Expand Down