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

fix(oauth2): google oauth2 whitelisting. #11372

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

JGodin-C2C
Copy link
Contributor

@JGodin-C2C JGodin-C2C commented Dec 4, 2024

Fix google oauth2 whitelisting.

The variable is a tuple and should be managed as such

Description

Fixes: #6748

What

Google oauth using environment variables as configuration (k8s for instance) could not get the correct configuration.
The google whitelisting is an array and was red as a string.
It was hence not working the way it was intended to.

How

I used the same method used as the allowed_hosts to pars arrays and updated the documentation to explain how to use the configuration keys in a helm deployments.

Checklist

This checklist is for your information.

  • Bugfixes should be submitted against the bugfix branch.

@github-actions github-actions bot added settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 docs ui helm labels Dec 4, 2024
@JGodin-C2C JGodin-C2C changed the base branch from master to bugfix December 4, 2024 15:09
Copy link

dryrunsecurity bot commented Dec 4, 2024

DryRun Security Summary

This pull request enhances the security of the Google OAuth2 authentication functionality in the DefectDojo application by adding support for configuring environment variables to specify whitelisted domains and emails, and updating the configuration file to properly handle the whitelisted values.

Expand for full summary

Summary:

The code changes in this pull request focus on enhancing the security of the Google OAuth2 authentication
functionality in the DefectDojo application. The changes include adding support for configuring environment
variables to specify whitelisted domains and emails for Google OAuth2 authentication, and updating the
configuration file to use the env.list() function to properly handle the whitelisted values.

From an application security perspective, these changes are positive as they allow for more granular control
over who can authenticate to the DefectDojo application. Whitelisting domains and emails helps prevent
unauthorized access and improves the overall security of the application. However, it's important to ensure
that the whitelisted domains and emails are properly maintained and updated as needed, as outdated or overly
permissive whitelists could still lead to security risks.

Files Changed:

  1. docs/content/en/open_source/archived_docs/integrations/social-authentication.md:

    • This file adds new code blocks that show how to configure the DD_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS
      and DD_SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS environment variables.
    • This allows administrators to specify a list of allowed domains and emails that can be used to authenticate
      users via Google OAuth2.
    • The documentation should emphasize the importance of properly configuring these settings and the potential
      security implications of misconfiguration, as well as provide guidance on best practices for managing the
      whitelists.
  2. dojo/settings/settings.dist.py:

    • The changes update the SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS and
      SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS settings to use the env.list() function instead of
      the regular env() function.
    • This ensures that the values are properly converted to a tuple, which is the expected data type for
      these settings, reducing the risk of configuration errors or unexpected behavior.

Overall, these code changes appear to be security-focused improvements that enhance the security of the
Google OAuth2 authentication functionality in the DefectDojo application.

Code Analysis

We ran 9 analyzers against 2 files and 1 analyzer had findings. 8 analyzers had no findings.

Analyzer Findings
Authn/Authz Analyzer 1 finding

View PR in the DryRun Dashboard.

Copy link
Contributor

github-actions bot commented Dec 4, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

JGodin-C2C and others added 2 commits December 5, 2024 08:28
The variable is a tuple and should be managed as such

Signed-off-by: Julien Godin <julien.godin@camptocamp.com>
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@mtesauro mtesauro merged commit d7dff9e into DefectDojo:bugfix Dec 12, 2024
73 checks passed
paulOsinski pushed a commit to paulOsinski/django-DefectDojo that referenced this pull request Dec 23, 2024
* Update release step3

* fix(oauth2): Fix google oauth2 whitelisting.

The variable is a tuple and should be managed as such

Signed-off-by: Julien Godin <julien.godin@camptocamp.com>

---------

Signed-off-by: Julien Godin <julien.godin@camptocamp.com>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Your credentials aren't allowed for Google OAuth Authentication
5 participants