Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: allow all GitHub login when no org is set #4837

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

Closed
wants to merge 1 commit into from

Conversation

starcatmeow
Copy link
Contributor

Allow all GitHub login when no organization is set. This enables users to provide public access of their coder instance.

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@starcatmeow
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@bpmct bpmct requested a review from kylecarbs November 1, 2022 16:11
@kylecarbs
Copy link
Member

@starcatmeow sorry I've been slow to review! I'll get around to it this weekend.

I appreciate the contribution!

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @starcatmeow!

I'm a bit worried about how easy it'll be to accidentally open up logins to the world, let's say the server admin has a typo in their org environment variable and as a result, no orgs are set. This would then allow everyone to login with the admin being non-the-wiser.

We could add a new config (--oauth2-github-allow-everyone/CODER_OAUTH2_GITHUB_ALLOW_EVERYONE) and perform additional checks in cli/server.go (to exit early on config errors). Only if this config is set would we allow orgs to be empty. Thoughts @kylecarbs?

@@ -95,7 +98,7 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
}

// The default if no teams are specified is to allow all.
if len(api.GithubOAuth2Config.AllowTeams) > 0 {
if len(api.GithubOAuth2Config.AllowOrganizations) > 0 && len(api.GithubOAuth2Config.AllowTeams) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

This would silently allow all logins even if teams are set but organizations are not. I'd say that's a configuration error, but we shouldn't silently allow it.

We should perhaps keep this if as it was and recheck that selectedMembership is non-nil.

@kylecarbs
Copy link
Member

@mafredri I like that solution. While not being as clean as empty being all, it feels much less likely to cause a security breach.

@bpmct
Copy link
Member

bpmct commented Nov 9, 2022

I like where your head is at @mafredri! Another option is to use wildcards 😉

CODER_OAUTH2_GITHUB_ALLOW_ORGANIZATIONS=*

Either a separate env var or wildcard makes sense to me. I agree with the security concern around the unset behavior

@mafredri
Copy link
Member

mafredri commented Nov 9, 2022

I like where your head is at @mafredri! Another option is to use wildcards 😉

CODER_OAUTH2_GITHUB_ALLOW_ORGANIZATIONS=*

Either a separate env var or wildcard makes sense to me. I agree with the security concern around the unset behavior

I love that suggestion. Just one question, how would we surface this option/possibility? I suppose it could be part of the --help output for the allow orgs flag. I.e. Set to * to allow everyone.

This begs the question, if we go this route, should we turn this into a regex like we have for git auth URL matching? Would feel a bit weird having both "glob-ish" and "regex" styles. But also, regex is a nightmare for security so a simpler variant would win here.

@bpmct
Copy link
Member

bpmct commented Nov 9, 2022

Yeah, perhaps going with the separate boolean flag is better for those reasons. Otherwise, yeah we can just add Set to * to allow everyone. to the help text description. Your call @mafredri

@mafredri
Copy link
Member

@starcatmeow we wanted to fast-track this so I hope it's OK I took over your PR. I would've pushed to this branch but I didn't have permissions so I opened up a new PR: #5086.

Feel free to give feedback on the new approach!

@starcatmeow
Copy link
Contributor Author

@starcatmeow we wanted to fast-track this so I hope it's OK I took over your PR. I would've pushed to this branch but I didn't have permissions so I opened up a new PR: #5086.

Feel free to give feedback on the new approach!

Your solution is great for both functionality and security! I'm quite busy these days so I couldn't respond in time. Thanks for all you guys sharing ideas and raising PRs! I'm going to close this.

1 similar comment
@starcatmeow
Copy link
Contributor Author

@starcatmeow we wanted to fast-track this so I hope it's OK I took over your PR. I would've pushed to this branch but I didn't have permissions so I opened up a new PR: #5086.

Feel free to give feedback on the new approach!

Your solution is great for both functionality and security! I'm quite busy these days so I couldn't respond in time. Thanks for all you guys sharing ideas and raising PRs! I'm going to close this.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants