Commit Graph

377 Commits (1371c6afad28d2e44c46a8333ba76bf37ccd83fe)

Author SHA1 Message Date
Tim Raymond 734414c479 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
Jared Scheib be1b7dfcdf Clarify error output for missing Name or URL 2017-06-27 13:40:26 -07:00
Jared Scheib 21fab035c2 Error out server if CustomLinks invalid on run
Signed-off-by: Chris Goller <goller@gmail.com>
2017-06-27 13:31:35 -07:00
Jared Scheib c637e5407d Refactor links_test to use table test and cleaner error check
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-06-27 13:30:34 -07:00
Jared Scheib 2e93ad5230 Conserve memory allocation for customLinks slice
Signed-off-by: Chris Goller <goller@gmail.com>
2017-06-27 12:00:05 -07:00
Jared Scheib 3fea7501d8 Remove omitempty from CustomLink definition since should never b 2017-06-27 11:02:28 -07:00
Jared Scheib 48e90fcd0a Return and test for nil on invalid NewCustomLink input 2017-06-27 10:59:04 -07:00
Jared Scheib 578bf89c97 Pass through CustomLinks error message directly 2017-06-26 18:02:22 -05:00
Jared Scheib 604faea32d Add full test coverage for NewCustomLinks 2017-06-26 17:18:53 -05:00
Jared Scheib ca239d037d Move external links structs to links.go 2017-06-26 16:13:23 -05:00
Jared Scheib 81ada5315c Only test one CustomLink to avoid map key order failing test 2017-06-26 16:12:54 -05:00
Jared Scheib 6e59d8ce34 Add custom links to routes test 2017-06-26 16:00:27 -05:00
Jared Scheib a723ef8ae1 Use appropriate error when NewCustomLinks fails 2017-06-26 15:44:56 -05:00
Jared Scheib 6dedf77add Comment CustomLink struct 2017-06-26 15:43:03 -05:00
Jared Scheib ede2476837 Change 'Url' prop key to 'URL' to satisfy Go convention 2017-06-26 15:42:36 -05:00
Jared Scheib 799dc64ea4 Update comment for ServeHTTP to mention External Links 2017-06-26 15:35:42 -05:00
Jared Scheib 90aaa8104d Refactor CustomLinks transform into routes.go and new links.go
Rename generateCustomLinks to NewCustomLinks
Handle error from NewCustomLinks per app convention
2017-06-26 15:30:33 -05:00
Jared Scheib 1b3c00d07a Add 'custom' prop and example to /chronograf/v1 in swagger docs 2017-06-26 11:56:05 -07:00
Jared Scheib 7d6eaf925a Generate custom links from env var and multiple CLI flags
Signed-off-by: Chris Goller <goller@gmail.com>
2017-06-26 11:48:47 -07:00
Jared Scheib 613dcc64ac WIP Parse custom links from CLI 2017-06-23 15:12:02 -07:00
Tim Raymond 07a3dceb2f 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
Timothy J. Raymond 21c3f78fe3 Merge pull request #1619 from pragkent/generic-oauth-redirect-url
Add redirect url to generic oauth
2017-06-21 10:19:03 -04:00
Kent Wang fdcbd6badc Fix generic redirect URL 2017-06-21 12:19:21 +08:00
Kent Wang 55093d720d Replace string concat to path.Join 2017-06-18 10:47:02 +08:00
Kent Wang 25958a017e Don't pass RedirectURL if PublicURL not set 2017-06-18 10:40:07 +08:00
Jared Scheib 2f4695fa0b Merge branch 'master' into feature/status_page-1556 2017-06-16 17:52:16 -07:00
Jared Scheib 06dd8a7a3d Update default JSON feed URL to final, secure link 2017-06-16 14:23:46 -07:00
Kent Wang b4627983b9 Add redirect url to generic oauth 2017-06-16 17:35:57 +08:00
Jared Scheib 2ff86cf15e Update swagger docs for external and statusFeed props 2017-06-15 18:23:42 -07:00
Jared Scheib c8c3f6108c Comment new StatusFeed member of AllRoutes 2017-06-15 17:55:46 -07:00
Jared Scheib 7e359239e5 Refactor statusFeedURL to be set in CLI 'default'
Reverts to a clean separation of concerns between mux.go vs AllRoutes
AllRoutes now expects a StatusFeed url directly
2017-06-15 13:51:22 -07:00
Jared Scheib 2c5e7ef0d6 Add test for all routes with ExternalLinks 2017-06-14 16:22:30 -07:00
Jared Scheib f4ea8fc7b5 Remove unused fragment 2017-06-14 13:51:08 -07:00
Tim Raymond c5872bba41 correct TemplateVar collection type in Queries 2017-06-14 10:52:29 -04:00
Jared Scheib 8af550fa6f Add default InfluxData JSON feed url 2017-06-13 19:23:52 -07:00
Jared Scheib 25bde527a6 Add status-feed-url build flag within new externalLinks prop in AllRoutes 2017-06-13 13:40:20 -07:00
Tim Raymond 45402f476d Add support for :autoGroupBy: template variable
This adds support for dynamic template variables that compute something
about themselves given some additional context.
2017-06-13 14:59:56 -04:00
Hunter Trujillo 816a8b9226 Update swagger docs. 2017-06-12 15:30:10 -06:00
Regan Kuchan 6da83b8629 Update version and changelog for v1.3.2.0 2017-06-02 13:34:23 -06:00
Jared Scheib 6806f62ac0 Refactor /chronograf/v1 to not return logoutLink if not using auth
Use logoutLink to determine if logout menu item is shown

Signed-off-by: Chris Goller <güllère@gmail.com>
2017-05-30 17:34:55 -07:00
Chris Goller 7122c6a19d Add kapacitor rule validation on update 2017-05-25 12:10:25 -05:00
Chris Goller 8d8ffd2bf5 Fix kapacitor PUT/POST returning request rather than response 2017-05-24 15:30:45 -07:00
Regan Kuchan 5848660f97 Update version number and bumpversion 2017-05-22 11:57:23 -07:00
Tim Raymond b7bb23720f Fix infinite spinner with /chronograf basepath
When using a basepath of /chronograf, the app would present a
never-ending spinner when visiting the root route. This was because the
prefixingRedirector middleware which is responsible for appending the
basepath to redirects from downstream http.Handlers thought that the
prefix was already appended since it saw `/chronograf/v1`. In reality,
it should have produced a location like `/chronograf/chronograf/v1`.

The solution was to look beyond the first instance of a prefix and check
for the presence of another prefix to detect if a prefix was already
applied by a downstream handler.
2017-05-09 12:12:42 -07:00
Chris Goller 99099e8a5c Update version to 1.3 for javascript and swagger 2017-05-09 08:24:04 -07:00
Tim Raymond 24160ed6ef Force prefixing in several locations
The Basepath option should be applied in anything that will be consumed
by the React application. This is because from its perspective, the
proxy sitting between it and the backend wants those prefixes regardless
of what it does with them before handing the request back to the
Chronograf backend. Consequently, there's situations in the backend
where we need to have the `opts.Basepath` or the `basepath` that we
alter when `opts.PrefixRoutes` is set. The `basepath` is strictly for
altering routing decisions made by the backend.

There's subtle places where routes are supplied to the frontend that
need to always have the `opts.Basepath` set as well. Another commit
addressed the "Location" header of Redirects, for example.
2017-05-08 14:40:50 -07:00
Tim Raymond 5cf21f6cbd Add PrefixedRedirect function
The router that we use has a feature that will automatically redirect
routes in certain situations where it feels a trailing slash would be
appropriate. Because the underlying router is totally unaware of
upstream prefixing activity, the "Location" that it sends clients to is
incorrect because it doesn't have the prefix.

This introduces a middleware that catches any downstream 3XX class
responses and replaces the Location header with the prefixed version of
it, plus a trailing slash. It does this only when the prefix has not
been applied already by some downstream middleware.
2017-05-08 14:40:50 -07:00
Tim Raymond ccf7964e78 Add HTTP status code to logs
This adds the status code to the response log message to make it easier
to diagnose issues. It also replaces the placeholder "Success" message
with the decoded value of the HTTP Status, resulting in messages like:

INFO[0041] Response: Temporary Redirect                  code=307

...and so on. Both easily consumable by humans and machines.
2017-05-08 14:40:50 -07:00
Tim Raymond 33e5eb0e30 Use Basepath over string concatenation
Basepath was previously not working here because the strings constructed
via concatenation had a trailing slash at the end:

Before:
  rootPath => "/someprefix/chronograf/v1/"

After:
  rootPath => "/someprefix/chronograf/v1"

The julienschmidt/httprouter that the bouk/httprouter is based on has
support for ignoring trailing slashes, which is behavior that we want.
However, routing decisions involving this rootPath string were being
made by a `strings.HasPrefix` function. This conditional seeks to
apply the token middleware only in cases where routes _under_
`/chronograf/v1` are accessed (e.g. `/chronograf/v1/sources`). In cases
where the paths were effectively equal, this conditional accidentally
worked because the string `/chronograf/v1` does not have the prefix
`/chronograf/v1/`. When this was corrected to use `path.Join`, this case
became true and caused the token middleware to be applied.

`path.Join` is the correct way to construct paths, since this prevents
issues where a fragment like `/foo/` is concatenated with a fragment
like `/bar/quux/` to yield the string `/foo//bar/quux/`.

Given that continuing to use concatenation is no longer an option, the
solution is to compare the lengths of the strings to ensure that the
path under comparison is longer than the prefix it's being tested
against. This guarantees that the subject path is a route underneath the
`/chronograf/v1` route.
2017-05-08 14:40:50 -07:00
Tim Raymond 5897e62928 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 337c7b16a5 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
Tim Raymond 7a9ca4a397 Add logging of response times
This makes monitoring Chronograf 👍
2017-05-08 14:40:50 -07:00
Jared Scheib 9c7fb0904b Notify user about --prefix-routes when using --basepath 2017-05-08 14:40:50 -07:00
Chris Goller d16286c505 Fix null queryConfig and add substantial test coverage to kapacitor
storage
2017-05-05 16:14:02 -05:00
Chris Goller 8aaed06402 Update Kapacitor alerts to set queryConfig to null if not parsable. 2017-05-05 14:30:20 -05:00
Andrew Watkins 014103adf6 Resolve conflicts
Conflicts:
	ui/src/utils/influxql.js
2017-05-05 10:01:26 -07:00
Chris Goller ce6229168d Merge branch 'master' into feature/influx-write 2017-05-05 08:10:14 -05:00
Chris Goller 94fd7ef164 Update influxql AST parsing to return full binary exprs (#1380) 2017-05-03 15:57:19 -07:00
Chris Goller 86575b2cde Add line-protocol /write endpoint to all data sources 2017-05-03 00:06:40 -05:00
Chris Goller 6ee108d5b7 Update swagger.json to mention queryConfig's range 2017-05-02 15:20:06 -05:00
Chris Goller e6aab20617 Add Range.Lower and Range.Upper to query config to persist custom ranges 2017-05-02 15:08:51 -05:00
Chris Goller b48448fdef Update /queries endpoint to handle templates 2017-04-28 15:12:28 -05:00
Luke Morris 9a198bb5dc Remove unused dependencies from dashboard_test.go 2017-04-28 12:57:16 -07:00
Hunter Trujillo 0d1c416c98 Merge branch 'master' into feature/template-variables
# Conflicts:
#	bolt/internal/internal.pb.go
#	ui/src/CheckSources.js
#	ui/src/dashboards/actions/index.js
#	ui/src/dashboards/containers/DashboardPage.js
#	ui/src/data_explorer/components/Visualization.js
#	ui/src/shared/components/AutoRefresh.js
#	ui/src/shared/components/Dropdown.js
2017-04-25 17:08:55 -06:00
Jade McGough 50914024ea make kapacitor patching work 2017-04-21 12:42:35 -07:00
Jade McGough 87af3b44a4 persist the currently active kapacitor in boltdb 2017-04-21 12:42:35 -07:00
Jade McGough 7a5457644a WIP 2017-04-21 12:39:41 -07:00
Jade McGough 17ff852d94 add kapacitors to AllRoutes 2017-04-21 12:39:41 -07:00
Jade McGough 2a0dee6536 clean up kapacitor swagger docs 2017-04-21 12:39:40 -07:00
Chris Goller 3ca35dc721 Remove extra debug info in the dashboard testing 2017-04-20 16:31:00 -05:00
Chris Goller fee966da28 Add measurements and databases to template variables 2017-04-20 14:32:02 -05:00
Chris Goller b38ee73c6b Update templates API response 2017-04-20 12:22:55 -05:00
Chris Goller abc5ad0b17 Add more validation checks to dashboard updates 2017-04-20 11:47:31 -05:00
Chris Goller e44f716543 Add initial template CRUD operations 2017-04-20 11:09:56 -05:00
Chris Goller ac0ba1334e Move dashboard cells into cells.go 2017-04-20 09:24:57 -05:00
Chris Goller 9075c0da83 Add swagger documentation for template variables 2017-04-19 12:09:22 -05:00
Chris Goller 76fdbc9d55 Merge branch 'master' into feature/refreshing-jwts 2017-04-17 15:24:10 -05:00
Chris Goller 3c6f0db623 Update oauth2 Authenticator signatures to use extend 2017-04-17 11:49:45 -05:00
Chris Goller 017b01d384 Update tests for refreshing jwts 2017-04-14 02:35:30 -05:00
Chris Goller 7c048e8135 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
Andrew Watkins 99a36cb586 Add default RP to queryConfig when no RP is present
This will only happen if the qC is fully qualified.  A fully
qualified query is one that has a db, measurement, and field.
2017-04-13 17:49:53 -07:00
Andrew Watkins 4ef7ff2dc5 Merge pull request #1232 from influxdata/feature/voltron-the-builder
Voltron the builder / One Builder to Rule Them All / Make Builder Great Again
2017-04-13 09:49:45 -07:00
Chris Goller d643907a6e Merge branch 'master' into feature/reverse-kapa 2017-04-11 12:52:49 -05:00
Fred Cox 183a0e0f28 Fix env var name for Google client secret 2017-04-11 16:48:35 +03:00
Hunter Trujillo fd672f0f05 Use backend IDs for great justice. 2017-04-10 12:02:09 -06:00
Chris Goller 65231c2409 Update rawtext in queryconfig to be null and not omitempty 2017-04-07 17:32:10 -05:00
Chris Goller 84e9e0018a Update queries endpoint to return InfluxQL, queryConfig, queryAST 2017-04-07 16:58:56 -05:00
Chris Goller 8d5dcc3ec7 Fix JSON typos in swagger.json 2017-04-07 16:35:05 -05:00
Chris Goller 2f01e567c4 Merge branch 'master' into feature/structured-queries
Conflicts:
	Godeps
	LICENSE_OF_DEPENDENCIES.md
	server/mux.go
	server/routes.go
	ui/.eslintrc
2017-04-07 16:06:24 -05:00
Chris Goller f0acd1b7e0 Merge branch 'master' into feature/generic-oauth 2017-04-07 15:35:28 -05:00
Chris Goller eb5b288e00 Fix PathEscape work for go 1.7 2017-04-07 15:32:35 -05:00
Chris Goller 65b4789227 Update generic oauth routes to be path escaped. 2017-04-07 15:20:53 -05:00
Chris Goller 84f1263357 Add configurable scopes to generic oauth2 support 2017-04-07 14:58:35 -05:00
Chris Goller 51fdcdb944 Merge branch 'master' into feature/generic-oauth 2017-04-07 08:39:52 -05:00
John Gilden f050b5adc6 Use the Host header from the original Kapacitor URL 2017-04-07 08:15:19 -05:00
Chris Goller 1b189c1eab Update cell dashboard error messags to be descriptive 2017-04-06 17:30:53 -05:00
Chris Goller e81a569de5 Merge branch 'master' into feature/generic-oauth 2017-04-06 16:47:58 -05:00
Chris Goller 4a56fdddfc Add generic oauth2 configuration options 2017-04-06 16:45:33 -05:00
Luke Morris d6fab042ed Merge branch 'master' into hotfix/1193-influxql-no-quotes 2017-04-06 13:51:15 -07:00
Jared Scheib 9df1630cf8 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 298a8c47e1.

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 b4773c15af.

* 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