-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for roles to be obtained from JWTs. (#2694)
Add support for roles to be obtained from JWTs
- Loading branch information
Showing
2 changed files
with
4 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,13 +103,14 @@ defmodule JwtAuthTest do | |
end | ||
|
||
def test_fun(alg, key) do | ||
{:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub", "[email protected]"}]}, key) | ||
{:ok, token} = :jwtf.encode({[{"alg", alg}, {"typ", "JWT"}]}, {[{"sub", "[email protected]"}, {"roles", ["testing"]}]}, key) | ||
|
||
resp = Couch.get("/_session", | ||
headers: [authorization: "Bearer #{token}"] | ||
) | ||
|
||
assert resp.body["userCtx"]["name"] == "[email protected]" | ||
assert resp.body["userCtx"]["roles"] == ["testing"] | ||
assert resp.body["info"]["authenticated"] == "jwt" | ||
end | ||
|
||
|