mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: enable GitHub OAuth2 login by default on new deployments (#16662)
Third and final PR to address https://github.com/coder/coder/issues/16230. This PR enables GitHub OAuth2 login by default on new deployments. Combined with https://github.com/coder/coder/pull/16629, this will allow the first admin user to sign up with GitHub rather than email and password. We take care not to enable the default on deployments that would upgrade to a Coder version with this change. To disable the default provider an admin can set the `CODER_OAUTH2_GITHUB_DEFAULT_PROVIDER` env variable to false.
This commit is contained in:
+19
-8
@@ -503,14 +503,15 @@ type OAuth2Config struct {
|
||||
}
|
||||
|
||||
type OAuth2GithubConfig struct {
|
||||
ClientID serpent.String `json:"client_id" typescript:",notnull"`
|
||||
ClientSecret serpent.String `json:"client_secret" typescript:",notnull"`
|
||||
DeviceFlow serpent.Bool `json:"device_flow" typescript:",notnull"`
|
||||
AllowedOrgs serpent.StringArray `json:"allowed_orgs" typescript:",notnull"`
|
||||
AllowedTeams serpent.StringArray `json:"allowed_teams" typescript:",notnull"`
|
||||
AllowSignups serpent.Bool `json:"allow_signups" typescript:",notnull"`
|
||||
AllowEveryone serpent.Bool `json:"allow_everyone" typescript:",notnull"`
|
||||
EnterpriseBaseURL serpent.String `json:"enterprise_base_url" typescript:",notnull"`
|
||||
ClientID serpent.String `json:"client_id" typescript:",notnull"`
|
||||
ClientSecret serpent.String `json:"client_secret" typescript:",notnull"`
|
||||
DeviceFlow serpent.Bool `json:"device_flow" typescript:",notnull"`
|
||||
DefaultProviderEnable serpent.Bool `json:"default_provider_enable" typescript:",notnull"`
|
||||
AllowedOrgs serpent.StringArray `json:"allowed_orgs" typescript:",notnull"`
|
||||
AllowedTeams serpent.StringArray `json:"allowed_teams" typescript:",notnull"`
|
||||
AllowSignups serpent.Bool `json:"allow_signups" typescript:",notnull"`
|
||||
AllowEveryone serpent.Bool `json:"allow_everyone" typescript:",notnull"`
|
||||
EnterpriseBaseURL serpent.String `json:"enterprise_base_url" typescript:",notnull"`
|
||||
}
|
||||
|
||||
type OIDCConfig struct {
|
||||
@@ -1593,6 +1594,16 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
|
||||
YAML: "deviceFlow",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "OAuth2 GitHub Default Provider Enable",
|
||||
Description: "Enable the default GitHub OAuth2 provider managed by Coder.",
|
||||
Flag: "oauth2-github-default-provider-enable",
|
||||
Env: "CODER_OAUTH2_GITHUB_DEFAULT_PROVIDER_ENABLE",
|
||||
Value: &c.OAuth2.Github.DefaultProviderEnable,
|
||||
Group: &deploymentGroupOAuth2GitHub,
|
||||
YAML: "defaultProviderEnable",
|
||||
Default: "true",
|
||||
},
|
||||
{
|
||||
Name: "OAuth2 GitHub Allowed Orgs",
|
||||
Description: "Organizations the user must be a member of to Login with GitHub.",
|
||||
|
||||
+9
-4
@@ -275,10 +275,10 @@ type OAuthConversionResponse struct {
|
||||
|
||||
// AuthMethods contains authentication method information like whether they are enabled or not or custom text, etc.
|
||||
type AuthMethods struct {
|
||||
TermsOfServiceURL string `json:"terms_of_service_url,omitempty"`
|
||||
Password AuthMethod `json:"password"`
|
||||
Github AuthMethod `json:"github"`
|
||||
OIDC OIDCAuthMethod `json:"oidc"`
|
||||
TermsOfServiceURL string `json:"terms_of_service_url,omitempty"`
|
||||
Password AuthMethod `json:"password"`
|
||||
Github GithubAuthMethod `json:"github"`
|
||||
OIDC OIDCAuthMethod `json:"oidc"`
|
||||
}
|
||||
|
||||
type AuthMethod struct {
|
||||
@@ -289,6 +289,11 @@ type UserLoginType struct {
|
||||
LoginType LoginType `json:"login_type"`
|
||||
}
|
||||
|
||||
type GithubAuthMethod struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
DefaultProviderConfigured bool `json:"default_provider_configured"`
|
||||
}
|
||||
|
||||
type OIDCAuthMethod struct {
|
||||
AuthMethod
|
||||
SignInText string `json:"signInText"`
|
||||
|
||||
Reference in New Issue
Block a user