diff options
author | Alexander Trauzzi <atrauzzi@gmail.com> | 2020-03-24 14:38:20 -0500 |
---|---|---|
committer | Alexander Trauzzi <atrauzzi@gmail.com> | 2020-03-24 14:38:20 -0500 |
commit | 3523c817c903a4fb033a19808d63514754b77194 (patch) | |
tree | 846cf02990ba18f61203b0d15060e47549ba4b44 | |
parent | 1890168af11fec4dff6126991d29a4eedb793ca9 (diff) | |
download | couchdb-3523c817c903a4fb033a19808d63514754b77194.tar.gz |
Rename the claim used for roles to be more CouchDB specific.
-rw-r--r-- | src/couch/src/couch_httpd_auth.erl | 2 | ||||
-rw-r--r-- | 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 4ad205255..43fb4161c 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 dc3d27df4..de5b3e65d 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", "couch@apache.org"}, {"roles", ["testing"]}]}, key) + {:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub", "couch@apache.org"}, {"_couchdb.roles", ["testing"]}]}, key) resp = Couch.get("/_session", headers: [authorization: "Bearer #{token}"] |