-
Notifications
You must be signed in to change notification settings - Fork 894
docs: git auth #4902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
docs: git auth #4902
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Git Providers | ||
|
||
Coder integrates with git providers so developers can authenticate with repositories within their workspace. | ||
|
||
## How it works | ||
|
||
When developers use `git` inside their workspace, they are first prompted to authenticate. After that, Coder will store/refresh tokens for future operations. | ||
|
||
<video autoplay playsinline loop> | ||
<source src="https://github.com/coder/coder/blob/main/site/static/gitauth.mp4?raw=true" type="video/mp4"> | ||
Your browser does not support the video tag. | ||
</video> | ||
|
||
## Configuration | ||
|
||
To add a git provider, you'll need to create an OAuth application. The following providers are supported: | ||
|
||
- [GitHub](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app) (GitHub apps are also supported) | ||
- [GitLab](https://docs.gitlab.com/ee/integration/oauth_provider.html) | ||
- [BitBucket](https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/) | ||
- [Azure DevOps](https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops) | ||
|
||
Example callback URL: `https://coder.example.com/api/v2/gitauth/primary-github/callback`. Use an arbitrary ID for your provider (e.g. `primary-github`). | ||
ghuntley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Set the following environment variables to [configure the Coder server](./configure.md): | ||
|
||
```sh | ||
CODER_GITAUTH_0_ID="primary-github" | ||
CODER_GITAUTH_0_TYPE=github|gitlab|azure-devops|bitbucket | ||
CODER_GITAUTH_0_CLIENT_ID=xxxxxx | ||
CODER_GITAUTH_0_CLIENT_SECRET=xxxxxxx | ||
``` | ||
|
||
### Self-managed git providers | ||
|
||
Custom authentication and token URLs should be | ||
used for self-managed Git provider deployments. | ||
|
||
```sh | ||
CODER_GITAUTH_0_AUTH_URL="https://github.example.com/oauth/authorize" | ||
CODER_GITAUTH_0_TOKEN_URL="https://github.example.com/oauth/token" | ||
``` | ||
|
||
### Custom scopes | ||
|
||
Optionally, you can request custom scopes: | ||
|
||
```sh | ||
CODER_GITAUTH_0_SCOPES="repo:read repo:write write:gpg_key" | ||
``` | ||
|
||
### Multiple git providers (enterprise) | ||
|
||
Multiple providers are an Enterprise feature. [Learn more](../enterprise.md). | ||
|
||
A custom regex can be used to match a specific repository or organization to limit auth scope. Here's a sample config: | ||
|
||
```sh | ||
# Provider 1) github.com | ||
CODER_GITAUTH_0_ID=primary-github | ||
CODER_GITAUTH_0_TYPE=github | ||
CODER_GITAUTH_0_CLIENT_ID=xxxxxx | ||
CODER_GITAUTH_0_CLIENT_SECRET=xxxxxxx | ||
CODER_GITAUTH_0_REGEX=github.com/orgname | ||
|
||
# Provider 2) github.example.com | ||
CODER_GITAUTH_1_ID=secondary-github | ||
CODER_GITAUTH_1_TYPE=github | ||
CODER_GITAUTH_1_CLIENT_ID=xxxxxx | ||
CODER_GITAUTH_1_CLIENT_SECRET=xxxxxxx | ||
CODER_GITAUTH_1_REGEX=github.example.com | ||
CODER_GITAUTH_1_AUTH_URL="https://github.example.com/oauth/authorize" | ||
CODER_GITAUTH_1_TOKEN_URL="https://github.example.com/oauth/token" | ||
``` | ||
|
||
To support regex matching for paths (e.g. github.com/orgname), youll need to add this to the [Coder agent startup script](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#startup_script): | ||
|
||
```sh | ||
git config --global credential.useHttpPath true | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.