actix-jwt-auth-middleware icon indicating copy to clipboard operation
actix-jwt-auth-middleware copied to clipboard

allow modifying cookie settings

Open ovalek opened this issue 8 months ago • 2 comments

Allow modifying cookie settings by passing closure with CookieBuilder to cookie_adjust in TokenSigner builder.

As mentioned in https://github.com/michaelvanstraten/actix-jwt-auth-middleware/issues/24, we could change cookie settings when creating the initial access_token or refresh_token, but we couldn't easily change the access_token when it is refreshed. This PR allows to adjust cookie settings (e.g. Path) as follows using cookie_adjust():

TokenSigner::new()
    .signing_key(key.clone())
    .algorithm(Hs256)
    .cookie_adjust(|builder: CookieBuilder| builder.path("/"))
    .build()
    .expect("Error: Could not create a TokenSigner")

ovalek avatar Jun 17 '24 02:06 ovalek