Lightning.Workers.RunToken (Lightning v2.19.0-pre)

View Source

JWT token configuration to verify if workers work is legit.

Verify run tokens through Lightning.Workers.verify_run_token/2, never through verify_and_validate/3 here. Joken looks up a validator per claim the token carries, so the exp and sub checks below do not run for a token that simply omits them; verify_run_token/2 is where the claims are required to be present, and so is the only place those two checks bind.

Summary

Functions

generate_and_sign(extra_claims \\ %{}, key \\ __default_signer__())

@spec 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__())

@spec generate_and_sign!(Joken.claims(), Joken.signer_arg()) :: Joken.bearer_token()

Same as generate_and_sign/2 but raises if error

verify_and_validate(bearer_token, key \\ __default_signer__(), context \\ %{})

@spec verify_and_validate(Joken.bearer_token(), Joken.signer_arg(), term()) ::
  {:ok, Joken.claims()} | {:error, Joken.error_reason()}

Combines verify/2 and validate/2

verify_and_validate!(bearer_token, key \\ __default_signer__(), context \\ %{})

@spec verify_and_validate!(Joken.bearer_token(), Joken.signer_arg(), term()) ::
  Joken.claims()

Same as verify_and_validate/2 but raises if error