class Athena::MercureBundle::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 mercureAuthorization cookie for the given hub_name.
#create_cookie(request : AHTTP::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 : AHTTP::Request, subscribe : Array(String) | Nil = [] of String, publish : Array(String) | Nil = [] of String, additional_claims : Hash | Nil = nil, hub_name : String | Nil = nil) : Nil#
Sets the mercureAuthorization cookie for the provided hub_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 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.