class Athena::Mercure::Authorization
inherits Reference
#
Helper class for adding the Mercure authorization cookie to an HTTP response in order to enable private updates. See Authorization for more information.
Constructors#
.new(hub_registry : AMC::Hub::Registry, cookie_lifetime : Time::Span = 1.hour, cookie_samesite : HTTP::Cookie::SameSite = :strict)#
Methods#
#clear_cookie(request : HTTP::Request, response : HTTP::Server::Response, hub_name : String | Nil = nil) : Nil#
Clears the Mercure cookie from the provided response, optionally for the provided hub.
#create_cookie(request : HTTP::Request, subscribe : Array(String) | Nil = [] of String, publish : Array(String) | Nil = [] of String, 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 set the subscribe and publish arrays to the topics you want it to be able to interact with, or ["*"] to handle all topics.
additional_claims may also be used to define additional claims to the JWT if needed.
#set_cookie(request : HTTP::Request, response : HTTP::Server::Response, subscribe : Array(String) | Nil = [] of String, publish : Array(String) | Nil = [] of String, additional_claims : Hash | Nil = nil, hub_name : String | Nil = nil)#
Sets the mercureAuthorization cookie on the provided response given the provided request, optionally for the provided hub.
The JWT cookie value by default does not have access to publish or subscribe to any topic.
Be sure to set the subscribe and publish arrays to the topics you want it to be able to interact with, or ["*"] to handle all topics.
additional_claims may also be used to define additional claims to the JWT if needed.