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

Fix cookie name in passcode handler #1625

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

loeffert
Copy link

Description

Use configured cookie name in passcode handler. Fixes #1624

uses configured cookie name in passcode handler
@@ -453,7 +452,7 @@ func (h *PasscodeHandler) Finish(c echo.Context) error {

func (h *PasscodeHandler) GetSessionToken(c echo.Context) jwt.Token {
var token jwt.Token
sessionCookie, _ := c.Cookie("hanko")
sessionCookie, _ := c.Cookie(h.cfg.Session.Cookie.GetName())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FreddyDevelop how can we handle the errors here? all errors in GetSessionToken are ignored. They should be logged at least. What is the best way to get a logger instance here?

That would have helped to faster find that bug, because the accessed cookie doesn't exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not log the error, that a cookie is missing, because the session token can also be send within the Authorization header and when the error gets logged then we would clutter the logs with unnecessary messages.

Only solution to that would be to log that errors only when no token can be returned. You can use zerolog for the logging. An example can be found at:

zeroLogger.Warn().Err(err).Msg("failed to trigger webhook")

@loeffert loeffert changed the title fixes teamhanko/hanko#1624 Fix cookie name in passcode handler Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

Self-Hosted hanko with session cookie name does not allow to add additional email addresses
3 participants