sources/oauth: Fix an issue where wechat may crash duing login. (cherry-pick #18973 to version-2025.12)#19854
Conversation
* Fix an issue where wechat may crash duing login. The WeChatOAuth2Client.get_access_token method was defined with a signature that required redirect_uri and code arguments, but the generic OAuth callback handler calls this method without any arguments (expecting the client to retrieve them from the request context). I have fixed authentik/sources/oauth/types/wechat.py by: Updating get_access_token signature: It now accepts **request_kwargs instead of mandatory positional arguments, matching the base OAuth2Client . Retrieving code correctly: It now looks for code in the request parameters using self.get_request_arg, just like standard OAuth clients. Adding State Validation: I added self.check_application_state() to ensure the state parameter matches, preventing CSRF attacks. Improving Error Handling: Both get_access_token and get_profile_info now return None (or error dicts) instead of raising exceptions when API calls fail. This prevents the "Server Error" (500) crashes you were seeing and allows Authentik to handle login failures gracefully. Signed-off-by: Anduin Xue <anduin@aiursoft.com> * Update wechat.py Signed-off-by: Anduin Xue <anduin@aiursoft.com> * Update wechat.py Signed-off-by: Anduin Xue <anduin@aiursoft.com> * Remove unnecessary blank lines in wechat.py Signed-off-by: Anduin Xue <anduin@aiursoft.com> * Fix linting issues in wechat.py --------- Signed-off-by: Anduin Xue <anduin@aiursoft.com> Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## version-2025.12 #19854 +/- ##
===================================================
- Coverage 93.26% 93.26% -0.01%
===================================================
Files 947 947
Lines 52356 52369 +13
===================================================
+ Hits 48831 48840 +9
- Misses 3525 3529 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-0e3c8c27b01bb7366999160dc16f9a4e0523a1a6
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-0e3c8c27b01bb7366999160dc16f9a4e0523a1a6Afterwards, run the upgrade commands from the latest release notes. |
Cherry-pick of #18973 to
version-2025.12branch.Original PR: #18973
Original Author: @Anduin2017
Cherry-picked commit: e01d7f2