auth_plug v0.8.0 AuthPlug.Token
Token module to create and validate jwt. see https://hexdocs.pm/joken/configuration.html#module-approach
Link to this section Summary
Functions
create_signer/1
creates a signer for the given secret
key.
It uses the HS256 (HMAC with SHA-256) to generate the signature.
if you're wondering what "HS256" is, read:
community.auth0.com/t/jwt-signing-algorithms-rs256-vs-hs256/7720
Combines generate_claims/1
and encode_and_sign/2
Same as generate_and_sign/2
but raises if error
generate_jwt!/1
invokes Joken.generate_and_sign/3
claims are the data to be signed.
Throws an error if anyting in the claims is invalid.
generate_jwt!/2
invokes Joken.generate_and_sign/3
claims
are the data to be signed and secret
is the secret key.
Combines verify/2
and validate/1
Same as verify_and_validate/2
but raises if error
verify_jwt/1
verifies the given JWT and returns {:ok, claims}
where the claims are the original data that were signed.
verify_jwt/2
verifies the given JWT and secret.
Returns {:ok, claims} where the claims are the original data that were signed.
verify_jwt!/1
verifies the given JWT and returns claims
where the claims are the original data that were signed.
verify_jwt!/2
verifies the given JWT and returns claims
where the token
is the JWT that was signed secret
is the secret key.
Returns claims
the original claims contained in the JWT.
Link to this section Functions
create_signer(secret)
create_signer/1
creates a signer for the given secret
key.
It uses the HS256 (HMAC with SHA-256) to generate the signature.
if you're wondering what "HS256" is, read:
community.auth0.com/t/jwt-signing-algorithms-rs256-vs-hs256/7720
generate_and_sign(extra_claims \\ %{}, key \\ __default_signer__())
generate_and_sign(Joken.claims(), Joken.signer_arg()) :: {:ok, Joken.bearer_token(), Joken.claims()} | {:error, Joken.error_reason()}
Combines generate_claims/1
and encode_and_sign/2
generate_and_sign!(extra_claims \\ %{}, key \\ __default_signer__())
generate_and_sign!(Joken.claims(), Joken.signer_arg()) :: Joken.bearer_token() | no_return()
Same as generate_and_sign/2
but raises if error
generate_jwt!(claims)
generate_jwt!/1
invokes Joken.generate_and_sign/3
claims are the data to be signed.
Throws an error if anyting in the claims is invalid.
generate_jwt!(claims, secret)
generate_jwt!/2
invokes Joken.generate_and_sign/3
claims
are the data to be signed and secret
is the secret key.
verify_and_validate(bearer_token, key \\ __default_signer__(), context \\ %{})
verify_and_validate(Joken.bearer_token(), Joken.signer_arg(), term()) :: {:ok, Joken.claims()} | {:error, Joken.error_reason()}
Combines verify/2
and validate/1
verify_and_validate!(bearer_token, key \\ __default_signer__(), context \\ %{})
verify_and_validate!(Joken.bearer_token(), Joken.signer_arg(), term()) :: Joken.claims() | no_return()
Same as verify_and_validate/2
but raises if error
verify_jwt(token)
verify_jwt/1
verifies the given JWT and returns {:ok, claims}
where the claims are the original data that were signed.
verify_jwt(token, secret)
verify_jwt/2
verifies the given JWT and secret.
Returns {:ok, claims} where the claims are the original data that were signed.
verify_jwt!(token)
verify_jwt!/1
verifies the given JWT and returns claims
where the claims are the original data that were signed.
verify_jwt!(token, secret)
verify_jwt!/2
verifies the given JWT and returns claims
where the token
is the JWT that was signed secret
is the secret key.
Returns claims
the original claims contained in the JWT.