Commit Graph
100 Commits
Author SHA1 Message Date
Eric Chiang 50f2905cac *: add standup script for LDAP 2017-08-22 10:37:29 -07:00
Eric Chiang aad328bb35 *: add log events for login, LDAP queries, and SAML responses 2017-08-11 12:00:06 -07:00
Eric Chiang c1a7285711 examples: document explicit flow in example config 2017-06-23 11:27:49 -07:00
Eric Chiang 95334ad51d Documentation: add docs on public clients 2017-05-09 17:09:49 -07:00
Eric Chiang fcb9c5a1c4 server: fix localhost redirect validation for public clients 2017-05-09 17:09:20 -07:00
Eric Chiang c400e860fe Documentation: more diagrams 2017-04-21 14:51:46 -07:00
Eric Chiang 8a7665b5a1 README.md: reorganize README
* Highlights that dex is NOT a user-management system.
* Highlights ID Tokens as dex's primary feature.
* General cleanup.
2017-04-21 14:51:46 -07:00
Eric Chiang a4cb57ab5d Documentation: add a doc describing how to use dex 2017-04-21 11:35:34 -07:00
Eric Chiang 49e05b95c0 *: update maintainers 2017-04-21 09:39:31 -07:00
Eric Chiang a12d2f85a8 README: add section about reporting security vulnerabilities
It was pointed out by @davidillsley that we don't point this out
anywhere in our docs.
2017-04-19 13:42:03 -07:00
Eric Chiang ba1660ae1f *: revendor and regenerate protobuf files 2017-04-13 11:35:41 -07:00
Eric Chiang ef376b9c69 *: update grpc and correct protobuf generation
Turns out that manually setting PATH in the Makefile doesn't work
so we've been using the protobuf plugins installed on the host. Fix
this by specifying plugins by path.
2017-04-13 11:32:19 -07:00
Eric Chiang 74f5eaf47e connector/ldap: support the StartTLS flow for secure connections
When connecting to an LDAP server, there are three ways to connect:

1. Insecurely through port 389 (LDAP).
2. Securely through port 696 (LDAPS).
3. Insecurely through port 389 then negotiate TLS (StartTLS).

This PR adds support for the 3rd flow, letting dex connect to the
standard LDAP port then negotiating TLS through the LDAP protocol
itself.

See a writeup here:

http://www.openldap.org/faq/data/cache/185.html
2017-04-12 15:25:42 -07:00
Eric Chiang 00b5c99ffc connector/saml/testdata: fix bad status test case
Notice this when inspecting the code coverage results. For some
reason this test wasn't triggering the bad status code path, maybe
due to signature validation. Removing the comment fixed the code
coverage.
2017-04-11 17:20:29 -07:00
Eric Chiang 5f377f07d4 *: promote SAML to stable
This means we no longer refer to it as "experimental" and wont make
breaking changes.
2017-04-11 10:09:48 -07:00
Eric Chiang cf089025ae *: add GitLab connector to README 2017-04-11 10:04:48 -07:00
Eric Chiang 97813ff4fc connector/ldap: fix case where groups are listed on the user entity
Support schemas that determine membership by having fields on the
user entity, instead of listing users on a groups entity. E.g. the
following schema is now supported when it wasn't previously:

    cn=eric,cn=user,dn=exapmle,dn=com
    objectClass=myPerson
    cn: eric
    uid: eric
    email: eric@example.com
    memberOf: foo
    memberOf: bar

    cn=foo,cn=group,dn=exapmle,dn=com
    objectClass=myGroup
    cn: foo

    cn=bar,cn=group,dn=exapmle,dn=com
    objectClass=myGroup
    cn: bar
2017-04-11 09:48:48 -07:00
Eric Chiang b8ba59d7f6 *: run LDAP tests in travis 2017-04-10 15:33:07 -07:00
Eric Chiang 0ac11d93e6 connector/ldap/testdata: add LDAP schema files 2017-04-10 15:33:07 -07:00
Eric Chiang 4a93b55c8b connector/ldap: add LDAP integration tests 2017-04-10 15:33:07 -07:00
Eric Chiang 362e0798a4 connector/saml: clean up SAML verification logic and comments 2017-04-07 14:13:05 -07:00
Eric Chiang a97cffcd52 connector/saml: refactor tests and add self-signed responses
Introduces SAML tests which execute full response processing and
compare user attributes. tesdata now includes a full, self-signed
CA and documents signed using xmlsec1.

Adds deprication notices to existing tests, but don't remove them
since they still provide coverage.
2017-04-04 11:11:35 -07:00
Eric Chiang e0709dc2ac connector/saml: fix validation bug with multiple Assertion elements
When a SAML response provided multiple Assertion elements, only the
first one is checked for a valid signature. If the Assertion is
verified, the original Assertion is removed and the canonicalized
version is prepended to the Response. However, if there were
multiple assertions, the second assertion could end up first in the
list of Assertions, even if it was unsigned.

For example this:

    <Response>
      <!--
         Response unsigned. According to SAML spec must check
         assertion signature.
      -->
      <Assertion>
        <Signature>
          <!-- Correrctly signed assertion -->
        </Signature>
      </Assertion>

      <Assertion>
        <!-- Unsigned assertion inserted by attacker-->
      </Assertion>
    </Response>

could be verified then re-ordered to the following:

    <Response>
      <!--
         Response unsigned. According to SAML spec must check
         assertion signature.
      -->
      <Assertion>
        <!-- Unsigned assertion inserted by attacker-->
      </Assertion>

      <Assertion>
        <!-- Canonicalized, correrctly signed assertion -->
      </Assertion>
    </Response>

Fix this by removing all unverified child elements of the Response,
not just the original assertion.
2017-04-04 11:11:35 -07:00
Eric Chiang 5e34f0d1a6 Documentation: document dex scopes, claims, and client features 2017-03-28 16:53:06 -07:00
Eric Chiang f734b140cd server: use client connected to remove server for gRPC tests 2017-03-28 16:41:39 -07:00
Eric Chiang 9b0e9ab2ca cmd/example-app: fix custom CA behavior 2017-03-24 11:53:28 -07:00
Eric Chiang 50b223a9db *: validate InResponseTo SAML response field and make issuer optional 2017-03-22 13:02:44 -07:00
Eric Chiang 910d59865b vendor: revendor 2017-03-21 09:27:22 -07:00
Eric Chiang 5888220965 glide.yaml: update goxmldsig 2017-03-21 09:25:56 -07:00
Eric Chiang 4c39bc20ae storage: make static storages query real storages for some actions
If dex is configured with static passwords or clients, let the API
still add or modify objects in the backing storage, so long as
their IDs don't conflict with the static ones. List options now
aggregate resources from the static list and backing storage.
2017-03-20 09:39:38 -07:00
Eric Chiang 33f0199077 *: fix spelling using github.com/client9/misspell 2017-03-20 09:16:56 -07:00
Eric Chiang f503ff7950 *: add documentation for the OpenID Connect provider 2017-03-20 08:47:02 -07:00
Eric Chiang ac032e99f0 connector/oidc: expose oauth2.RegisterBrokenAuthHeaderProvider 2017-03-20 08:47:02 -07:00
Eric Chiang 6cb38604d9 storage/kubernetes: log INFO level if TPR already exists, not ERROR 2017-03-15 10:30:10 -07:00
Eric Chiang 0481fccd76 storage/sql: add missing WHERE statement to refresh token update 2017-03-13 15:53:28 -07:00
Eric Chiang ee27a4f9f4 *: only use docker when releasing, update to Go 1.8, remove aci scripts
This change modifies our release process to only require Docker
when building a release and updates our released binary to use Go
1.8. It also removes our .aci scripts, which we've not been
regularly building.

A nice consequence is that OSX users can now build a release image.
2017-03-09 10:46:09 -08:00
Eric Chiang e5f60fe9dd vendor: revendor 2017-03-08 10:33:36 -08:00
Eric Chiang 777eeafabc *: update go-oidc and use standard library's context package 2017-03-08 10:33:19 -08:00
Eric Chiang 2c4752d5d4 server: fix expiry detection for verification keys 2017-03-01 12:43:45 -08:00
Eric Chiang 38c77e0f33 storage/kubernetes: enable HTTP/2 support 2017-02-28 12:42:06 -08:00
Eric Chiang a7b8e52b92 storage/kubernetes: fix conflict error detection in TRP creation
PR #815 fixed the Kubernetes storage implementation by correctly
returning storage.ErrAlreadyExists on POST conflicts. This caused a
regression in TPR creation (#822) when some, but not all, of the
resources already existed. E.g. for users upgrading from old
versions of dex.

Fixes #822
2017-02-27 11:01:47 -08:00
Eric Chiang 1da2ae279c storage/kubernetes: fix hash initialization bug 2017-02-24 12:55:04 -08:00
Eric Chiang 4be029c6c1 storage/kubernetes: fix kubernetes storage conformance test failures 2017-02-23 19:23:19 -08:00
Eric Chiang 80038847de server: clean up test comments and code flow 2017-02-07 10:31:51 -08:00
Eric Chiang adf3703962 Documentation: warn admins not to edit dex ThirdPartyResources manually 2017-02-06 10:35:27 -08:00
Eric Chiang 72a431dd4b {web,server}: use html/template and reduce use of auth request ID
Switch from using "text/template" to "html/template", which provides
basic XSS preventions. We haven't identified any particular place
where unsanitized user data is rendered to the frontend. This is
just a preventative step.

At the same time, make more templates take pure URL instead of
forming an URL themselves using an "authReqID" argument. This will
help us stop using the auth req ID in certain places, preventing
garbage collection from killing login flows that wait too long at
the login screen.

Also increase the login session window (time between initial
redirect and the user logging in) from 30 minutes to 24 hours,
and display a more helpful error message when the session expires.

How to test:

1. Spin up dex and example with examples/config-dev.yaml.
2. Login through both the password prompt and the direct redirect.
3. Edit examples/config-dev.yaml removing the "connectors" section.
4. Ensure you can still login with a password.

(email/password is "admin@example.com" and "password")
2017-02-02 11:11:00 -08:00
Eric Chiang 8541184afb server: support POSTing to authorization endpoint
Fixes #791
2017-01-27 11:42:46 -08:00
Eric Chiang 1eda382789 server: add at_hash claim support
The "at_hash" claim, which provides hash verification for the
"access_token," is a required claim for implicit and hybrid flow
requests. Previously we did not include it (against spec). This
PR implements the "at_hash" logic and adds the claim to all
responses.

As a cleanup, it also moves some JOSE signing logic out of the
storage package and into the server package.

For details see:

https://openid.net/specs/openid-connect-core-1_0.html#ImplicitIDToken
2017-01-13 10:05:24 -08:00
Eric Chiang ed20fee2b9 cmd/example-app: fix refreshing 2017-01-11 12:07:48 -08:00
Eric Chiang f4bbab5056 server/internal: generate protobuf types 2017-01-11 12:07:48 -08:00
Eric Chiang f778b2d33b server: update refresh tokens instead of deleting and creating another
The server implements a strategy called "Refresh Token Rotation" to
ensure refresh tokens can only be claimed once.

ref: https://tools.ietf.org/html/rfc6819#section-5.2.2.3

Previously "refresh_token" values in token responses where just the
ID of the internal refresh object. To implement rotation, when a
client redeemed a refresh token, the object would be deleted, a new
one created, and the new ID returned as the new "refresh_token".

However, this means there was no consistent ID for refresh tokens
internally, making things like foreign keys very hard to implement.
This is problematic for revocation features like showing all the
refresh tokens a user or client has out.

This PR updates the "refresh_token" to be an encoded protobuf
message, which holds the internal ID and a nonce. When a refresh
token is used, the nonce is updated to prevent reuse, but the ID
remains the same. Additionally it adds the timestamp of each
token's last use.
2017-01-11 12:07:48 -08:00
Eric Chiang 312ca7491e storage: add extra fields to refresh token and update method 2017-01-11 12:07:48 -08:00
Eric Chiang f926d74157 server: fixes for the implicit and hybrid flow
Accept the following response_type for the implicit flow:

    id_token
    token id_token

And the following for hybrid flow

    code id_token
    code token
    code token id_token

This corrects the previous behavior of the implicit flow, which
only accepted "token" (now correctly rejected).
2017-01-10 16:20:17 -08:00
Eric Chiang 7ea2d24011 vendor: revendor 2017-01-09 18:30:58 -08:00
Eric Chiang 78665074ed cmd/example-app: add option to not request a refresh token 2017-01-09 18:30:58 -08:00
Eric Chiang 0f4a1f69c5 *: wire up SAML POST binding 2017-01-09 18:30:58 -08:00
Eric Chiang 31dfb54b6f connector: add a SAML connector 2017-01-09 18:30:58 -08:00
Eric Chiang 1451213dd7 vendor: revendor 2016-12-22 11:52:37 -08:00
Eric Chiang d87a4c35b9 *: add 'make revendor' and tests to catch incorrect glide usage
Introducing glide-vc caused us to unknowingly removed our Go
protobuf compiler (since it's a main). Add flags to glide-vc usage
to remedy this.

Since we now require several glide and glide-vc flags, add a Makfile
target and tests to catch when PRs don't use the correct flags.
2016-12-22 11:52:24 -08:00
Eric Chiang fd20b213bb storage: fix postgres timezone handling
Dex's Postgres client currently uses the `timestamp` datatype for
storing times. This lops of timezones with no conversion, causing
times to lose locality information.

We could convert all times to UTC before storing them, but this is
a backward incompatible change for upgrades, since the new version
of dex would still be reading times from the database with no
locality.

Because of this intrinsic issue that current Postgres users don't
save any timezone data, we chose to treat any existing installation
as corrupted and change the datatype used for times to `timestamptz`.
This is a breaking change, but it seems hard to offer an
alternative that's both correct and backward compatible.

Additionally, an internal flag has been added to SQL flavors,
`supportsTimezones`. This allows us to handle SQLite3, which doesn't
support timezones, while still storing timezones in other flavors.
Flavors that don't support timezones are explicitly converted to
UTC.
2016-12-16 11:46:49 -08:00
Eric Chiang 4d54038256 examples: add logger fields 2016-12-15 13:47:37 -08:00
Eric Chiang 50086e6863 cmd/dex: provide better feedback when parsing config 2016-12-15 13:47:25 -08:00
Eric Chiang 998350db74 *: add go report card to README 2016-12-13 12:24:27 -08:00
Eric Chiang fe196864c0 *: fix comment typos found with github.com/client9/misspell 2016-12-13 12:23:16 -08:00
Eric Chiang 18bbd94fba *: check go version before building
Add a script to check the Go version before building dex. This
gives a nice error message rather than just failing to compile.

With changes:

    $ go version
    go version go1.6.4 linux/amd64
    $ make
    ERROR: dex requires Go version 1.7+. Please update your Go installation: https://golang.org/dl/
    Makefile:93: recipe for target 'check-go-version' failed
    make: *** [check-go-version] Error 2

Checks only added for building the actual binary, not tests, since
this is aimed at users just starting off with the project.
2016-12-13 12:03:27 -08:00
Eric Chiang 566bb2d1af Documentation: add notes on patch release branches 2016-12-12 15:29:00 -08:00
Eric Chiang faf6a0e680 *: add section about dex and Kubernetes to README 2016-12-12 11:23:39 -08:00
Eric Chiang 1e0cf3c068 connector/ldap: default email_verified to true 2016-12-09 13:22:19 -08:00
Eric Chiang 6dbe6e8ab5 Documentation: add examples of mapping LDAP schema to a search 2016-12-09 09:42:28 -08:00
Eric Chiang 879e018f74 storage/kubernetes: remove unused method 2016-12-08 16:42:18 -08:00
Eric Chiang 89033c2e05 vendor: revendor using glide-vc 2016-12-07 13:23:19 -08:00
Eric Chiang a500de802b glide.yaml: update inline comments 2016-12-07 13:23:19 -08:00
Eric Chiang e2aa095680 Documentation: add document on managing dependencies 2016-12-07 13:23:19 -08:00
Eric Chiang 8e126607ce *: add Travis build status to README 2016-12-07 10:22:33 -08:00
Eric Chiang 5e61d5fe83 Revert "Merge pull request #714 from amrutac/refactor-css"
This reverts commit 4d88eabb50, reversing
changes made to b38d355202.
2016-12-01 13:18:32 -08:00
Eric Chiang 7a3658acdf vendor: revendor 2016-12-01 13:16:14 -08:00
Eric Chiang 3b99e8f22a *: update vendored go-oidc
Includes fixes for a panic when using HTTP/2[0] and some HTTPs calls
not actually using their passed context[1].

[0] https://github.com/coreos/go-oidc/pull/117
[1] https://github.com/coreos/go-oidc/pull/119
2016-12-01 13:13:27 -08:00
Eric Chiang aebb6818b7 cmd/example-app: use a non-empty state
Use a non-empty state in the example-app to ensure dex is properly
preserving the state for the code flow.

Updates #712
2016-12-01 09:05:56 -08:00
Eric Chiang 391dc51c13 *: add theme based frontend configuration
This PR reworks the web layout so static files can be provided and
a "themes" directory to allow a certain degree of control over logos,
styles, etc.

This PR does NOT add general support for frontend customization,
only enough to allow us to start exploring theming internally.
The dex binary also must now be run from the root directory since
templates are no longer "compiled into" the binary.

The docker image has been updated with frontend assets.
2016-11-30 17:20:21 -08:00
Eric Chiang 8b8c076ecf Documentation: clarify difference between LDAP ports and security guarantees
Now that LDAP supports an `insecureSkipVerify` option, clarify that
`insecureNoTLS` is an extremely bad choice and as such we may drop
support for 389 in the future.

However, since we send plain text passwords from our frontend to our
backend, this probably gets us into a bigger conversation about dex's
TLS story. For example when terminiation is approporate. cc'ing
@dghubble for thoughts on how that might apply to our internal uses.

We probably want an overaching security doc at some point, but that
can be another PR.
2016-11-23 12:26:44 -08:00
Eric Chiang a876ab37af vendor: revendor 2016-11-22 13:29:17 -08:00
Eric Chiang 522749b5d8 *: switch oidc client to github.com/coreos/go-oidc
This saves us from having to import two different versions of
square/go-jose.
2016-11-22 13:29:17 -08:00
Eric Chiang 6980920a3a *: document the GitHub connector 2016-11-22 12:53:46 -08:00
Eric Chiang 55e97d90a6 *: add tests for the RefreshConnector 2016-11-22 12:53:46 -08:00
Eric Chiang 952e0f81f5 connector: add RefreshConnector interface 2016-11-22 12:53:46 -08:00
Eric Chiang baa9096b6e *: small README link additions 2016-11-18 17:07:10 -08:00
Eric Chiang ae4c32bc3b connector/ldap: use gopkg.in/ldap.v2's escape filter
Use the escape filter method provided by the upstream LDAP package
instead of rolling our own.
2016-11-18 15:16:40 -08:00
Eric Chiang 5c602d36d9 server: fix expiry test flake
Ensure compared times are within a second of one another instead of
rounding, which can flake if the two times are different enough to
do round to different values.

Tested using the golang.org/x/tools/cmd/stress tool.

The following set of commands fail without this patch:

    $ go get golang.org/x/tools/cmd/stress
    $ go test -o server.test github.com/coreos/dex/server
    $ stress ./server.test -test.run=TestOAuth2CodeFlow
    219 runs so far, 0 failures
    425 runs so far, 0 failures
    618 runs so far, 0 failures
    802 runs so far, 0 failures
    ^C

Closes #699
2016-11-18 13:47:16 -08:00
Eric Chiang 3ecfaf700e examples/k8s: update kubernetes examples 2016-11-17 14:10:55 -08:00
Eric Chiang 2b20c4565f *: remove TODO.md file
This existed for when we were developing v2 but v1 was using the
issue tracker. We've since moved these goals to the issue tracker.
2016-11-17 10:53:11 -08:00
Eric Chiang ff119d1556 Dockerfile: add OpenSSL to Docker container
Add OpenSSL to the dex Docker container so wget can be used to query
HTTPS endpoint. This is a requirement for health checking when dex is
doing its own TLS termination.

This increased the image size from 20.37 MB to 20.92 MB (+550 KB).

Additionally add Ed and Rithu as maintainers.
2016-11-14 17:25:19 -08:00
Eric Chiang 447253c8de README: add link on v2 and section on getting help 2016-11-08 15:29:13 -08:00
Eric Chiang a52e324f68 *: readme updates for v2 2016-11-08 14:36:29 -08:00
Eric Chiang 2417fc9154 Documentation/logos: add logos 2016-11-08 11:51:47 -08:00
Eric Chiang 12a5c0ada3 server: use seconds instead of nano seconds for expires_in and expiry 2016-11-04 17:00:10 -07:00
Eric Chiang c9889683b4 Documentation: add doc describing v2 changes 2016-11-04 16:56:21 -07:00
Eric Chiang 015e7cf606 cmd/dex: only expand from env for storages and connectors
Bcrypt'd hashes have "$" characters in them. This means that #667
(accepting actually bcrypted values) combined with #627 (expanding
config with environment variables) broke the example config.

For now, allow storages and connectors to expand their configs from
the environment, but don't do this anywhere else.
2016-11-03 21:38:32 -07:00
Eric Chiang 35d6423ac2 cmd/example-app: add a --debug flag 2016-11-03 21:36:15 -07:00
Eric Chiang 0f31566b27 connector: accept base64 encoded CA and add convience open method 2016-11-03 16:28:23 -07:00
Eric Chiang 59240f93b1 vendor: revendor 2016-11-03 15:24:47 -07:00