This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 3523c81 Rename the claim used for roles to be more CouchDB specific.
new 2b95500 Merge pull request #2714 from
atrauzzi/jwt-couchdb-specific-roles-claim
3523c81 is described below
commit 3523c817c903a4fb033a19808d63514754b77194
Author: Alexander Trauzzi <[email protected]>
AuthorDate: Tue Mar 24 14:38:20 2020 -0500
Rename the claim used for roles to be more CouchDB specific.
---
src/couch/src/couch_httpd_auth.erl | 2 +-
test/elixir/test/jwtauth_test.exs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/couch/src/couch_httpd_auth.erl
b/src/couch/src/couch_httpd_auth.erl
index 4ad2052..43fb416 100644
--- a/src/couch/src/couch_httpd_auth.erl
+++ b/src/couch/src/couch_httpd_auth.erl
@@ -199,7 +199,7 @@ jwt_authentication_handler(Req) ->
false -> throw({unauthorized, <<"Token missing sub
claim.">>});
{_, User} -> Req#httpd{user_ctx=#user_ctx{
name = User,
- roles = couch_util:get_value(<<"roles">>, Claims,
[])
+ roles = couch_util:get_value(<<"_couchdb.roles">>,
Claims, [])
}}
end;
{error, Reason} ->
diff --git a/test/elixir/test/jwtauth_test.exs
b/test/elixir/test/jwtauth_test.exs
index dc3d27d..de5b3e6 100644
--- a/test/elixir/test/jwtauth_test.exs
+++ b/test/elixir/test/jwtauth_test.exs
@@ -103,7 +103,7 @@ defmodule JwtAuthTest do
end
def test_fun(alg, key) do
- {:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub",
"[email protected]"}, {"roles", ["testing"]}]}, key)
+ {:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub",
"[email protected]"}, {"_couchdb.roles", ["testing"]}]}, key)
resp = Couch.get("/_session",
headers: [authorization: "Bearer #{token}"]