-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Downgrade some OIDC exceptions to warnings #12723
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Downgrade some OIDC errors to warnings in the logs, to reduce the noise of Sentry reports. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,7 +224,7 @@ async def handle_oidc_callback(self, request: SynapseRequest) -> None: | |
self._sso_handler.render_error(request, "invalid_session", str(e)) | ||
return | ||
except MacaroonInvalidSignatureException as e: | ||
logger.exception("Could not verify session for OIDC callback") | ||
logger.warning("Could not verify session for OIDC callback: %s", e) | ||
self._sso_handler.render_error(request, "mismatching_session", str(e)) | ||
return | ||
|
||
|
@@ -827,7 +827,7 @@ async def handle_oidc_callback( | |
logger.debug("Exchanging OAuth2 code for a token") | ||
token = await self._exchange_code(code) | ||
except OidcError as e: | ||
logger.exception("Could not exchange OAuth2 code") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one can be an indicator of a misconfiguration, or just happen if there is a problem communicating to the IdP? It should not be that common (or we have other things to worry about) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at Sentry, it happens a lot because codes get exchanged twice, which could happen if that callback handler is loaded multiple times. So it's probably safe to ignore in most cases, but useful to log when OIDC is being setup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll still log this as a warning with the proposed change: |
||
logger.warning("Could not exchange OAuth2 code: %s", e) | ||
self._sso_handler.render_error(request, e.error, e.error_description) | ||
return | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the signature on the macaroon was wrong, so either the server just rotated their macaroon secret, or they have something really wrong in their setup (like different workers not sharing the same secret). I would probably keep this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still kept as a warning. Is the traceback useful to a server operator?
With the proposed change, we would log the message
Invalid session for OIDC callback: Signatures do not match
as a warning.I could throw in the name of e's class (i.e.
Invalid session for OIDC callback - MacaroonInvalidSingatureException: Signatures do not match
) if that's clearer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks fine to me 👍