-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(auth): GitHub auth with Organization and Team restriction #9320
Conversation
Contextual Security AnalysisAs DryRun Security performs checks, we’ll summarize them here. You can always dive into the detailed results in the section below for checks.
Chat with your AI-powered Security Buddy by typing Install and configure more repositories at DryRun Security |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
# github ouath2 settings | ||
SOCIAL_AUTH_GITHUB_KEY = env("DD_SOCIAL_AUTH_GITHUB_KEY") | ||
SOCIAL_AUTH_GITHUB_SECRET = env("DD_SOCIAL_AUTH_GITHUB_SECRET") | ||
|
||
# github org oauth2 | ||
SOCIAL_AUTH_GITHUB_ORG_KEY = env("DD_SOCIAL_AUTH_GITHUB_KEY") | ||
SOCIAL_AUTH_GITHUB_ORG_SECRET = env("DD_SOCIAL_AUTH_GITHUB_SECRET") | ||
SOCIAL_AUTH_GITHUB_ORG_NAME = env("DD_SOCIAL_AUTH_GITHUB_ORG_NAME") | ||
|
||
# github team oauth2 | ||
SOCIAL_AUTH_GITHUB_TEAM_KEY = env("DD_SOCIAL_AUTH_GITHUB_KEY") | ||
SOCIAL_AUTH_GITHUB_TEAM_SECRET = env("DD_SOCIAL_AUTH_GITHUB_SECRET") | ||
SOCIAL_AUTH_GITHUB_TEAM_ID = env("DD_SOCIAL_AUTH_GITHUB_TEAM_ID") | ||
|
||
if GITHUB_OAUTH2_ENABLED: | ||
if SOCIAL_AUTH_GITHUB_TEAM_ID: | ||
AUTHENTICATION_BACKENDS += "social_core.backends.github.GithubTeamOAuth2" | ||
elif SOCIAL_AUTH_GITHUB_ORG_NAME: | ||
AUTHENTICATION_BACKENDS += ( | ||
"social_core.backends.github.GithubOrganizationOAuth2" | ||
) | ||
else: | ||
AUTHENTICATION_BACKENDS += "social_core.backends.github.GithubOAuth2" | ||
|
||
|
||
GITHUB_ENTERPRISE_OAUTH2_ENABLED = env( | ||
"DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_OAUTH2_ENABLED" | ||
) | ||
SOCIAL_AUTH_GITHUB_ENTERPRISE_URL = env("DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_URL") | ||
SOCIAL_AUTH_GITHUB_ENTERPRISE_API_URL = env("DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_API_URL") | ||
SOCIAL_AUTH_GITHUB_ENTERPRISE_KEY = env("DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_KEY") | ||
SOCIAL_AUTH_GITHUB_ENTERPRISE_SECRET = env("DD_SOCIAL_AUTH_GITHUB_ENTERPRISE_SECRET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping this comment for other reviewers for where the code changes are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, my linters stripped a lot of trailing whitespace. Will look at fixing the merge conflict 🔜
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Closing as |
We are narrowing the scope of acceptable enhancements to DefectDojo in preparation for v3. Learn more here:
https://github.com/DefectDojo/django-DefectDojo/blob/master/readme-docs/CONTRIBUTING.md
Description
This re-introduces github.com auth with the ability to set an organization name or team id. Reading further into the python-social docs, it seems that there are three or four different backends depending on how you want to control access to an application with GitHub auth: https://python-social-auth.readthedocs.io/en/latest/backends/github.html#github-apps
This means that the correct GItHub
AUTHENTICATION_BACKENDS
needs setting in a programmatic way based on configuration.Documentation
Updated
Checklist
This checklist is for your information.
dev
.dev
.bugfix
branch.Extra information
Please clear everything below when submitting your pull request, it's here purely for your information.
Moderators: Labels currently accepted for PRs:
Contributors: Git Tips
Rebase on dev branch
If the dev branch has changed since you started working on it, please rebase your work after the current dev.
On your working branch
mybranch
:In case of conflict:
When everything's fine on your local branch, force push to your
myOrigin
remote:To cancel everything:
Squashing commits
pick
byfixup
on the commits you want squashed outpick
byreword
on the first commit if you want to change the commit messageForce push to your
myOrigin
remote: