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
This commit is contained in:
Kyle Carberry
2023-09-29 19:13:20 +00:00
committed by GitHub
parent 2b5428e95f
commit 8abca9bea7
67 changed files with 1441 additions and 1363 deletions
+9 -9
View File
@@ -33,11 +33,11 @@ type TemplateVersion struct {
Warnings []TemplateVersionWarning `json:"warnings,omitempty" enums:"DEPRECATED_PARAMETERS"`
}
type TemplateVersionGitAuth struct {
ID string `json:"id"`
Type GitProvider `json:"type"`
AuthenticateURL string `json:"authenticate_url"`
Authenticated bool `json:"authenticated"`
type TemplateVersionExternalAuth struct {
ID string `json:"id"`
Type ExternalAuthProvider `json:"type"`
AuthenticateURL string `json:"authenticate_url"`
Authenticated bool `json:"authenticated"`
}
type ValidationMonotonicOrder string
@@ -132,8 +132,8 @@ func (c *Client) TemplateVersionRichParameters(ctx context.Context, version uuid
return params, json.NewDecoder(res.Body).Decode(&params)
}
// TemplateVersionGitAuth returns git authentication for the requested template version.
func (c *Client) TemplateVersionGitAuth(ctx context.Context, version uuid.UUID) ([]TemplateVersionGitAuth, error) {
// TemplateVersionExternalAuth returns authentication providers for the requested template version.
func (c *Client) TemplateVersionExternalAuth(ctx context.Context, version uuid.UUID) ([]TemplateVersionExternalAuth, error) {
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/gitauth", version), nil)
if err != nil {
return nil, err
@@ -142,8 +142,8 @@ func (c *Client) TemplateVersionGitAuth(ctx context.Context, version uuid.UUID)
if res.StatusCode != http.StatusOK {
return nil, ReadBodyAsError(res)
}
var gitAuth []TemplateVersionGitAuth
return gitAuth, json.NewDecoder(res.Body).Decode(&gitAuth)
var extAuth []TemplateVersionExternalAuth
return extAuth, json.NewDecoder(res.Body).Decode(&extAuth)
}
// TemplateVersionResources returns resources a template version declares.
+14 -11
View File
@@ -744,30 +744,33 @@ func (c *Client) WorkspaceAgentLogsAfter(ctx context.Context, agentID uuid.UUID,
}), nil
}
// GitProvider is a constant that represents the
// ExternalAuthProvider is a constant that represents the
// type of providers that are supported within Coder.
type GitProvider string
type ExternalAuthProvider string
func (g GitProvider) Pretty() string {
func (g ExternalAuthProvider) Pretty() string {
switch g {
case GitProviderAzureDevops:
case ExternalAuthProviderAzureDevops:
return "Azure DevOps"
case GitProviderGitHub:
case ExternalAuthProviderGitHub:
return "GitHub"
case GitProviderGitLab:
case ExternalAuthProviderGitLab:
return "GitLab"
case GitProviderBitBucket:
case ExternalAuthProviderBitBucket:
return "Bitbucket"
case ExternalAuthProviderOpenIDConnect:
return "OpenID Connect"
default:
return string(g)
}
}
const (
GitProviderAzureDevops GitProvider = "azure-devops"
GitProviderGitHub GitProvider = "github"
GitProviderGitLab GitProvider = "gitlab"
GitProviderBitBucket GitProvider = "bitbucket"
ExternalAuthProviderAzureDevops ExternalAuthProvider = "azure-devops"
ExternalAuthProviderGitHub ExternalAuthProvider = "github"
ExternalAuthProviderGitLab ExternalAuthProvider = "gitlab"
ExternalAuthProviderBitBucket ExternalAuthProvider = "bitbucket"
ExternalAuthProviderOpenIDConnect ExternalAuthProvider = "openid-connect"
)
type WorkspaceAgentLog struct {