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

Instead of showing server errors, show social_core.exceptions texts in login UI #17982

Open
julianstolp opened this issue Nov 11, 2024 · 0 comments
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: feature Introduction of new functionality to the application

Comments

@julianstolp
Copy link

NetBox version

v4.1.6

Feature type

Change to existing functionality

Triage priority

N/A

Proposed functionality

Currently, exceptions from social_core.exceptions result in a server error. Ideally, the error message should be in the same text boxes as the current login error messages.

As an example here NetBox vs. Grafana with configured SSO with Authelia as OpenID Connect provider. Both logins were rejected by the user in Authelia.

Internal Server Error: /oauth/complete/oidc/

AuthCanceled at /oauth/complete/oidc/
Authentication process canceled: The resource owner or authorization server denied the request. Make sure that the request you are making is valid. Maybe the credential or request parameters you are using are limited in scope or otherwise restricted.

Request Method: GET
Request URL: [...]
Django Version: 5.0.9
Python Executable: venv/bin/python
Python Version: 3.12.3
Python Path: ['.', '', '/opt/netbox/venv/bin', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/opt/netbox/venv/lib/python3.12/site-packages']
Server time: Mon, 11 Nov 2024 10:43:45 +0100

[...]

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_django/utils.py", line 49, in wrapper
    return func(request, backend, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_django/views.py", line 31, in complete
    return do_complete(
          
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_core/actions.py", line 49, in do_complete
    user = backend.complete(user=user, redirect_name=redirect_name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_core/backends/base.py", line 39, in complete
    return self.auth_complete(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_core/utils.py", line 253, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_core/backends/oauth.py", line 410, in auth_complete
    self.process_error(self.data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/social_core/backends/oauth.py", line 402, in process_error
    raise AuthCanceled(self, data.get("error_description", ""))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: AuthCanceled at /oauth/complete/oidc/
Exception Value: Authentication process canceled: The resource owner or authorization server denied the request. Make sure that the request you are making is valid. Maybe the credential or request parameters you are using are limited in scope or otherwise restricted.
Raised during: social_django.views.complete
Request information:
USER: AnonymousUser

GET:
error = 'access_denied'
error_description = 'The resource owner or authorization server denied the request. Make sure that the request you are making is valid. Maybe the credential or request parameters you are using are limited in scope or otherwise restricted.'
iss = [...]
state = 'CIItvG532lO7Aj28x9vadobtw6JeWReI'

image

Use case

  • Removal of an unnecessary server error
  • Cleaner UI for users

Database changes

No

External dependencies

No

@julianstolp julianstolp added status: needs triage This issue is awaiting triage by a maintainer type: feature Introduction of new functionality to the application labels Nov 11, 2024
@bctiemann bctiemann added complexity: medium Requires a substantial but not unusual amount of effort to implement status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Nov 12, 2024 — with Linear
@bctiemann bctiemann removed the status: needs triage This issue is awaiting triage by a maintainer label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants