Skip to content

Commit 8abca9b

Browse files
authored
chore: rename git_auth to external_auth in our schema (#9935)
* chore: rename `git_auth` to `external_auth` in our schema We're changing Git auth to be external auth. It will support any OAuth2 or OIDC provider. To split up the larger change I want to contribute the schema changes first, and I'll add the feature itself in another PR. * Fix names * Fix outdated view * Rename some additional places * Fix sort order * Fix template versions auth route * Fix types * Fix dbauthz
1 parent 2b5428e commit 8abca9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1440
-1362
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,11 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./coders
542542
cd site
543543
pnpm run format:types ./src/api/typesGenerated.ts
544544

545-
site/e2e/provisionerGenerated.ts:
545+
site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go
546546
cd site
547547
../scripts/pnpm_install.sh
548548
pnpm run gen:provisioner
549549

550-
551550
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
552551
go run ./scripts/examplegen/main.go > examples/examples.gen.json
553552

cli/cliui/gitauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
type GitAuthOptions struct {
15-
Fetch func(context.Context) ([]codersdk.TemplateVersionGitAuth, error)
15+
Fetch func(context.Context) ([]codersdk.TemplateVersionExternalAuth, error)
1616
FetchInterval time.Duration
1717
}
1818

cli/cliui/gitauth_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ func TestGitAuth(t *testing.T) {
2626
Handler: func(inv *clibase.Invocation) error {
2727
var fetched atomic.Bool
2828
return cliui.GitAuth(inv.Context(), inv.Stdout, cliui.GitAuthOptions{
29-
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionGitAuth, error) {
29+
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
3030
defer fetched.Store(true)
31-
return []codersdk.TemplateVersionGitAuth{{
31+
return []codersdk.TemplateVersionExternalAuth{{
3232
ID: "github",
33-
Type: codersdk.GitProviderGitHub,
33+
Type: codersdk.ExternalAuthProviderGitHub,
3434
Authenticated: fetched.Load(),
3535
AuthenticateURL: "https://example.com/gitauth/github",
3636
}}, nil

cli/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ func prepWorkspaceBuild(inv *clibase.Invocation, client *codersdk.Client, args p
266266
}
267267

268268
err = cliui.GitAuth(ctx, inv.Stdout, cliui.GitAuthOptions{
269-
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionGitAuth, error) {
270-
return client.TemplateVersionGitAuth(ctx, templateVersion.ID)
269+
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
270+
return client.TemplateVersionExternalAuth(ctx, templateVersion.ID)
271271
},
272272
})
273273
if err != nil {

cli/create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ func TestCreateWithGitAuth(t *testing.T) {
609609
}
610610

611611
client := coderdtest.New(t, &coderdtest.Options{
612-
GitAuthConfigs: []*gitauth.Config{{
612+
ExternalAuthConfigs: []*gitauth.Config{{
613613
OAuth2Config: &testutil.OAuth2Config{},
614614
ID: "github",
615615
Regex: regexp.MustCompile(`github\.com`),
616-
Type: codersdk.GitProviderGitHub,
616+
Type: codersdk.ExternalAuthProviderGitHub,
617617
}},
618618
IncludeProvisionerDaemon: true,
619619
})

cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
608608
Pubsub: pubsub.NewInMemory(),
609609
CacheDir: cacheDir,
610610
GoogleTokenValidator: googleTokenValidator,
611-
GitAuthConfigs: gitAuthConfigs,
611+
ExternalAuthConfigs: gitAuthConfigs,
612612
RealIPConfig: realIPConfig,
613613
SecureAuthCookie: vals.SecureAuthCookie.Value(),
614614
SSHKeygenAlgorithm: sshKeygenAlgorithm,

cmd/cliui/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,16 @@ func main() {
332332
gitlabAuthed.Store(true)
333333
}()
334334
return cliui.GitAuth(inv.Context(), inv.Stdout, cliui.GitAuthOptions{
335-
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionGitAuth, error) {
335+
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
336336
count.Add(1)
337-
return []codersdk.TemplateVersionGitAuth{{
337+
return []codersdk.TemplateVersionExternalAuth{{
338338
ID: "github",
339-
Type: codersdk.GitProviderGitHub,
339+
Type: codersdk.ExternalAuthProviderGitHub,
340340
Authenticated: githubAuthed.Load(),
341341
AuthenticateURL: "https://example.com/gitauth/github?redirect=" + url.QueryEscape("/gitauth?notify"),
342342
}, {
343343
ID: "gitlab",
344-
Type: codersdk.GitProviderGitLab,
344+
Type: codersdk.ExternalAuthProviderGitLab,
345345
Authenticated: gitlabAuthed.Load(),
346346
AuthenticateURL: "https://example.com/gitauth/gitlab?redirect=" + url.QueryEscape("/gitauth?notify"),
347347
}}, nil

coderd/apidoc/docs.go

Lines changed: 20 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ type Options struct {
115115
SSHKeygenAlgorithm gitsshkey.Algorithm
116116
Telemetry telemetry.Reporter
117117
TracerProvider trace.TracerProvider
118-
GitAuthConfigs []*gitauth.Config
118+
ExternalAuthConfigs []*gitauth.Config
119119
RealIPConfig *httpmw.RealIPConfig
120120
TrialGenerator func(ctx context.Context, email string) error
121121
// TLSCertificates is used to mesh DERP servers securely.
@@ -547,7 +547,7 @@ func New(options *Options) *API {
547547

548548
// Register callback handlers for each OAuth2 provider.
549549
r.Route("/gitauth", func(r chi.Router) {
550-
for _, gitAuthConfig := range options.GitAuthConfigs {
550+
for _, gitAuthConfig := range options.ExternalAuthConfigs {
551551
// We don't need to register a callback handler for device auth.
552552
if gitAuthConfig.DeviceAuth != nil {
553553
continue
@@ -616,7 +616,7 @@ func New(options *Options) *API {
616616
r.Route("/gitauth/{gitauth}", func(r chi.Router) {
617617
r.Use(
618618
apiKeyMiddleware,
619-
httpmw.ExtractGitAuthParam(options.GitAuthConfigs),
619+
httpmw.ExtractGitAuthParam(options.ExternalAuthConfigs),
620620
)
621621
r.Get("/", api.gitAuthByID)
622622
r.Post("/device", api.postGitAuthDeviceByID)
@@ -1117,8 +1117,8 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context) (client pro
11171117
api.UserQuietHoursScheduleStore,
11181118
api.DeploymentValues,
11191119
provisionerdserver.Options{
1120-
OIDCConfig: api.OIDCConfig,
1121-
GitAuthConfigs: api.GitAuthConfigs,
1120+
OIDCConfig: api.OIDCConfig,
1121+
ExternalAuthConfigs: api.ExternalAuthConfigs,
11221122
},
11231123
)
11241124
if err != nil {

0 commit comments

Comments
 (0)