Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow modifying cookie settings #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ovalek
Copy link

@ovalek ovalek commented Jun 17, 2024

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

As mentioned in #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")

@michaelvanstraten
Copy link
Owner

Would passing an initial CookieBuilder also be fine with you? I think it should offer the same level of flexibility with a bit less exposure in the interface. Please speak out if you have a use case where a function is required; it could be that I don't see the full picture here.

@ovalek
Copy link
Author

ovalek commented Jun 28, 2024

As long as I can set path, http_only and same_site parameters for the refreshed access_token I'm fine with it. I added new commit that adds bare CookieBuilder as a parameter. The Cookie::build method requires name and value, that have to be overriden. The builder doesn't have methods to set name/value, so I set these on the final Cookie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants