Skip to content

Commit 632663e

Browse files
committed
more consistent examples
1 parent fff9d84 commit 632663e

File tree

1 file changed

+43
-18
lines changed

1 file changed

+43
-18
lines changed

docs/admin/external-auth.md

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ application. The following providers have been tested and work with Coder:
1212
- [Azure DevOps](https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops)
1313
- [Azure DevOps (via Entra ID)](https://learn.microsoft.com/en-us/entra/architecture/auth-oauth2)
1414
- [BitBucket](https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/)
15-
- [GitHub](#github)
15+
- [GitHub](#configure-a-github-oauth-app
1616
- [GitLab](https://docs.gitlab.com/ee/integration/oauth_provider.html)
1717

1818
If you have experience with a provider that is not listed here, please
1919
[file an issue](https://github.com/coder/internal/issues/new?title=request%28docs%29%3A+external-auth+-+request+title+here%0D%0A&labels=["customer-feedback","docs"]&body=doc%3A+%5Bexternal-auth%5D%28https%3A%2F%2Fcoder.com%2Fdocs%2Fadmin%2Fexternal-auth%29%0D%0A%0D%0Aplease+enter+your+request+here%0D%0A)
2020

2121
## Configuration
2222

23+
### Set environment variables
24+
2325
After you create an OAuth application, set environment variables to configure the Coder server to use it:
2426

2527
```env
@@ -33,7 +35,13 @@ CODER_EXTERNAL_AUTH_0_DISPLAY_NAME="Google Calendar"
3335
CODER_EXTERNAL_AUTH_0_DISPLAY_ICON="https://mycustomicon.com/google.svg"
3436
```
3537

36-
The `CODER_EXTERNAL_AUTH_0_ID` environment variable is used as an identifier for the authentication provider. **This ID is also used as part of the callback URL path** that you must configure in your OAuth provider settings. Set it with a value that helps you identify the provider. For example, you can use `CODER_EXTERNAL_AUTH_0_ID="primary-github"` for your GitHub provider. Your callback URL would then be `https://your-coder-domain.com/external-auth/primary-github/callback`.
38+
The `CODER_EXTERNAL_AUTH_0_ID` environment variable is used as an identifier for the authentication provider.
39+
This variable is used as part of the callback URL path that you must configure in your OAuth provider settings.
40+
Set it with a value that helps you identify the provider.
41+
For example, if you use `CODER_EXTERNAL_AUTH_0_ID="primary-github"` for your GitHub provider,
42+
your callback URL will be `https://example.com/external-auth/primary-github/callback`.
43+
44+
### Add an authentication button to the workspace template
3745

3846
Add the following code to any template to add a button to the workspace setup page which will allow you to authenticate with your provider:
3947

@@ -50,7 +58,8 @@ data "coder_external_auth" "github" {
5058
5159
```
5260

53-
Inside your Terraform code, you now have access to authentication variables. Reference the documentation for your chosen provider for more information on how to supply it with a token.
61+
Inside your Terraform code, you now have access to authentication variables.
62+
Reference the documentation for your chosen provider for more information on how to supply it with a token.
5463

5564
### Workspace CLI
5665

@@ -100,10 +109,12 @@ CODER_EXTERNAL_AUTH_0_ID="primary-bitbucket-server"
100109
CODER_EXTERNAL_AUTH_0_TYPE=bitbucket-server
101110
CODER_EXTERNAL_AUTH_0_CLIENT_ID=xxx
102111
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=xxx
103-
CODER_EXTERNAL_AUTH_0_AUTH_URL=https://bitbucket.domain.com/rest/oauth2/latest/authorize
112+
CODER_EXTERNAL_AUTH_0_AUTH_URL=https://bitbucket.example.com/rest/oauth2/latest/authorize
104113
```
105114

106-
When configuring your Bitbucket OAuth application, set the Redirect URI to `https://your-coder-domain.com/external-auth/primary-bitbucket-server/callback`. The callback path includes the value of `CODER_EXTERNAL_AUTH_0_ID`.
115+
When configuring your Bitbucket OAuth application, set the redirect URI to
116+
`https://example.com/external-auth/primary-bitbucket-server/callback`.
117+
This callback path includes the value of `CODER_EXTERNAL_AUTH_0_ID`.
107118

108119
### Gitea
109120

@@ -116,13 +127,16 @@ CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=xxxxxxx
116127
CODER_EXTERNAL_AUTH_0_AUTH_URL="https://gitea.com/login/oauth/authorize"
117128
```
118129

119-
The Redirect URI for Gitea should be
120-
`https://coder.company.org/external-auth/gitea/callback`.
130+
The redirect URI for Gitea should be
131+
`https://coder.example.org/external-auth/gitea/callback`.
121132

122133
### GitHub
123134

124-
> [!TIP]
125-
> If you don't require fine-grained access control, it's easier to [configure a GitHub OAuth app](#configure-a-github-oauth-app).
135+
Use this section as a reference for environment variables to customize your setup
136+
or to integrate with an existing GitHub authentication.
137+
138+
For a more complete, step-by-step guide, follow the
139+
[configure a GitHub OAuth app](#configure-a-github-oauth-app) section instead.
126140

127141
```env
128142
CODER_EXTERNAL_AUTH_0_ID="USER_DEFINED_ID"
@@ -131,6 +145,11 @@ CODER_EXTERNAL_AUTH_0_CLIENT_ID=xxxxxx
131145
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=xxxxxxx
132146
```
133147

148+
When configuring your GitHub OAuth application, set the
149+
[authorization callback URL](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/about-the-user-authorization-callback-url)
150+
as `https://example.com/external-auth/USER_DEFINED_ID/callback`, where
151+
`USER_DEFINED_ID` matches your `CODER_EXTERNAL_AUTH_0_ID` value (in this example, `USER_DEFINED_ID`).
152+
134153
### GitHub Enterprise
135154

136155
GitHub Enterprise requires the following environment variables:
@@ -145,6 +164,11 @@ CODER_EXTERNAL_AUTH_0_AUTH_URL="https://github.example.com/login/oauth/authorize
145164
CODER_EXTERNAL_AUTH_0_TOKEN_URL="https://github.example.com/login/oauth/access_token"
146165
```
147166

167+
When configuring your GitHub Enterprise OAuth application, set the
168+
[authorization callback URL](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/about-the-user-authorization-callback-url)
169+
as `https://example.com/external-auth/primary-github/callback`, where
170+
`USER_DEFINED_ID` matches your `CODER_EXTERNAL_AUTH_0_ID` value (in this example, `primary-github`).
171+
148172
### GitLab self-managed
149173

150174
GitLab self-managed requires the following environment variables:
@@ -155,14 +179,15 @@ CODER_EXTERNAL_AUTH_0_TYPE=gitlab
155179
# This value is the "Application ID"
156180
CODER_EXTERNAL_AUTH_0_CLIENT_ID=xxxxxx
157181
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=xxxxxxx
158-
CODER_EXTERNAL_AUTH_0_VALIDATE_URL="https://gitlab.company.org/oauth/token/info"
159-
CODER_EXTERNAL_AUTH_0_AUTH_URL="https://gitlab.company.org/oauth/authorize"
160-
CODER_EXTERNAL_AUTH_0_TOKEN_URL="https://gitlab.company.org/oauth/token"
161-
CODER_EXTERNAL_AUTH_0_REGEX=gitlab\.company\.org
182+
CODER_EXTERNAL_AUTH_0_VALIDATE_URL="https://gitlab.example.org/oauth/token/info"
183+
CODER_EXTERNAL_AUTH_0_AUTH_URL="https://gitlab.example.org/oauth/authorize"
184+
CODER_EXTERNAL_AUTH_0_TOKEN_URL="https://gitlab.example.org/oauth/token"
185+
CODER_EXTERNAL_AUTH_0_REGEX=gitlab\.example\.org
162186
```
163187

164-
> [!IMPORTANT]
165-
> When configuring your GitLab OAuth application, set the Redirect URI to `https://your-coder-domain.com/external-auth/primary-gitlab/callback`. Note that the callback URL must include the value of `CODER_EXTERNAL_AUTH_0_ID` (in this example, "primary-gitlab").
188+
When [configuring your GitLab OAuth application](https://docs.gitlab.com/17.5/integration/oauth_provider/),
189+
set the redirect URI to `https://example.com/external-auth/primary-gitlab/callback`.
190+
Note that the redirect URI must include the value of `CODER_EXTERNAL_AUTH_0_ID` (in this example, `primary-gitlab`).
166191

167192
### JFrog Artifactory
168193

@@ -181,7 +206,7 @@ CODER_EXTERNAL_AUTH_0_REGEX=github\.company\.org
181206
```
182207

183208
> [!NOTE]
184-
> The `REGEX` variable must be set if using a custom git domain.
209+
> The `REGEX` variable must be set if using a custom Git domain.
185210
186211
## Custom scopes
187212

@@ -197,8 +222,8 @@ CODER_EXTERNAL_AUTH_0_SCOPES="repo:read repo:write write:gpg_key"
197222

198223
1. [Create a GitHub App](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app)
199224

200-
- Set the callback URL to
201-
`https://coder.example.com/external-auth/USER_DEFINED_ID/callback`, where `USER_DEFINED_ID`
225+
- Set the authorization callback URL to
226+
`https://coder.example.com/external-auth/USER_DEFINED_ID/callback`, where `USER_DEFINED_ID`
202227
is the value you set for `CODER_EXTERNAL_AUTH_0_ID`.
203228
- Deactivate Webhooks.
204229
- Enable fine-grained access to specific repositories or a subset of

0 commit comments

Comments
 (0)