Skip to content

Commit 9ad24b6

Browse files
committed
Move externalauth -> external-auth
1 parent e6c047c commit 9ad24b6

File tree

16 files changed

+33
-33
lines changed

16 files changed

+33
-33
lines changed

coderd/coderd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ func New(options *Options) *API {
547547

548548
// Register callback handlers for each OAuth2 provider.
549549
// We must support gitauth and externalauth for backwards compatibility.
550-
for _, route := range []string{"gitauth", "externalauth"} {
550+
for _, route := range []string{"gitauth", "external-auth"} {
551551
r.Route("/"+route, func(r chi.Router) {
552552
for _, externalAuthConfig := range options.ExternalAuthConfigs {
553553
// We don't need to register a callback handler for device auth.
@@ -616,7 +616,7 @@ func New(options *Options) *API {
616616
r.Get("/{fileID}", api.fileByID)
617617
r.Post("/", api.postFile)
618618
})
619-
r.Route("/externalauth/{externalauth}", func(r chi.Router) {
619+
r.Route("/external-auth/{externalauth}", func(r chi.Router) {
620620
r.Use(
621621
apiKeyMiddleware,
622622
httpmw.ExtractExternalAuthParam(options.ExternalAuthConfigs),
@@ -689,7 +689,7 @@ func New(options *Options) *API {
689689
r.Get("/schema", templateVersionSchemaDeprecated)
690690
r.Get("/parameters", templateVersionParametersDeprecated)
691691
r.Get("/rich-parameters", api.templateVersionRichParameters)
692-
r.Get("/externalauth", api.templateVersionExternalAuth)
692+
r.Get("/external-auth", api.templateVersionExternalAuth)
693693
r.Get("/variables", api.templateVersionVariables)
694694
r.Get("/resources", api.templateVersionResources)
695695
r.Get("/logs", api.templateVersionLogs)

coderd/externalauth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
// @Tags Git
2424
// @Param externalauth path string true "Git Provider ID" format(string)
2525
// @Success 200 {object} codersdk.ExternalAuth
26-
// @Router /externalauth/{externalauth} [get]
26+
// @Router /external-auth/{externalauth} [get]
2727
func (api *API) externalAuthByID(w http.ResponseWriter, r *http.Request) {
2828
config := httpmw.ExternalAuthParam(r)
2929
apiKey := httpmw.APIKey(r)
@@ -82,7 +82,7 @@ func (api *API) externalAuthByID(w http.ResponseWriter, r *http.Request) {
8282
// @Tags Git
8383
// @Param externalauth path string true "External Provider ID" format(string)
8484
// @Success 204
85-
// @Router /externalauth/{externalauth}/device [post]
85+
// @Router /external-auth/{externalauth}/device [post]
8686
func (api *API) postExternalAuthDeviceByID(rw http.ResponseWriter, r *http.Request) {
8787
ctx := r.Context()
8888
apiKey := httpmw.APIKey(r)
@@ -165,7 +165,7 @@ func (api *API) postExternalAuthDeviceByID(rw http.ResponseWriter, r *http.Reque
165165
// @Tags Git
166166
// @Param externalauth path string true "Git Provider ID" format(string)
167167
// @Success 200 {object} codersdk.ExternalAuthDevice
168-
// @Router /externalauth/{externalauth}/device [get]
168+
// @Router /external-auth/{externalauth}/device [get]
169169
func (*API) externalAuthDeviceByID(rw http.ResponseWriter, r *http.Request) {
170170
config := httpmw.ExternalAuthParam(r)
171171
ctx := r.Context()
@@ -247,7 +247,7 @@ func (api *API) externalAuthCallback(externalAuthConfig *externalauth.Config) ht
247247
redirect := state.Redirect
248248
if redirect == "" {
249249
// This is a nicely rendered screen on the frontend
250-
redirect = fmt.Sprintf("/externalauth/%s", externalAuthConfig.ID)
250+
redirect = fmt.Sprintf("/external-auth/%s", externalAuthConfig.ID)
251251
}
252252
http.Redirect(rw, r, redirect, http.StatusTemporaryRedirect)
253253
}

coderd/externalauth/externalauth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ func ConvertConfig(entries []codersdk.ExternalAuthConfig, accessURL *url.URL) ([
407407
}
408408
ids[entry.ID] = struct{}{}
409409

410-
authRedirect, err := accessURL.Parse(fmt.Sprintf("/externalauth/%s/callback", entry.ID))
410+
authRedirect, err := accessURL.Parse(fmt.Sprintf("/external-auth/%s/callback", entry.ID))
411411
if err != nil {
412-
return nil, xerrors.Errorf("parse externalauth callback url: %w", err)
412+
return nil, xerrors.Errorf("parse external auth callback url: %w", err)
413413
}
414414

415415
var regex *regexp.Regexp

coderd/externalauth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func TestGitAuthCallback(t *testing.T) {
268268
agentClient.SetSessionToken(authToken)
269269
token, err := agentClient.GitAuth(context.Background(), "github.com/asd/asd", false)
270270
require.NoError(t, err)
271-
require.True(t, strings.HasSuffix(token.URL, fmt.Sprintf("/externalauth/%s", "github")))
271+
require.True(t, strings.HasSuffix(token.URL, fmt.Sprintf("/external-auth/%s", "github")))
272272
})
273273
t.Run("UnauthorizedCallback", func(t *testing.T) {
274274
t.Parallel()
@@ -300,7 +300,7 @@ func TestGitAuthCallback(t *testing.T) {
300300
require.Equal(t, http.StatusTemporaryRedirect, resp.StatusCode)
301301
location, err := resp.Location()
302302
require.NoError(t, err)
303-
require.Equal(t, "/externalauth/github", location.Path)
303+
require.Equal(t, "/external-auth/github", location.Path)
304304

305305
// Callback again to simulate updating the token.
306306
resp = coderdtest.RequestExternalAuthCallback(t, "github", client)

coderd/httpmw/patternmatcher/routepatterns_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ func Test_RoutePatterns(t *testing.T) {
6565
"/api/**",
6666
"/@*/*/apps/**",
6767
"/%40*/*/apps/**",
68-
"/externalauth/*/callback",
68+
"/external-auth/*/callback",
6969
},
70-
output: "^(/api/?|/api/.+/?|/@[^/]+/[^/]+/apps/.+/?|/%40[^/]+/[^/]+/apps/.+/?|/externalauth/[^/]+/callback/?)$",
70+
output: "^(/api/?|/api/.+/?|/@[^/]+/[^/]+/apps/.+/?|/%40[^/]+/[^/]+/apps/.+/?|/external-auth/[^/]+/callback/?)$",
7171
},
7272
{
7373
name: "Slash",

coderd/templateversions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (api *API) templateVersionRichParameters(rw http.ResponseWriter, r *http.Re
280280
// @Tags Templates
281281
// @Param templateversion path string true "Template version ID" format(uuid)
282282
// @Success 200 {array} codersdk.TemplateVersionExternalAuth
283-
// @Router /templateversions/{templateversion}/externalauth [get]
283+
// @Router /templateversions/{templateversion}/external-auth [get]
284284
func (api *API) templateVersionExternalAuth(rw http.ResponseWriter, r *http.Request) {
285285
ctx := r.Context()
286286
var (
@@ -307,7 +307,7 @@ func (api *API) templateVersionExternalAuth(rw http.ResponseWriter, r *http.Requ
307307
}
308308

309309
// This is the URL that will redirect the user with a state token.
310-
redirectURL, err := api.AccessURL.Parse(fmt.Sprintf("/externalauth/%s", config.ID))
310+
redirectURL, err := api.AccessURL.Parse(fmt.Sprintf("/external-auth/%s", config.ID))
311311
if err != nil {
312312
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
313313
Message: "Failed to parse access URL.",

coderd/tracing/httpmw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func Middleware(tracerProvider trace.TracerProvider) func(http.Handler) http.Han
2626
"/api/**",
2727
"/@*/*/apps/**",
2828
"/%40*/*/apps/**",
29-
"/externalauth/*/callback",
29+
"/external-auth/*/callback",
3030
}.MustCompile()
3131

3232
var tracer trace.Tracer

coderd/tracing/httpmw_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func Test_Middleware(t *testing.T) {
5959
{"/%40hi/hi/apps/hi", true},
6060
{"/%40hi/hi/apps/hi/hi", true},
6161
{"/%40hi/hi/apps/hi/hi", true},
62-
{"/externalauth/hi/callback", true},
62+
{"/external=auth/hi/callback", true},
6363

6464
// Other routes that should not be collected.
6565
{"/index.html", false},

codersdk/externalauth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type ExternalAuthDeviceExchange struct {
5050
}
5151

5252
func (c *Client) ExternalAuthDeviceByID(ctx context.Context, provider string) (ExternalAuthDevice, error) {
53-
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/externalauth/%s/device", provider), nil)
53+
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/external-auth/%s/device", provider), nil)
5454
if err != nil {
5555
return ExternalAuthDevice{}, err
5656
}
@@ -64,7 +64,7 @@ func (c *Client) ExternalAuthDeviceByID(ctx context.Context, provider string) (E
6464

6565
// ExchangeGitAuth exchanges a device code for an external auth token.
6666
func (c *Client) ExternalAuthDeviceExchange(ctx context.Context, provider string, req ExternalAuthDeviceExchange) error {
67-
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/externalauth/%s/device", provider), req)
67+
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/external-auth/%s/device", provider), req)
6868
if err != nil {
6969
return err
7070
}
@@ -77,7 +77,7 @@ func (c *Client) ExternalAuthDeviceExchange(ctx context.Context, provider string
7777

7878
// ExternalAuthByID returns the external auth for the given provider by ID.
7979
func (c *Client) ExternalAuthByID(ctx context.Context, provider string) (ExternalAuth, error) {
80-
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/externalauth/%s", provider), nil)
80+
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/external-auth/%s", provider), nil)
8181
if err != nil {
8282
return ExternalAuth{}, err
8383
}

codersdk/templateversions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (c *Client) TemplateVersionRichParameters(ctx context.Context, version uuid
136136

137137
// TemplateVersionExternalAuth returns authentication providers for the requested template version.
138138
func (c *Client) TemplateVersionExternalAuth(ctx context.Context, version uuid.UUID) ([]TemplateVersionExternalAuth, error) {
139-
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/externalauth", version), nil)
139+
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/external-auth", version), nil)
140140
if err != nil {
141141
return nil, err
142142
}

0 commit comments

Comments
 (0)