Commit Graph

52 Commits (0e1540b962b0dab5b1262969f2bf9ddf877bb7e0)

Author SHA1 Message Date
Jared Scheib c9e579acb2 Merge remote-tracking branch 'origin/master' into multitenancy 2017-12-05 11:43:23 -08:00
Chris Goller 0e72c0d16b Add GENERIC_API_KEY to override of oauth2 responses to support azure 2017-11-21 16:55:03 -06:00
Michael Desa 94179f8f34 Add comment of how to generate JWT tokens 2017-11-01 16:05:56 -04:00
Michael Desa e7a94c18d6 Add comments throughout codebase 2017-11-01 12:30:42 -04:00
Michael Desa 3bfed5756d Remove setting default org on Principal 2017-11-01 09:21:35 -04:00
Michael Desa 708c37dc67 WIP cleanup 2017-10-31 20:58:40 -04:00
Michael Desa 5e08464ecf Provide route to change current users organization
Add current Organization to JWT.
Use OrganizationUsersStore to retrieve Users that are not me.

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-26 18:06:52 -04:00
Tim Raymond 5b5dbee078 Merge master into feature/tr-auth0-organizations
Conflicts were the addition of CLI flags from a concurrent branch.
2017-07-07 16:18:01 -04:00
Tim Raymond 07def02ff7 Add test coverage for Auth0 organizations
This covers cases where users are or are not members of organizations as
well as whether or not they should have access to the application based
on their organization membership.
2017-06-28 16:29:52 -04:00
Tim Raymond 5a4817baf6 Support Organizations in Auth0
It's useful for operators to classify users into separate groups which
we have termed "organizations". For other OAuth providers, the notion of
an organization typically fell along company lines. For example,
MegaCorp might have a "MegaCorp" GitHub organiztion, and all email
addresses would have the domain "megacorp.com".

Auth0 is slightly different in that MegaCorp would likely run their own
Auth0 provider for their internal services, so "organizations" in Auth0
are no longer synonymous with "large organizations" (or companies).
Instead, Auth0 organizations could be used to restrict access to
Chronograf instances based on team membership within an organization.

To make use of Auth0 organizations, operators should modify users'
app_metadata to include the key "organization". Its value should be the
organization which that user belongs to. This can be done automatically
through arbitrary rules using Auth0 Rules.
2017-06-28 16:29:52 -04:00
Jade McGough 9ac59861d2 add email to auth0 required scopes 2017-06-27 16:29:51 -07:00
Tim Raymond 6c8e889b03 Add Auth0 to supported OAuth2 providers
Auth0 is an OpenID Connect compliant OAuth2 provider, so we're able to
re-use the generic OAuth2 provider to implement it. The routes required
by Auth0 have been hardcoded for user convenience.

Also, Auth0 requires users to register a subdomain of auth0.com when
signing up. This must be provided to chronograf through the
`--auth0-domain` parameter (or `AUTH0_DOMAIN` ENV). This is **distinct**
from the `PUBLIC_URL`. For example, for a Chronograf hosted at
`http://www.example.com`, and an Auth0 domain of
`http://oceanic-airlines.auth0.com`, a client-id of `notpennysboat` and a
client-secret of `4-8-15-16-23-42`, the command line options would look
like:

```
chronograf \
  --auth0-domain=http://oceanic-airlines.auth0.com \
  --auth0-client-id=notpennysboat \
  --auth0-secret=4-8-15-16-23-24
  --public-url=http://www.example.com
  -t `uuidgen`
```
2017-06-21 10:20:46 -04:00
Kent Wang a231e9f942 Add redirect url to generic oauth 2017-06-16 17:35:57 +08:00
Tim Raymond 93acebffc6 Remove broken path.Join logic
It is entirely unclear why this doesn't work.
2017-05-08 14:40:50 -07:00
Tim Raymond & Jared Scheib dcbe44d9ce Fix OAuth when using Basepath
Updated the logout link in the UI to use a link provided by the
/chronograf/v1/ endpoint. We also replaced many instances of string
concatenation of URL paths with path.Join, which better handles cases
where prefixed and suffixed "/" characters may be present in provided
basepaths. We also refactored how Basepath was being prefixed when using
Auth. Documentation was also updated to warn users that basepaths should
be applied to the OAuth callback link when configuring OAuth with their
provider.
2017-05-08 14:40:50 -07:00
Chris Goller e098045a92 Fix JWTs for auth-durations less than 5 mins (#1318)
* WIP

* Fix JWTs for auth-durations less than 5 mins

For auth-duration = 0 the JWT now understands that there does not
need to be duration checks.

For auth-duration < 5 minutes > 0 the JWT lifespan will be 1/2
of auth-duration to allow one extension

There is likely a range of very short auth-duration times like, say,
less than 5 seconds that would never allow a person to login simply
because the time of issue and request is longer.

* Update changelog
2017-04-20 17:33:08 -07:00
Chris Goller 9b40e39775 Add tests for token extend 2017-04-17 14:49:05 -05:00
Chris Goller 89ef827f94 Add comment about tokens in extending 2017-04-17 12:22:49 -05:00
Chris Goller 45e9508d31 Update oauth2 Authenticator signatures to use extend 2017-04-17 11:49:45 -05:00
Chris Goller 778cb19f57 Update JWT to use Extended rather than Extend 2017-04-17 10:57:33 -05:00
Chris Goller f6aedc85a0 Update oauth2 now time calculation to ensure UTC time 2017-04-17 10:39:01 -05:00
Chris Goller f95e6f451c Add default now time func to return UTC 2017-04-17 10:38:46 -05:00
Chris Goller 1fabed5039 Update tests for refreshing jwts 2017-04-14 02:35:30 -05:00
Chris Goller 5b692bdef3 Add JWT refresh on validation.
JWTs will only life five minutes into the future.  Any time
the server receives an authenicated request, the JWT's expire at
will be extended into the future.
2017-04-14 02:12:52 -05:00
Chris Goller bbf6c1300c Add configurable scopes to generic oauth2 support 2017-04-07 14:58:35 -05:00
Chris Goller 862e2132b6 Add renaming of generic oauth2 provider 2017-04-06 16:45:13 -05:00
Chris Goller ffd838fc26 Add test for generic oauth2 provider 2017-04-06 15:06:22 -05:00
Chris Goller 0a0753bcd0 Merge branch 'master' into feature/generic-oauth 2017-04-06 14:44:44 -05:00
Jared Scheib ac4423a6fd Add new auth duration CLI option; add client heartbeat; fix logout (#1119)
* User can now set oauth cookie session duration via the CLI to any duration or to expire on browser close

* Refactor GET 'me' into heartbeat at constant interval

* Add ping route to all routes

* Add /chronograf/v1/ping endpoint for server status

* Refactor cookie generation to use an interface

* WIP adding refreshable tokens

* Add reminder to review index.js Login error handling

* Refactor Authenticator interface to accommodate cookie duration and logout delay

* Update make run-dev to be more TICKStack compliant

* Remove heartbeat/logout duration from authentication

* WIP Refactor tests to accommodate cookie and auth refactor

* Update oauth2 tests to newly refactored design

* Update oauth provider tests

* Remove unused oauth2/consts.go

* Move authentication middleware to server package

* Fix authentication comment

* Update authenication documentation to mention AUTH_DURATION

* Update /chronograf/v1/ping to simply return 204

* Fix Makefile run-dev target

* Remove spurious ping route

* Update auth docs to clarify authentication duration

* Revert "Refactor GET 'me' into heartbeat at constant interval"

This reverts commit 298a8c47e1431720d9bd97a9cb853744f04501a3.

Conflicts:
ui/src/index.js

* Add auth test for JWT signing method

* Add comments for why coverage isn't written for some areas of jwt code

* Update auth docs to explicitly mention how to require re-auth for all users on server restart

* Add Duration to Validation interface for Tokens

* Make auth duration of zero yield a everlasting token

* Revert "Revert "Refactor GET 'me' into heartbeat at constant interval""

This reverts commit b4773c15afe4fcd227ad88aa9d5686beb6b0a6cd.

* Rename http status constants and add FORBIDDEN

* Heartbeat only when logged in, notify user if heartbeat fails

* Update changelog

* Fix minor word semantics

* Update oauth2 tests to be in the oauth2_test package

* Add check at compile time that JWT implements Tokenizer

* Rename CookieMux to AuthMux for consistency with earlier refactor

* Fix logout middleware

* Fix logout button not showing due to obsolete data shape expectations

* Update changelog

* Fix proptypes for logout button data shape in SideNav
2017-04-06 11:40:57 -07:00
Chris Goller 94afc97beb Add implementation of generic oauth2 provider based on github concepts 2017-04-06 10:19:07 -05:00
Chris Goller 9ac300cf19 Update to fix go linter issues 2017-03-06 10:11:52 -06:00
Chris Goller f60a358751 Merge branch 'master' into feature/#54-tr-enterprise-client
Conflicts:
	Makefile
	chronograf.go
	server/routes.go
	server/users.go
2017-02-23 23:26:09 -06:00
Tim Raymond 22a556e964 Add organization restriction on Heroku provider
This allows operators to permit access to Chronograf only to users belonging
to a set of specific Heroku organizations. This is controlled using the
HEROKU_ORGS env or the --heroku-organizations switch.
2017-02-21 13:09:42 -05:00
Tim Raymond 3c62eaa93c Update/Cleanup OAuth2 documentation
Information on setting up Heroku and Google authentication has been
added. Also, the information about the design has been updated and moved
to the oauth2 package docs along with updated diagrams to match with
developer expectations about where design-related documentation should
be found.
2017-02-21 11:04:01 -05:00
Tim Raymond de3badc4a7 Improve documentation for oauth2 package
Adds a diagram showing how all the pieces fit together and a short
description.
2017-02-17 17:08:11 -05:00
Tim Raymond f48487771c Rename JWTMux to CookieMux
JWTMux was a disingenuous name because while JWTs are a very good choice
for a cookie encoding, they were not strictly required for use with this
mux. To better indicate the responsibilities of this mux, it's been
renamed "CookieMux," since its responsibilities end with persisting the
oauth2.Authenticator's encoded state in the browser. It is up to the
oauth2.Authenticator to choose the encoding.
2017-02-17 12:57:08 -05:00
Tim Raymond 6a96d2b745 Add test for oauth2.Callback() handler
This test ensures that the Callback handler sets a cookie in its
response to the browser when the provider returns a 200
2017-02-17 12:41:14 -05:00
Tim Raymond cde17a3837 Add test for (*JWTMux).Login()
Ensures that state is send properly to Provider.
2017-02-16 17:29:34 -05:00
Tim Raymond 322d14103a Reorganize OAuth2 Test Helpers
Moved all test helper structs and funcs under oauth2/oauth2_test.go
2017-02-16 17:27:55 -05:00
Tim Raymond 6ae180d5e7 Add tests around oauth2.JWTMux
Adds a test for Logout() handler.
2017-02-16 16:42:43 -05:00
Chris Goller cfa4d15efa Add google OAuth2 principal domain/email test 2017-02-16 13:36:37 -06:00
Chris Goller 06d314598d Add Github OAuth2 principal email/org tests 2017-02-16 13:26:08 -06:00
Tim Raymond d426193597 Configure Heroku OAuth2 properly
This was erroneously left unconfigured during dev.
2017-02-16 12:56:01 -05:00
Tim Raymond 6b9c642699 Add Heroku Oauth2 Provider
This adds an Oauth2 Provider for authenticating users against Heroku's
API. In contrast to other Providers, a maintained client library for
interacting with the Heroku API was not available, so direct HTTP calls
are made instead. This follows with their documentation posted here:
https://devcenter.heroku.com/articles/oauth2-heroku-go
2017-02-16 12:05:55 -05:00
Chris Goller fa36ac6149 Add unified OAuth2 logout route redirecting to provider logout
Signed-off-by: Tim Raymond <tim@timraymond.com>
2017-02-15 16:29:13 -06:00
Chris Goller 703af8c3da Fix go test failures from code moving 2017-02-14 23:38:43 -06:00
Chris Goller 2d691bb694 Add --public-url CLI option to support google oauth redirect uri 2017-02-14 23:34:15 -06:00
Chris Goller ae5e4edacf Add google oauth provider. Need redirect_uri 2017-02-14 23:11:11 -06:00
Chris Goller 9c3ffed99e Remove unneeded authenticator from github 2017-02-14 23:09:34 -06:00
Tim Raymond 1a80a6c4d5 Doc++ 2017-02-14 17:28:38 -05:00