Skip to content

Commit 4a5bb81

Browse files
Merge branch 'bugfix' into implement_oidc_groups
2 parents 975135c + 2b54bbb commit 4a5bb81

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

docs/content/supported_tools/parsers/file/nancy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This parser expects a JSON file.
1616
Sample Nancy scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/nancy).
1717

1818
### Link To Tool
19-
See Nancy on GitHub: https://github.com/sonatype-nexus-community/nancy
19+
See Nancy on [Github](https://github.com/sonatype-nexus-community/nancy)
2020

2121
### Default Deduplication Hashcode Fields
2222
By default, DefectDojo identifies duplicate Findings using these [hashcode fields](https://docs.defectdojo.com/en/working_with_findings/finding_deduplication/about_deduplication/):

dojo/middleware.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,23 @@ def __call__(self, request):
8383
class CustomSocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware):
8484
def process_exception(self, request, exception):
8585
if isinstance(exception, requests.exceptions.RequestException):
86-
messages.error(request, "Please use the standard login below.")
86+
messages.error(request, settings.SOCIAL_AUTH_EXCEPTION_MESSAGE_REQUEST_EXCEPTION)
8787
return redirect("/login?force_login_form")
8888
if isinstance(exception, AuthCanceled):
89-
messages.warning(request, "Social login was canceled. Please try again or use the standard login.")
89+
messages.warning(request, settings.SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_CANCELED)
9090
return redirect("/login?force_login_form")
9191
if isinstance(exception, AuthFailed):
92-
messages.error(request, "Social login failed. Please try again or use the standard login.")
92+
messages.error(request, settings.SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FAILED)
9393
return redirect("/login?force_login_form")
9494
if isinstance(exception, AuthForbidden):
95-
messages.error(request, "You are not authorized to log in via this method. Please contact support or use the standard login.")
95+
messages.error(request, settings.SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FORBIDDEN)
9696
return redirect("/login?force_login_form")
9797
if isinstance(exception, AuthTokenError):
98-
messages.error(request, "Social login failed due to an invalid or expired token. Please try again or use the standard login.")
98+
messages.error(request, settings.SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_TOKEN_ERROR)
9999
return redirect("/login?force_login_form")
100100
if isinstance(exception, TypeError) and "'NoneType' object is not iterable" in str(exception):
101101
logger.warning("OIDC login error: NoneType is not iterable")
102-
messages.error(request, "An unexpected error occurred during social login. Please use the standard login.")
102+
messages.error(request, settings.SOCIAL_AUTH_EXCEPTION_MESSAGE_NONE_TYPE)
103103
return redirect("/login?force_login_form")
104104
logger.error(f"Unhandled exception during social login: {exception}")
105105
return super().process_exception(request, exception)

dojo/settings/settings.dist.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@
178178
DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_KEY=(str, ""),
179179
DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_SECRET=(str, ""),
180180
DD_SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL=(bool, True),
181+
DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_REQUEST_EXCEPTION=(str, "Please use the standard login below."),
182+
DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_CANCELED=(str, "Social login was canceled. Please try again or use the standard login."),
183+
DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FAILED=(str, "Social login failed. Please try again or use the standard login."),
184+
DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FORBIDDEN=(str, "You are not authorized to log in via this method. Please contact support or use the standard login."),
185+
DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_NONE_TYPE=(str, "An unexpected error occurred during social login. Please use the standard login."),
186+
DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_TOKEN_ERROR=(str, "Social login failed due to an invalid or expired token. Please try again or use the standard login."),
181187
DD_SAML2_ENABLED=(bool, False),
182188
# Allows to override default SAML authentication backend. Check https://djangosaml2.readthedocs.io/contents/setup.html#custom-user-attributes-processing
183189
DD_SAML2_AUTHENTICATION_BACKENDS=(str, "djangosaml2.backends.Saml2Backend"),
@@ -658,6 +664,13 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
658664
if value := env("DD_SOCIAL_AUTH_OIDC_LOGIN_BUTTON_TEXT"):
659665
SOCIAL_AUTH_OIDC_LOGIN_BUTTON_TEXT = value
660666

667+
SOCIAL_AUTH_EXCEPTION_MESSAGE_REQUEST_EXCEPTION = env("DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_REQUEST_EXCEPTION")
668+
SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_CANCELED = env("DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_CANCELED")
669+
SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FAILED = env("DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FAILED")
670+
SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FORBIDDEN = env("DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_FORBIDDEN")
671+
SOCIAL_AUTH_EXCEPTION_MESSAGE_NONE_TYPE = env("DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_NONE_TYPE")
672+
SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_TOKEN_ERROR = env("DD_SOCIAL_AUTH_EXCEPTION_MESSAGE_AUTH_TOKEN_ERROR")
673+
661674
AUTH0_OAUTH2_ENABLED = env("DD_SOCIAL_AUTH_AUTH0_OAUTH2_ENABLED")
662675
SOCIAL_AUTH_AUTH0_KEY = env("DD_SOCIAL_AUTH_AUTH0_KEY")
663676
SOCIAL_AUTH_AUTH0_SECRET = env("DD_SOCIAL_AUTH_AUTH0_SECRET")

0 commit comments

Comments
 (0)