12
113
Fork
You've already forked django-allauth
149

fix(steam): error handling during OpenID discovery #4616

Merged
pennersr merged 1 commit from beheh/django-allauth:steam-provider-fixes into main 2025年11月27日 10:29:58 +01:00
Contributor
Copy link

This is a small follow-up to 050d8f8def:

After using a custom Steam provider with the new redirect method, we discovered some missing exception handling that OpenIDLoginVew.perform_openid_auth handles. I've borrowed the exception handling code from the perform_openid_auth method.

No changelog entry should be required, as the commit issue that introduced this issue has not been released yet.

The exceptions we get without this change look like this:

Traceback (most recent call last):
 File "django/core/handlers/exception.py", line 55, in inner
 response = get_response(request)
 File "django/core/handlers/base.py", line 197, in _get_response
 response = wrapped_callback(request, *callback_args, **callback_kwargs)
 File "allauth/headless/internal/decorators.py", line 47, in _wrapper_view
 return view_func(request, *args, **kwargs)
 File "django/views/generic/base.py", line 105, in view
 return self.dispatch(request, *args, **kwargs)
 File "allauth/headless/base/views.py", line 27, in dispatch
 return super().dispatch(request, *args, **kwargs)
 File "allauth/headless/internal/restkit/views.py", line 17, in dispatch
 return self.handle(request, *args, **kwargs)
 File "allauth/headless/internal/restkit/views.py", line 25, in handle
 return super().dispatch(request, *args, **kwargs)
 File "django/views/generic/base.py", line 144, in dispatch
 return handler(request, *args, **kwargs)
 File "allauth/headless/socialaccount/views.py", line 68, in post
 return provider.redirect(
 File "<redacted>/providers/steam/provider.py", line <redacted>, in redirect
 auth_request = client.begin(endpoint)
 File "openid/consumer/consumer.py", line 351, in begin
 service = disco.getNextService(self._discover)
 File "openid/yadis/manager.py", line 106, in getNextService
 yadis_url, services = discover(self.url)
 File "openid/consumer/discover.py", line 467, in discover
 return discoverURI(identifier)
 File "openid/consumer/discover.py", line 458, in discoverURI
 claimed_id, openid_services = discoverYadis(uri)
 File "openid/consumer/discover.py", line 383, in discoverYadis
 response = yadisDiscover(uri)
 File "openid/yadis/discover.py", line 77, in discover
 raise DiscoveryFailure(
DiscoveryFailure: HTTP Response status from identity URL host is not 200. Got status 502

Submitting Pull Requests

General

  • Make sure you use semantic commit messages.
    Examples: "fix(google): Fixed foobar bug", "feat(accounts): Added foobar feature".
  • All Python code must formatted using Black, and clean from pep8 and isort issues.
  • JavaScript code should adhere to StandardJS.
  • If your changes are significant, please update ChangeLog.rst.
  • If your change is substantial, feel free to add yourself to AUTHORS.

Provider Specifics

In case you add a new provider:

  • Make sure unit tests are available.
  • Ensure your provider is tested by adding an entry over at tests/projects/common/settings.py::INSTALLED_SOCIALACCOUNT_APPS.
  • Provide provider specific documentation at docs/socialaccount/providers/<provider name>.rst.
  • Link to your provider specific documentation at docs/insocialaccount/providers/index.rst.
  • Add an entry for your provider in the quickstart, over at docs/installation/quickstart.rst::INSTALLED_APPS.
This is a small follow-up to 050d8f8defdeec82a01cb46c296ee3d9afa783f0: After using a custom Steam provider with the new `redirect` method, we discovered some missing exception handling that `OpenIDLoginVew.perform_openid_auth` handles. I've borrowed the exception handling code from the `perform_openid_auth` method. No changelog entry should be required, as the commit issue that introduced this issue has not been released yet. The exceptions we get without this change look like this: ``` Traceback (most recent call last): File "django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "allauth/headless/internal/decorators.py", line 47, in _wrapper_view return view_func(request, *args, **kwargs) File "django/views/generic/base.py", line 105, in view return self.dispatch(request, *args, **kwargs) File "allauth/headless/base/views.py", line 27, in dispatch return super().dispatch(request, *args, **kwargs) File "allauth/headless/internal/restkit/views.py", line 17, in dispatch return self.handle(request, *args, **kwargs) File "allauth/headless/internal/restkit/views.py", line 25, in handle return super().dispatch(request, *args, **kwargs) File "django/views/generic/base.py", line 144, in dispatch return handler(request, *args, **kwargs) File "allauth/headless/socialaccount/views.py", line 68, in post return provider.redirect( File "<redacted>/providers/steam/provider.py", line <redacted>, in redirect auth_request = client.begin(endpoint) File "openid/consumer/consumer.py", line 351, in begin service = disco.getNextService(self._discover) File "openid/yadis/manager.py", line 106, in getNextService yadis_url, services = discover(self.url) File "openid/consumer/discover.py", line 467, in discover return discoverURI(identifier) File "openid/consumer/discover.py", line 458, in discoverURI claimed_id, openid_services = discoverYadis(uri) File "openid/consumer/discover.py", line 383, in discoverYadis response = yadisDiscover(uri) File "openid/yadis/discover.py", line 77, in discover raise DiscoveryFailure( DiscoveryFailure: HTTP Response status from identity URL host is not 200. Got status 502 ``` # Submitting Pull Requests ## General - [x] Make sure you use [semantic commit messages](https://seesparkbox.com/foundry/semantic_commit_messages). Examples: `"fix(google): Fixed foobar bug"`, `"feat(accounts): Added foobar feature"`. - [x] All Python code must formatted using Black, and clean from pep8 and isort issues. - [ ] JavaScript code should adhere to [StandardJS](https://standardjs.com). - [ ] If your changes are significant, please update `ChangeLog.rst`. - [ ] If your change is substantial, feel free to add yourself to `AUTHORS`. ## Provider Specifics In case you add a new provider: - [ ] Make sure unit tests are available. - [ ] Ensure your provider is tested by adding an entry over at `tests/projects/common/settings.py::INSTALLED_SOCIALACCOUNT_APPS`. - [ ] Provide provider specific documentation at `docs/socialaccount/providers/<provider name>.rst`. - [ ] Link to your provider specific documentation at `docs/insocialaccount/providers/index.rst`. - [ ] Add an entry for your provider in the quickstart, over at `docs/installation/quickstart.rst::INSTALLED_APPS`.
Author
Contributor
Copy link

(削除) I'm also aware of another similar case in the SteamCallbackView, where client.begin can throw when the user-supplied parameters are invalid. Not sure if you also want that here, on in a separate PR. (削除ここまで)

Actually, nevermind, I believe that should happen on the openid provider level, so I'll create a separate PR for that: #4617

~~I'm also aware of another similar case in the `SteamCallbackView`, where `client.begin` can throw when the user-supplied parameters are invalid. Not sure if you also want that here, on in a separate PR.~~ Actually, nevermind, I believe that should happen on the `openid` provider level, so I'll create a separate PR for that: #4617
beheh changed title from (削除) fix(steam): error handling during OpenID discovery (削除ここまで) to wip: fix(steam): error handling during OpenID discovery 2025年11月26日 14:43:28 +01:00
Author
Contributor
Copy link

I'll still add a test for this.

I'll still add a test for this.
beheh force-pushed steam-provider-fixes from 0323dadfee
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to 86d29848f5
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
2025年11月26日 14:55:02 +01:00
Compare
beheh force-pushed steam-provider-fixes from 86d29848f5
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to bf4c4fc164
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
2025年11月26日 14:59:34 +01:00
Compare
beheh force-pushed steam-provider-fixes from bf4c4fc164
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to 9ae05290d2
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
2025年11月26日 15:05:11 +01:00
Compare
beheh force-pushed steam-provider-fixes from 9ae05290d2
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to 0e9913045d
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
2025年11月26日 15:06:20 +01:00
Compare
beheh force-pushed steam-provider-fixes from 0e9913045d
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to 8bb2535267
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
2025年11月26日 15:10:13 +01:00
Compare
beheh changed title from (削除) wip: fix(steam): error handling during OpenID discovery (削除ここまで) to WIP: wip: fix(steam): error handling during OpenID discovery 2025年11月26日 15:14:31 +01:00
beheh changed title from (削除) WIP: wip: fix(steam): error handling during OpenID discovery (削除ここまで) to fix(steam): error handling during OpenID discovery 2025年11月26日 15:14:41 +01:00
Author
Contributor
Copy link

Okay, I've added two basic tests for the steam provider. I think that's appropriate, as the generic openid provider doesn't have redirect.

Okay, I've added two basic tests for the steam provider. I think that's appropriate, as the generic openid provider doesn't have `redirect`.
beheh force-pushed steam-provider-fixes from 8bb2535267
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to 2137d14cec
All checks were successful
ci/woodpecker/pr/woodpecker/1 Pipeline was successful
ci/woodpecker/pr/woodpecker/2 Pipeline was successful
2025年11月26日 19:47:58 +01:00
Compare
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
allauth/django-allauth!4616
Reference in a new issue
allauth/django-allauth
No description provided.
Delete branch "beheh/django-allauth:steam-provider-fixes"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?