5
5
"net/http"
6
6
)
7
7
8
+ // AuthProviderType is an enum of each valid auth provider.
8
9
type AuthProviderType string
9
10
10
11
// AuthProviderType enum.
@@ -14,18 +15,21 @@ const (
14
15
AuthProviderOIDC AuthProviderType = "oidc"
15
16
)
16
17
18
+ // ConfigAuth describes the authentication configuration for a Coder Enterprise deployment.
17
19
type ConfigAuth struct {
18
20
ProviderType * AuthProviderType `json:"provider_type"`
19
21
OIDC * ConfigOIDC `json:"oidc"`
20
22
SAML * ConfigSAML `json:"saml"`
21
23
}
22
24
25
+ // ConfigOIDC describes the OIDC configuration for single-signon support in Coder Enterprise.
23
26
type ConfigOIDC struct {
24
27
ClientID * string `json:"client_id"`
25
28
ClientSecret * string `json:"client_secret"`
26
29
Issuer * string `json:"issuer"`
27
30
}
28
31
32
+ // ConfigSAML describes the SAML configuration values.
29
33
type ConfigSAML struct {
30
34
IdentityProviderMetadataURL * string `json:"idp_metadata_url"`
31
35
SignatureAlgorithm * string `json:"signature_algorithm"`
@@ -34,28 +38,33 @@ type ConfigSAML struct {
34
38
PublicKeyCertificate * string `json:"public_key_certificate"`
35
39
}
36
40
41
+ // ConfigOAuthBitbucketServer describes the Bitbucket integration configuration for a Coder Enterprise deployment.
37
42
type ConfigOAuthBitbucketServer struct {
38
43
BaseURL string `json:"base_url" diff:"oauth.bitbucket_server.base_url"`
39
44
}
40
45
46
+ // ConfigOAuthGitHub describes the Github integration configuration for a Coder Enterprise deployment.
41
47
type ConfigOAuthGitHub struct {
42
48
BaseURL string `json:"base_url"`
43
49
ClientID string `json:"client_id"`
44
50
ClientSecret string `json:"client_secret"`
45
51
}
46
52
53
+ // ConfigOAuthGitLab describes the GitLab integration configuration for a Coder Enterprise deployment.
47
54
type ConfigOAuthGitLab struct {
48
55
BaseURL string `json:"base_url"`
49
56
ClientID string `json:"client_id" `
50
57
ClientSecret string `json:"client_secret"`
51
58
}
52
59
60
+ // ConfigOAuth describes the aggregate git integration configuration for a Coder Enterprise deployment.
53
61
type ConfigOAuth struct {
54
62
BitbucketServer ConfigOAuthBitbucketServer `json:"bitbucket_server"`
55
63
GitHub ConfigOAuthGitHub `json:"github"`
56
64
GitLab ConfigOAuthGitLab `json:"gitlab"`
57
65
}
58
66
67
+ // SiteConfigAuth fetches the sitewide authentication configuration.
59
68
func (c Client ) SiteConfigAuth (ctx context.Context ) (* ConfigAuth , error ) {
60
69
var conf ConfigAuth
61
70
if err := c .requestBody (ctx , http .MethodGet , "/api/auth/config" , nil , & conf ); err != nil {
@@ -64,10 +73,12 @@ func (c Client) SiteConfigAuth(ctx context.Context) (*ConfigAuth, error) {
64
73
return & conf , nil
65
74
}
66
75
76
+ // PutSiteConfigAuth sets the sitewide authentication configuration.
67
77
func (c Client ) PutSiteConfigAuth (ctx context.Context , req ConfigAuth ) error {
68
78
return c .requestBody (ctx , http .MethodPut , "/api/auth/config" , req , nil )
69
79
}
70
80
81
+ // SiteConfigOAuth fetches the sitewide git provider OAuth configuration.
71
82
func (c Client ) SiteConfigOAuth (ctx context.Context ) (* ConfigOAuth , error ) {
72
83
var conf ConfigOAuth
73
84
if err := c .requestBody (ctx , http .MethodGet , "/api/oauth/config" , nil , & conf ); err != nil {
@@ -76,6 +87,7 @@ func (c Client) SiteConfigOAuth(ctx context.Context) (*ConfigOAuth, error) {
76
87
return & conf , nil
77
88
}
78
89
90
+ // PutSiteConfigOAuth sets the sitewide git provider OAuth configuration.
79
91
func (c Client ) PutSiteConfigOAuth (ctx context.Context , req ConfigOAuth ) error {
80
92
return c .requestBody (ctx , http .MethodPut , "/api/oauth/config" , req , nil )
81
93
}
@@ -84,6 +96,7 @@ type configSetupMode struct {
84
96
SetupMode bool `json:"setup_mode"`
85
97
}
86
98
99
+ // SiteSetupModeEnabled fetches the current setup_mode state of a Coder Enterprise deployment.
87
100
func (c Client ) SiteSetupModeEnabled (ctx context.Context ) (bool , error ) {
88
101
var conf configSetupMode
89
102
if err := c .requestBody (ctx , http .MethodGet , "/api/config/setup-mode" , nil , & conf ); err != nil {
@@ -92,6 +105,7 @@ func (c Client) SiteSetupModeEnabled(ctx context.Context) (bool, error) {
92
105
return conf .SetupMode , nil
93
106
}
94
107
108
+ // ExtensionMarketplaceType is an enum of the valid extension marketplace configurations.
95
109
type ExtensionMarketplaceType string
96
110
97
111
// ExtensionMarketplaceType enum.
@@ -101,13 +115,16 @@ const (
101
115
ExtensionMarketplacePublic ExtensionMarketplaceType = "public"
102
116
)
103
117
118
+ // MarketplaceExtensionPublicURL is the URL of the coder.com public marketplace that serves open source Code OSS extensions.
104
119
const MarketplaceExtensionPublicURL = "https://extensions.coder.com/api"
105
120
121
+ // ConfigExtensionMarketplace describes the sitewide extension marketplace configuration.
106
122
type ConfigExtensionMarketplace struct {
107
123
URL string `json:"url"`
108
124
Type ExtensionMarketplaceType `json:"type"`
109
125
}
110
126
127
+ // SiteConfigExtensionMarketplace fetches the extension marketplace configuration.
111
128
func (c Client ) SiteConfigExtensionMarketplace (ctx context.Context ) (* ConfigExtensionMarketplace , error ) {
112
129
var conf ConfigExtensionMarketplace
113
130
if err := c .requestBody (ctx , http .MethodGet , "/api/extensions/config" , nil , & conf ); err != nil {
@@ -116,6 +133,7 @@ func (c Client) SiteConfigExtensionMarketplace(ctx context.Context) (*ConfigExte
116
133
return & conf , nil
117
134
}
118
135
136
+ // PutSiteConfigExtensionMarketplace sets the extension marketplace configuration.
119
137
func (c Client ) PutSiteConfigExtensionMarketplace (ctx context.Context , req ConfigExtensionMarketplace ) error {
120
138
return c .requestBody (ctx , http .MethodPut , "/api/extensions/config" , req , nil )
121
139
}
0 commit comments