Skip to content

Commit f203598

Browse files
committed
siteconfig and deployment config
1 parent dfd49d0 commit f203598

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

coderd/database/queries/siteconfig.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,27 @@ ON CONFLICT (key) DO UPDATE SET value = $2 WHERE site_configs.key = $1;
107107
DELETE FROM site_configs
108108
WHERE site_configs.key = $1;
109109

110+
-- name: GetOAuth2GithubDefaultEligible :one
111+
SELECT
112+
CASE
113+
WHEN value = 'true' THEN TRUE
114+
ELSE FALSE
115+
END
116+
FROM site_configs
117+
WHERE key = 'oauth2_github_default_eligible';
118+
119+
-- name: UpsertOAuth2GithubDefaultEligible :exec
120+
INSERT INTO site_configs (key, value)
121+
VALUES (
122+
'oauth2_github_default_eligible',
123+
CASE
124+
WHEN sqlc.arg(eligible)::bool THEN 'true'
125+
ELSE 'false'
126+
END
127+
)
128+
ON CONFLICT (key) DO UPDATE
129+
SET value = CASE
130+
WHEN sqlc.arg(eligible)::bool THEN 'true'
131+
ELSE 'false'
132+
END
133+
WHERE site_configs.key = 'oauth2_github_default_eligible';

codersdk/deployment.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,15 @@ type OAuth2Config struct {
503503
}
504504

505505
type OAuth2GithubConfig struct {
506-
ClientID serpent.String `json:"client_id" typescript:",notnull"`
507-
ClientSecret serpent.String `json:"client_secret" typescript:",notnull"`
508-
DeviceFlow serpent.Bool `json:"device_flow" typescript:",notnull"`
509-
AllowedOrgs serpent.StringArray `json:"allowed_orgs" typescript:",notnull"`
510-
AllowedTeams serpent.StringArray `json:"allowed_teams" typescript:",notnull"`
511-
AllowSignups serpent.Bool `json:"allow_signups" typescript:",notnull"`
512-
AllowEveryone serpent.Bool `json:"allow_everyone" typescript:",notnull"`
513-
EnterpriseBaseURL serpent.String `json:"enterprise_base_url" typescript:",notnull"`
506+
ClientID serpent.String `json:"client_id" typescript:",notnull"`
507+
ClientSecret serpent.String `json:"client_secret" typescript:",notnull"`
508+
DeviceFlow serpent.Bool `json:"device_flow" typescript:",notnull"`
509+
DefaultProviderEnable serpent.Bool `json:"default_provider_enable" typescript:",notnull"`
510+
AllowedOrgs serpent.StringArray `json:"allowed_orgs" typescript:",notnull"`
511+
AllowedTeams serpent.StringArray `json:"allowed_teams" typescript:",notnull"`
512+
AllowSignups serpent.Bool `json:"allow_signups" typescript:",notnull"`
513+
AllowEveryone serpent.Bool `json:"allow_everyone" typescript:",notnull"`
514+
EnterpriseBaseURL serpent.String `json:"enterprise_base_url" typescript:",notnull"`
514515
}
515516

516517
type OIDCConfig struct {
@@ -1583,6 +1584,16 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
15831584
YAML: "deviceFlow",
15841585
Default: "false",
15851586
},
1587+
{
1588+
Name: "OAuth2 GitHub Default Provider Enable",
1589+
Description: "Enable the default GitHub OAuth2 provider managed by Coder.",
1590+
Flag: "oauth2-github-default-provider-enable",
1591+
Env: "CODER_OAUTH2_GITHUB_DEFAULT_PROVIDER_ENABLE",
1592+
Value: &c.OAuth2.Github.DefaultProviderEnable,
1593+
Group: &deploymentGroupOAuth2GitHub,
1594+
YAML: "defaultProviderEnable",
1595+
Default: "true",
1596+
},
15861597
{
15871598
Name: "OAuth2 GitHub Allowed Orgs",
15881599
Description: "Organizations the user must be a member of to Login with GitHub.",

codersdk/users.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ type OAuthConversionResponse struct {
275275

276276
// AuthMethods contains authentication method information like whether they are enabled or not or custom text, etc.
277277
type AuthMethods struct {
278-
TermsOfServiceURL string `json:"terms_of_service_url,omitempty"`
279-
Password AuthMethod `json:"password"`
280-
Github AuthMethod `json:"github"`
281-
OIDC OIDCAuthMethod `json:"oidc"`
278+
TermsOfServiceURL string `json:"terms_of_service_url,omitempty"`
279+
Password AuthMethod `json:"password"`
280+
Github GithubAuthMethod `json:"github"`
281+
OIDC OIDCAuthMethod `json:"oidc"`
282282
}
283283

284284
type AuthMethod struct {
@@ -289,6 +289,11 @@ type UserLoginType struct {
289289
LoginType LoginType `json:"login_type"`
290290
}
291291

292+
type GithubAuthMethod struct {
293+
Enabled bool `json:"enabled"`
294+
DefaultProviderConfigured bool `json:"default_provider_configured"`
295+
}
296+
292297
type OIDCAuthMethod struct {
293298
AuthMethod
294299
SignInText string `json:"signInText"`

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy