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

Closed
opened 2025-12-29 21:31:51 +01:00 by adam · 2 comments
Owner

Originally created by @julianstolp on GitHub (Nov 11, 2024).

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

Originally created by @julianstolp on GitHub (Nov 11, 2024). ### 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](https://github.com/user-attachments/assets/29039c1e-670b-4062-bc9c-194afa4bdc48) ### Use case - Removal of an unnecessary server error - Cleaner UI for users ### Database changes No ### External dependencies No
adam added the type: featurestatus: needs ownerpending closurecomplexity: medium labels 2025-12-29 21:31:51 +01:00
adam closed this issue 2025-12-29 21:31:52 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Apr 25, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Apr 25, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (May 25, 2025):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (May 25, 2025): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10465