Updated JWT README content.

This commit is contained in:
2018-10-29 15:17:31 +01:00
parent 45179b58a3
commit 8241c0209a

View File

@@ -2,25 +2,34 @@ JSON Web Token (JWT)
http://jwt.io/
Note: supporting only HS256 and none algorithm for signature.
Note: supporting only HS256 and none algorithm for signature, but could be extend with your own algorithm via `JWT_ALGORITHMS` (see `JWT.algorithms`, and `JWT_LOADER.algorithms`).
# How to use
```eiffel
example
local
jwt: JWT
jwt: JWS
tok: STRING
l_loader: JWT_LOADER
do
create jwt
tok := jwt.encoded_string ("[
create jwt.make_with_json_payload ("[
{"iss":"joe", "exp":1200819380,"http://example.com/is_root":true}
]", "secret", "HS256")
]")
jwt.set_algorithm_to_hs256
tok := jwt.encoded_string ("my-secret")
create l_loader
if
attached jwt.decoded_string (tok, "secret", Void) as l_tok_payload and
not jwt.has_error
attached l_loader.token (tok, Void, "my-secret", Void) as l_tok and then
not l_tok.has_error
then
check verified: not jwt.has_unverified_token_error end
check no_error: not jwt.has_error end
print (l_tok_payload)
print (l_tok.claimset.string)
check verified: not l_tok.has_unverified_token_error end
check no_error: not l_tok.has_error end
end
end
end
```