## File: README.md # dex - A federated OpenID Connect provider [](https://api.securityscorecards.dev/projects/github.com/dexidp/dex) [](https://www.bestpractices.dev/projects/12566) [](https://goreportcard.com/report/github.com/dexidp/dex) [](https://insights.linuxfoundation.org/project/dex/contributors) Dex is an identity service that uses [OpenID Connect][openid-connect] to drive authentication for other apps. Dex acts as a portal to other identity providers through ["connectors."](#connectors) This lets dex defer authentication to LDAP servers, SAML providers, or established identity providers like GitHub, Google, and Active Directory. Clients write their authentication logic once to talk to dex, then dex handles the protocols for a given backend. ## ID Tokens ID Tokens are an OAuth2 extension introduced by OpenID Connect and dex's primary feature. ID Tokens are [JSON Web Tokens][jwt-io] (JWTs) signed by dex and returned as part of the OAuth2 response that attests to the end user's identity. An example JWT might look like: ``` eyJhbGciOiJSUzI1NiIsImtpZCI6IjlkNDQ3NDFmNzczYjkzOGNmNjVkZDMyNjY4NWI4NjE4MGMzMjRkOTkifQ.eyJpc3MiOiJodHRwOi8vMTI3LjAuMC4xOjU1NTYvZGV4Iiwic3ViIjoiQ2djeU16UXlOelE1RWdabmFYUm9kV0kiLCJhdWQiOiJleGFtcGxlLWFwcCIsImV4cCI6MTQ5Mjg4MjA0MiwiaWF0IjoxNDkyNzk1NjQyLCJhdF9oYXNoIjoiYmk5NmdPWFpTaHZsV1l0YWw5RXFpdyIsImVtYWlsIjoiZXJpYy5jaGlhbmdAY29yZW9zLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJncm91cHMiOlsiYWRtaW5zIiwiZGV2ZWxvcGVycyJdLCJuYW1lIjoiRXJpYyBDaGlhbmcifQ.OhROPq_0eP-zsQRjg87KZ4wGkjiQGnTi5QuG877AdJDb3R2ZCOk2Vkf5SdP8cPyb3VMqL32G4hLDayniiv8f1_ZXAde0sKrayfQ10XAXFgZl_P1yilkLdknxn6nbhDRVllpWcB12ki9vmAxklAr0B1C4kr5nI3-BZLrFcUR5sQbxwJj4oW1OuG6jJCNGHXGNTBTNEaM28eD-9nhfBeuBTzzO7BKwPsojjj4C9ogU4JQhGvm_l4yfVi0boSx8c0FX3JsiB0yLa1ZdJVWVl9m90XmbWRSD85pNDQHcWZP9hR6CMgbvGkZsgjG32qeRwUL_eNkNowSBNWLrGNPoON1gMg ``` ID Tokens contains standard claims assert which client app logged the user in, when the token expires, and the identity of the user. ```json { "iss": "http://127.0.0.1:5556/dex", "sub": "CgcyMzQyNzQ5EgZnaXRodWI", "aud": "example-app", "exp": 1492882042, "iat": 1492795642, "at_hash": "bi96gOXZShvlWYtal9Eqiw", "email": "jane.doe@coreos.com", "email_verified": true, "groups": [ "admins", "developers" ], "name": "Jane Doe" } ``` Because these tokens are signed by dex and [contain standard-based claims][standard-claims] other services can consume them as service-to-service credentials. Systems that can already consume OpenID Connect ID Tokens issued by dex include: * [Kubernetes][kubernetes] * [AWS STS][aws-sts] For details on how to request or validate an ID Token, see [_"Writing apps that use dex"_](https://dexidp.io/docs/using-dex/). ## Kubernetes and Dex Dex runs natively on top of any Kubernetes cluster using Custom Resource Definitions and can drive API server authentication through the OpenID Connect plugin. Clients, such as [`kubelogin`](https://github.com/int128/kubelogin) and `kubectl`, can act on behalf of users who can login to the cluster through any identity provider dex supports. * More docs for running dex as a Kubernetes authenticator can be found [here](https://dexidp.io/docs/guides/kubernetes/). * You can find more about companies and projects which use dex, [here](./ADOPTERS.md). ## Connectors When a user logs in through dex, the user's identity is usually stored in another user-management system: a LDAP directory, a GitHub org, etc. Dex acts as a shim between a client app and the upstream identity provider. The client only needs to understand OpenID Connect to query dex, while dex implements an array of protocols for querying other user-management systems. A "connector" is a strategy used by dex for authenticating a user against another identity provider. Dex implements connectors that target specific platforms such as GitHub, LinkedIn, and Microsoft as well as established protocols like LDAP and SAML. Depending on the connectors limitations in protocols can prevent dex from issuing [refresh tokens][scopes] or returning [group membership][scopes] claims. For example, because SAML doesn't provide a non-interactive way to refresh assertions, if a user logs in through the SAML connector dex won't issue a refresh token to its client. Refresh token support is required for clients that require offline access, such as `kubectl`. Dex implements the following connectors: | Name | supports refresh tokens | supports groups claim | supports preferred_username claim | status | notes | | ---- | ----------------------- | --------------------- | --------------------------------- | ------ | ----- | | [LDAP](https://dexidp.io/docs/connectors/ldap/) | yes | yes | yes | stable | | | [GitHub](https://dexidp.io/docs/connectors/github/) | yes | yes | yes | stable | | | [SAML 2.0](https://dexidp.io/docs/connectors/saml/) | no | yes | no | stable | WARNING: Unmaintained and likely vulnerable to auth bypasses ([#1884](https://github.com/dexidp/dex/discussions/1884)) | | [GitLab](https://dexidp.io/docs/connectors/gitlab/) | yes | yes | yes | beta | | | [OpenID Connect](https://dexidp.io/docs/connectors/oidc/) | yes | yes | yes | beta | Includes Salesforce, Azure, etc. | | [OAuth 2.0](https://dexidp.io/docs/connectors/oauth/) | no | yes | yes | alpha | | | [Google](https://dexidp.io/docs/connectors/google/) | yes | yes | yes | alpha | | | [LinkedIn](https://dexidp.io/docs/connectors/linkedin/) | yes | no | no | beta | | | [Microsoft](https://dexidp.io/docs/connectors/microsoft/) | yes | yes | no | beta | | | [AuthProxy](https://dexidp.io/docs/connectors/authproxy/) | no | yes | no | alpha | Authentication proxies such as Apache2 mod_auth, etc. | | [Bitbucket Cloud](https://dexidp.io/docs/connectors/bitbucketcloud/) | yes | yes | no | alpha | | | [OpenShift](https://dexidp.io/docs/connectors/openshift/) | yes | yes | no | alpha | | | [Atlassian Crowd](https://dexidp.io/docs/connectors/atlassian-crowd/) | yes | yes | yes * | beta | preferred_username claim must be configured through config | | [Gitea](https://dexidp.io/docs/connectors/gitea/) | yes | no | yes | beta | | | [OpenStack Keystone](https://dexidp.io/docs/connectors/keystone/) | yes | yes | no | alpha | | Stable, beta, and alpha are defined as: * Stable: well tested, in active use, and will not change in backward incompatible ways. * Beta: tested and unlikely to change in backward incompatible ways. * Alpha: may be untested by core maintainers and is subject to change in backward incompatible ways. All changes or deprecations of connector features will be announced in the [release notes][release-notes]. ## Documentation See the [official documentation](https://dexidp.io/docs/) for getting started, configuration, and usage guides. ## Reporting a vulnerability Please see our [security policy](.github/SECURITY.md) for details about reporting vulnerabilities. ## Getting help - For feature requests and bugs, file an [issue](https://github.com/dexidp/dex/issues). - For general discussion about both using and developing Dex: - join the [#dexidp](https://cloud-native.slack.com/messages/dexidp) on the CNCF Slack - open a new [discussion](https://github.com/dexidp/dex/discussions) [openid-connect]: https://openid.net/connect/ [standard-claims]: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims [scopes]: https://dexidp.io/docs/custom-scopes-claims-clients/#scopes [jwt-io]: https://jwt.io/ [kubernetes]: https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens [aws-sts]: https://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html [release-notes]: https://github.com/dexidp/dex/releases ## Contributing Please see [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, guidelines, and how to submit pull requests. ## License The project is licensed under the [Apache License, Version 2.0](LICENSE). --- ## File: docs/enhancements/README.md # Dex Enhancement Proposal ## Why do we need it? Dex Enhancement Proposal (DEP) is a design document providing information to the community, or describing a new feature for Dex. We intend DEPs to be the primary mechanisms for proposing major new features or significant changes to existing ones. This will make it easier for the community to describe, track, and look through the history of changes that affected the development of the project. ## Process ### Before starting 1. Search GitHub for previous [issues](https://github.com/dexidp/dex/issues), [discussions](https://github.com/dexidp/dex/discussions) and [DEPs](https://github.com/dexidp/dex/tree/master/docs/enhancements). 2. If a discussion does not exist, [open it](https://github.com/dexidp/dex/discussions/new?category=Ideas). 3. Ensure that writing enhancement proposal is necessary for you change by discussing it with a community. ### Writing an enhancement proposal 1. Fork the repo. 2. Copy the [`docs/enhancements/_title-YYYY-MM-DD-#issue.md`](docs/enhancements/_title-YYYY-MM-DD-#issue.md) template with the appropriate name. 3. Fill all sections according to hints in them. Provide as much information as you can. 4. Submit your PR and discuss it with the Dex team. --- ## File: docs/README.md These documents have moved to the [dexidp/website repo](https://github.com/dexidp/website). --- ## File: examples/grpc-client/README.md # Running a Dex gRPC client Using gRPC, a client application can directly call methods on a server application as if it was a local object. The schema for Dex's gRPC API calls is defined in [`api/api.proto`][api-proto]. [`client.go`][client] is an example client program that makes a bunch of API calls to the dex server. For further details on the Dex API refer the [documentation][https://dexidp.io/docs/api/]. ## Generating Credentials Before running the client or the server, TLS credentials have to be setup for secure communication. Run the `cred-gen` script to create TLS credentials for running this example. This script generates a `ca.crt`, `server.crt`, `server.key`, `client.crt`, and `client.key`. ``` # Used to set certificate subject alt names. export SAN=IP.1:127.0.0.1 # Run the script ./examples/grpc-client/cert-gen ``` To verify that the server and client certificates were signed by the CA, run the following commands: ``` openssl verify -CAfile ca.crt server.crt openssl verify -CAfile ca.crt client.crt ``` ## Running the Dex server To expose the gRPC service, the gRPC option must be enabled via the dex config file as shown below. ```yaml # Enables the gRPC API. grpc: addr: 127.0.0.1:5557 tlsCert: server.crt tlsKey: server.key ``` Start an instance of the dex server with an in-memory data store: ``` ./bin/dex serve examples/grpc-client/config.yaml ``` ## Running the Dex client Finally run the Dex client providing the CA certificate, client certificate and client key as arguments. ``` ./bin/grpc-client -ca-crt=ca.crt -client-crt=client.crt -client-key=client.key ``` Running the gRPC client will cause the following API calls to be made to the server 1. CreatePassword 2. ListPasswords 3. VerifyPassword 4. DeletePassword 5. CreateClient 6. ListClients 7. DeleteClient ## Cleaning up Run the following command to destroy all the credentials files that were created by the `cert-gen` script: ``` ./examples/grpc-client/cert-destroy ``` [api-proto]: ../../api/api.proto [client]: client.go --- ## File: pkg/httpclient/readme.md # Regenerate testdata ### server.csr.cnf ``` [req] default_bits = 2048 prompt = no default_md = sha256 distinguished_name = dn [dn] C=US ST=RandomState L=RandomCity O=RandomOrganization OU=RandomOrganizationUnit emailAddress=hello@example.com CN = localhost ``` and ### v3.ext ``` authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names [alt_names] DNS.1 = localhost IP.1 = 127.0.0.1 ``` ### Then enter the following commands: `openssl genrsa -out rootCA.key 2048` `openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3650 -out rootCA.pem -config server.csr.cnf` `openssl req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key -config server.csr.cnf` `openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 3650 -sha256 -extfile v3.ext`