class Athena::Mercure::TokenFactory::DefaultClaims
inherits Reference
#
Decorates a token factory, adding the provided default_claims to every token it creates, unless the claim is provided when creating the token.
Useful for claims every token of a hub requires, such as iss, sub, client_id, and aud under the Mercure protocol 1.0, so code creating tokens indirectly, such as AMC::Authorization, does not need to repeat them.
Included modules
Athena::Mercure::TokenFactory::Interface
Constructors#
.new(decorated : AMC::TokenFactory::Interface, default_claims : Hash(String, String | Array(String)))#
Methods#
#create(grants : Array(AMC::Grant) = [] of AMC::Grant, additional_claims : Hash | Nil = nil) : String#
Returns a JWT token that is allowed the provided grants, such as to subscribe or publish to some topics. Optionally, additional_claims may be added to the JWT.