class Athena::Mercure::Bundle::Authorization
inherits Athena::Mercure::Authorization
#
Extension of AMC::Authorization to add support for AHTTP::Request.
Constructors#
.new(hub_registry : AMC::Hub::Registry, cookie_lifetime : Time::Span = 1.hour, cookie_samesite : ::HTTP::Cookie::SameSite = :strict)#
Methods#
#clear_cookie(request : AHTTP::Request, hub_name : String | Nil = nil) : Nil#
Clears the authorization cookie of the given hub_name.
#create_cookie(request : AHTTP::Request, grants : Array(AMC::Grant) | Array(String) | Hash(String, Array(String)) | String = [] of AMC::Grant, additional_claims : Hash | Nil = nil, hub_name : String | Nil = nil) : ::HTTP::Cookie#
Returns a Mercure auth cookie given the provided request and optionally for the provided hub_name.
The JWT cookie value by default does not have access to publish or subscribe to any topic.
Be sure to provide the grants it should have, such as the topics to subscribe to, or ["*"] to subscribe to all topics.
See AMC::Grant.from for the accepted shorthands.
additional_claims may also be used to define additional claims to the JWT if needed.
#set_cookie(request : AHTTP::Request, grants : Array(AMC::Grant) | Array(String) | Hash(String, Array(String)) | String = [] of AMC::Grant, additional_claims : Hash | Nil = nil, hub_name : String | Nil = nil) : Nil#
Sets the authorization cookie of the provided hub_name, see AMC::Hub::Interface#cookie_name.
The cookie is automatically applied to the AHTTP::Response via the Listeners::SetCookie listener.
The JWT cookie value by default does not have access to publish or subscribe to any topic.
Be sure to provide the grants it should have, such as the topics to subscribe to, or ["*"] to subscribe to all topics.
See AMC::Grant.from for the accepted shorthands.
additional_claims may also be used to define additional claims to the JWT if needed.