2016-11-22 06:11:06 +05:30
# Authentication through GitHub
## Overview
One of the login options for dex uses the GitHub OAuth2 flow to identify the end user through their GitHub account.
When a client redeems a refresh token through dex, dex will re-query GitHub to update user information in the ID Token. To do this, __dex stores a readonly GitHub access token in its backing datastore.__ Users that reject dex's access through GitHub will also revoke all dex clients which authenticated them through GitHub.
2017-08-09 03:01:19 +05:30
## Caveats
2017-08-17 05:32:55 +05:30
* A user must explicitly [request][github-request-org-access] an [organization][github-orgs] give dex [resource access][github-approve-org-access]. Dex will not have the correct permissions to determine if the user is in that organization otherwise, and the user will not be able to log in. This request mechanism is a feature of the GitHub API.
2017-08-09 03:01:19 +05:30
2016-11-22 06:11:06 +05:30
## Configuration
Register a new application with [GitHub][github-oauth2] ensuring the callback URL is `(dex issuer)/callback` . For example if dex is listening at the non-root path `https://auth.example.com/dex` the callback would be `https://auth.example.com/dex/callback` .
The following is an example of a configuration for `examples/config-dev.yaml` :
```yaml
connectors:
- type: github
2017-01-24 04:44:41 +05:30
# Required field for connector id.
2016-11-22 06:11:06 +05:30
id: github
2017-01-24 04:44:41 +05:30
# Required field for connector name.
2016-11-22 06:11:06 +05:30
name: GitHub
config:
# Credentials can be string literals or pulled from the environment.
clientID: $GITHUB_CLIENT_ID
clientSecret: $GITHUB_CLIENT_SECRET
redirectURI: http://127.0.0.1:5556/dex/callback
2017-08-04 02:23:38 +05:30
# Optional organizations and teams, communicated through the "groups" scope.
2016-11-22 06:11:06 +05:30
#
# NOTE: This is an EXPERIMENTAL config option and will likely change.
2017-08-04 02:23:38 +05:30
#
# Legacy 'org' field. 'org' and 'orgs' cannot be used simultaneously. A user
# MUST be a member of the following org to authenticate with dex.
# org: my-organization
#
# Dex queries the following organizations for group information if the
# "groups" scope is provided. Group claims are formatted as "(org):(team)".
# For example if a user is part of the "engineering" team of the "coreos"
# org, the group claim would include "coreos:engineering".
#
# A user MUST be a member of at least one of the following orgs to
# authenticate with dex.
orgs:
- name: my-organization
# Include all teams as claims.
- name: my-organization-with-teams
# A white list of teams. Only include group claims for these teams.
teams:
2017-08-17 05:32:55 +05:30
- red-team
2017-08-04 02:23:38 +05:30
- blue-team
2016-11-22 06:11:06 +05:30
```
2017-04-08 03:25:22 +05:30
## GitHub Enterprise
Users can use their GitHub Enterprise account to login to dex. The following configuration can be used to enable a GitHub Enterprise connector on dex:
```yaml
connectors:
- type: github
# Required field for connector id.
id: github
# Required field for connector name.
name: GitHub
config:
# Required fields. Dex must be pre-registered with GitHub Enterprise
# to get the following values.
# Credentials can be string literals or pulled from the environment.
clientID: $GITHUB_CLIENT_ID
clientSecret: $GITHUB_CLIENT_SECRET
redirectURI: http://127.0.0.1:5556/dex/callback
2017-08-04 02:23:38 +05:30
# Optional organizations and teams, communicated through the "groups" scope.
2017-04-08 03:25:22 +05:30
#
# NOTE: This is an EXPERIMENTAL config option and will likely change.
2017-08-04 02:23:38 +05:30
#
# Legacy 'org' field. 'org' and 'orgs' cannot be used simultaneously. A user
# MUST be a member of the following org to authenticate with dex.
# org: my-organization
#
# Dex queries the following organizations for group information if the
# "groups" scope is provided. Group claims are formatted as "(org):(team)".
# For example if a user is part of the "engineering" team of the "coreos"
# org, the group claim would include "coreos:engineering".
#
# A user MUST be a member of at least one of the following orgs to
# authenticate with dex.
orgs:
- name: my-organization
# Include all teams as claims.
- name: my-organization-with-teams
# A white list of teams. Only include group claims for these teams.
teams:
2017-08-17 05:32:55 +05:30
- red-team
2017-08-04 02:23:38 +05:30
- blue-team
2017-04-08 03:25:22 +05:30
# Required ONLY for GitHub Enterprise.
# This is the Hostname of the GitHub Enterprise account listed on the
# management console. Ensure this domain is routable on your network.
hostName: git.example.com
# ONLY for GitHub Enterprise. Optional field.
# Used to support self-signed or untrusted CA root certificates.
rootCA: /etc/dex/ca.crt
```
2016-11-22 06:11:06 +05:30
[github-oauth2]: https://github.com/settings/applications/new
2017-08-09 03:01:19 +05:30
[github-orgs]: https://developer.github.com/v3/orgs/
[github-request-org-access]: https://help.github.com/articles/requesting-organization-approval-for-oauth-apps/
2017-08-17 05:32:55 +05:30
[github-approve-org-access]: https://help.github.com/articles/approving-oauth-apps-for-your-organization/