Commit Graph

710 Commits (2fca9efdf027b57d1711582d26ab9d7107945ef3)

Author SHA1 Message Date
Michael de Sa e69045d468 Remove super admin from store/sources tests
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-11-07 14:57:37 -05:00
Jared Scheib bc13ca5ff4 Add clarifying comments about how roles, organization, and context are used to filter resources
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-11-07 14:56:55 -05:00
Michael Desa 4f7f9c2757 Change SuperAdminRoleName to SuperAdminStatus
SuperAdmin is not a role type, but it a status of a user that is
tangentially related to a users role in an organization. This renames
the variable to reflect that difference.
2017-11-07 13:59:51 -05:00
Michael Desa d40a374274 Add comments suggested from PR review
Add tests to server/stores_test.go
2017-11-07 13:59:40 -05:00
Jared Scheib c50422eb39 Modify mock store & json on superadmin-creates-SA user to reflect true SA status
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-11-06 11:17:27 -08:00
Michael Desa bd4d5c6cc3 Fix role related tests after rebase 2017-11-06 11:31:44 -05:00
Michael Desa 9b194168a6 Move user roles and role names to roles package 2017-11-06 11:27:13 -05:00
Michael Desa 4781cb3673 Allow update of sources.Role in server.UpdateSource 2017-11-06 11:25:51 -05:00
Michael Desa f3f183f685 Add role ctx where appropriate in AuthorizedUser 2017-11-06 11:25:46 -05:00
Michael Desa 9ee3b431db Add roles implementation of sources store
Minimal test coverage of Update/Delete/Add methods was done since they
do not involve any filtering. The filtering for them should have
happened at the API level.
2017-11-06 11:24:13 -05:00
Michael Desa f0d19277a3 Pull out setting super admin into a single func 2017-11-06 11:15:49 -05:00
Michael Desa 3565eda4a1 Allow SuperAdmins to promoted and demoted 2017-11-06 11:15:48 -05:00
Michael Desa 49232f009e Add default org check even when no auth is used 2017-11-06 10:17:17 -05:00
Michael Desa f75de68607 Remove DefaultOrganization Name in tests mock store 2017-11-06 10:17:17 -05:00
Michael Desa 7200aaf9f9 Add default org logic to OrganizationsStore
Update resource handlers to appropriate consume default organization IDs
2017-11-06 10:14:12 -05:00
Michael Desa 09f79f3a3e Grant user role in default org if added via API
When users are created via the API they are only given roles in orgs
that are explicitly set. Additionally the roles must be roles that
belong to the current organization (unless they are a super admin).

This leads to a situation where a user may not be a part of the default
organization. If this is the case, we detect it when the user hits /me
and add the user to the default org.
2017-11-06 09:46:00 -05:00
Michael Desa 63f7d8205c Add default role to chronograf.Organization 2017-11-06 09:46:00 -05:00
Chris Goller 02762a95e5 Update queries endpoint comment 2017-11-04 20:19:08 -05:00
Michael Desa 167c0c06a8 Prevent duplicate organization roles in user CRUD 2017-11-03 12:06:18 -04:00
Michael Desa aabefe3ac1 Fix me tests with proper IDs 2017-11-03 09:47:54 -04:00
Michael Desa 4baa65629a Fix links in me request 2017-11-03 09:39:21 -04:00
Michael Desa 450a965019 Properly pass organization context to handlers 2017-11-03 09:13:03 -04:00
Michael Desa b67b2e8d6e Fix over-stringification of organization on roles 2017-11-02 21:52:30 -04:00
Jared Scheib 500843a867 Add SuperAdmin to userResponse 2017-11-02 16:24:16 -07:00
Chris Goller cdd2c826b9 Fix rendering of templated queries to the /queries endpoint 2017-11-02 17:57:02 -05:00
Michael Desa 311c68f457 Add CurrentOrganization & Organizations to me resp
Remove CurrentOrganization from chronograf.User
2017-11-02 11:59:53 -04:00
Michael Desa 986f86d99c Fix relevant go-vet/go-lint for server package 2017-11-01 16:43:31 -04:00
Michael Desa aa2087ec43 Add exhaustive test for AuthorizedUser 2017-11-01 16:38:17 -04:00
Michael Desa 65028027fd Add comments to DataStore interface and implemntn 2017-11-01 14:24:40 -04:00
Michael Desa eb845b1630 Fix routes tests 2017-11-01 14:09:58 -04:00
Jared Scheib 2e0911dbd9 Add organizations and users routes to allRoutes
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-11-01 12:59:07 -04:00
Michael Desa 40feb4ae94 Change nil check to len == 0 check for userRequest 2017-11-01 12:38:26 -04:00
Michael Desa 46987558e0 Remove unused code 2017-11-01 12:35:09 -04:00
Michael Desa 569978b4f7 Add parseOrganizationID method 2017-11-01 12:34:00 -04:00
Michael Desa e7a94c18d6 Add comments throughout codebase 2017-11-01 12:30:42 -04:00
Michael Desa a8a115ec50 Change function signature of hasSuperAdminContext 2017-11-01 10:39:09 -04:00
Michael Desa 4c0469cb07 Change OrganizationID to Organization in Me req 2017-11-01 10:37:32 -04:00
Michael Desa 0e18f8778b User explicit type when setting context 2017-11-01 09:49:02 -04:00
Michael Desa 3ad2305c33 Add superAdmin to users CRUD 2017-11-01 09:12:19 -04:00
Michael Desa 708c37dc67 WIP cleanup 2017-10-31 20:58:40 -04:00
Michael Desa e7e17537a1 WIP make app usable by frontend 2017-10-31 19:50:03 -04:00
Michael Desa f863bf2042 Add support for super admin 2017-10-31 18:27:24 -04:00
Michael Desa 2bd2c81bb7 Add noop implementation of each source type 2017-10-31 18:07:42 -04:00
Michael Desa cf64b2e506 Remove RawUsers from DataStore 2017-10-31 17:49:35 -04:00
Michael Desa 00b79a45eb Add org param to New Organizaiton methods 2017-10-31 17:40:58 -04:00
Michael Desa 36e14cb111 Refactor data stores into a common interface 2017-10-31 16:41:17 -04:00
Michael Desa bea2caaa7f Move organization resouces to their own package 2017-10-30 14:31:19 -04:00
Michael Desa 1082b264fe Use organization stores 2017-10-30 12:05:59 -04:00
Jared Scheib cbc22b10d7 Test authorized User in the context of Organization
Make principal explicit arg in auth tests.

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-27 13:54:28 -07:00
Michael de Sa cf58974927 Add organization field to principal in auth tests
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-27 13:19:43 -07:00
Jared Scheib 32a65aa307 Slightly DRYer code for getting fields off Principal
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-27 12:48:51 -07:00
Michael de Sa cff3ae798d Test MeOrganization for valid org with invalid user, and invalid org
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-27 10:14:14 -07:00
Jared Scheib 4c968b0ff5 Validate Organization and that User belongs to Org in MeOrganization
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-27 10:02:02 -07:00
Michael de Sa 5c4407cbaf Test MeOrganization for setting and changing current org
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-26 16:03:01 -07:00
Michael de Sa 6dd9f52c47 Change organization in meOrganizationRequest to currentOrganization
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-26 16:02:29 -07:00
Jared Scheib 30d1739e35 Move Mock Authenticator into mocks package
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-26 15:46:06 -07:00
Chris Goller 3152471f7c Fix logger and redirector to be flushers allowing HTTP chunking 2017-10-26 17:38:20 -05:00
Chris Goller f94eed49f5 Fix kapacitor proxy to accept url query parameters 2017-10-26 17:38:03 -05:00
Chris Goller 10e45721b4 Add flush interval to kapacitor proxy to fix buffering 2017-10-26 17:37:28 -05:00
Jared Scheib d6d3463208 Merge remote-tracking branch 'origin/multitenancy' into multitenancy_orgs
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-26 18:21:30 -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
Nathan Haugo c720f8a9cb Merge pull request #2140 from influxdata/feature/kapa-insecure
Add insecure ssl support to connect to kapacitor
2017-10-26 10:40:28 -04:00
Jared Scheib cf530eddc6 Update Organization comments on resources
Remove `omitempty` on Organization field

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-25 14:56:08 -04:00
Jared Scheib 4786964b54 Add Organization guard to server/kapacitors
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-25 14:48:19 -04:00
Michael Desa e909ce9a1e Add Organizations to Dashboards 2017-10-25 14:00:06 -04:00
Michael Desa 57468b5fbe Add Organization to layouts 2017-10-25 12:52:56 -04:00
Michael Desa ef079a1899 Add Organization to Sources 2017-10-25 11:51:15 -04:00
Jared Scheib bb67361cf1 Merge branch 'multitenancy' into multitenancy_lowercase_fields 2017-10-24 18:01:32 -07:00
Jared Scheib aa8742662f Merge branch 'master' into multitenancy 2017-10-24 17:58:15 -07:00
Jared Scheib 74fdcc1c39 Add scheme to me/AuthorizedUser tests 2017-10-24 16:21:24 -07:00
Jared Scheib f283702fe0 Lowercase Provider & Scheme & Role values for consistency
The client was being sent lowercase values for Role & Provider,
but not Scheme. This change makes all the above lowercase.
2017-10-24 16:17:59 -07:00
Jared Scheib 3b2818688a Make all Store names plural for consistency 2017-10-24 15:54:24 -07:00
Michael de Sa 86ba743f40 Fix string interpolation data type for uint64 in Users tests
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-24 14:28:39 -07:00
Michael de Sa 2137191d5f Modify ValidUpdate to ensure only User Roles can be updated
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-24 14:28:35 -07:00
Nathan Haugo da560018c6 Update changelog and version number for 1.3.10.0 2017-10-24 09:34:31 -04:00
Michael Desa 2226f34cf2 Add tests for server/organizations.go 2017-10-23 14:16:52 -04:00
Michael Desa 3f3e7a5662 Fix typo in organization comment 2017-10-23 14:16:31 -04:00
Michael Desa ee255f319d Add missing returns in http hanlder methods 2017-10-20 15:42:51 -04:00
Michael Desa b5e73dfd46 Add CRUD routes for organizations 2017-10-20 15:42:34 -04:00
Chris Goller 1b6724122c Add insecure ssl support to connect to kapacitor 2017-10-19 22:48:31 -05:00
Michael de Sa 414ca7f0b6 Add clarifying comment for InfluxDB UID being Name
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-19 14:42:34 -05:00
Michael de Sa f463642bae Update route authorization by Role
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-19 14:33:08 -05:00
Jared Scheib 19369b38cc Set Scheme to be OAuth2 explicitly for all users
Add Provider to Users authenticated via /me

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-19 14:32:33 -05:00
Michael Desa dafab1653a Fix formating of server/auth.go 2017-10-19 12:54:06 -04:00
Michael Desa 8d472646cd Fix wrong authorization level on selected routes
Fix leaking of username on failed authorization

Add comment to chronograf.UserQuery

Fix logic in hasPrivilege method
2017-10-18 15:45:06 -04:00
Michael Desa a0d300d280 Use new chonograf.UserStore Get method when needed
Refactor tests that were dependent of old implementation of UsersStore
2017-10-18 14:45:33 -04:00
Michael Desa 246e65e598 Generalize chronograf.UsersStore Get method
The `Get` method on the UsersStore was generalize by changing the second
parameter to a struct. This allows the Store to retrieve users by more
than simply their name.

-Get(ctx context.Context, name string) (*User, error)
+Get(ctx context.Context, q UserQuery) (*User, error)
2017-10-18 14:17:42 -04:00
Michael Desa 0517a87954 Add comment to AuthorizedUser 2017-10-18 12:45:58 -04:00
Michael Desa 3430eeb84b Wrap routes with Authorization middleware 2017-10-18 12:40:17 -04:00
Michael Desa f50a2b686f Add AuthorizedUser middleware 2017-10-18 12:35:40 -04:00
Michael Desa e61ed60ae8 Extract logic for getting user by name & provider 2017-10-18 12:34:23 -04:00
Michael de Sa 84f6702edf Modify /me to match User via UsersStore.All & principal's Issuer
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-16 19:58:02 -05:00
Jared Scheib 414eab5f7d Rename getEmail func & email var to getUsername & username
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-16 19:58:02 -05:00
Jared Scheib cc7e695f37 Merge pull request #2113 from influxdata/multitenancy_rename_role_sourcerole
MULTITENANCY: Rename Role CRUD methods & structs w Source prefix
2017-10-16 19:51:38 -05:00
Jared Scheib c924771fb9 Lowercase string consts for role names
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-16 19:42:57 -05:00
Michael de Sa c390678e43 Place user role consts and vars in server package
This also decouples the bolt tests from the server package.

Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-16 18:43:56 -05:00
Jared Scheib de6068228b Replace string slices of role names with slices of chronograf.Role
This effectively reinstants rolly polly as king.

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-16 18:26:08 -05:00
Michael de Sa 93e3e68272 Suggest valid options in Invalid Role error message
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-16 15:56:43 -05:00
Michael de Sa b2c4d9cb94 Add test coverage for userRequest validation
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-16 14:28:15 -05:00
Jared Scheib 74b4ad2c86 Remove unnecessary logic in ValidRoles guard
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-16 13:58:16 -05:00
Jared Scheib 263ff93f9b Modify chronograf user roles to only use role name
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-16 14:44:34 -04:00
Jared Scheib a928d1518c Modify User req & res to receive & give Role names only
Role members are fully explicated for CRUD operations.
Also adds validation for Roles on requests.
Also returns an empty array in JSON when a User has no roles.
2017-10-16 14:18:34 -04:00
Chris Goller 725fd521dc Update swagger documentation about queryConfig 2017-10-16 11:51:51 -05:00
Chris Goller 7b786657aa Rename queryConfig field to Value and support top/bottom 2017-10-16 10:56:12 -05:00
Jared Scheib de3dcf24c0 Add Roles to Users CRUD
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-12 17:42:30 -07:00
Jared Scheib b5693694ee Rename Role CRUD methods & structs w Source prefix
Move server/roles.go and server/roles_test.go into server/sources.go and
server/sources_test.go respectively.

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-12 19:25:33 -04:00
Michael Desa 33976d2832 Add jsonEqual to test helpers file 2017-10-11 14:33:55 -04:00
Michael de Sa a8c50620f3 Refactor setting writer Location header
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-11 10:14:57 -07:00
Chris Goller 3c1b09704e Refactor query config field arguments to be fields 2017-10-10 18:04:45 -05:00
Jared Scheib 31f72a71e9 Rename vestigial receiver 'h' on Service to 's'
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-10 15:27:58 -07:00
Chris Goller 3ba1a4c94d Refactor queryConfig to have field aliases and function arguments 2017-10-10 17:01:50 -05:00
Jared Scheib eca9614cda Refactor applying writer location header into helper func
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-10 14:40:45 -07:00
Michael de Sa 30f36bfd19 Move source_users & source_users_test code into sources.go & sources_test.go
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 14:32:41 -07:00
Michael de Sa e00f4512d2 Remove omitempty for Provider & Scheme in userRequest and userResponse
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 14:25:45 -07:00
Michael de Sa a46e3ab7c2 Use more idiomatic error message method
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 14:21:43 -07:00
Michael de Sa 85dde0cebe Add comments on ValidUpdate for future considerations
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 14:19:28 -07:00
Jared Scheib af5d21028c Make name on userResponse required
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-10 14:15:31 -07:00
Jared Scheib 2d88f15fdf Use string IDs in JSON res and req for Users
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-10 12:27:55 -07:00
Michael de Sa 63d7a4d201 Update only fields with diff; add test for that
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 11:40:33 -07:00
Michael de Sa 526dca3cb4 Make User Update test reflect updated changes
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 11:36:13 -07:00
Michael de Sa f2617c6744 Use new-school sort.Slice
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-10 11:30:57 -07:00
Jared Scheib c5ef8ed487 Add comments to exported functions
Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-09 15:28:39 -07:00
Michael de Sa 6135a6a4ea Return users in usersResponse in sorted order
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-09 15:19:46 -07:00
Michael de Sa b8970c8ed1 Add All route & operation for Chronograf Users
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-10-09 15:03:50 -07:00
Jared Scheib eb6c212023 Implement CRUD routes & operations for Chronograf User
Move source Users code into source_users and source_users_test files.
Use the UsersStore for both InfluxDB and Chronograf users.

Signed-off-by: Michael de Sa <mjdesa@gmail.com>
2017-10-09 14:16:24 -07:00
Nathan Haugo a2f270bdb2 Update version 2017-10-06 11:38:40 -07:00
Chris Goller 0e6a06d663 Update dashboard cells to have optional data source URI. 2017-10-02 12:50:42 -07:00
Andrew Watkins a35f045648 Update kapacitor links to include tasks and ping paths 2017-09-12 09:23:22 -07:00
Chris Goller 35248b8044 Update kapacitor AlertRule to containe most Kapacitor Task information 2017-09-09 10:19:52 -05:00
Chris Goller d1007513cd Update kapacitor rule response with dbrps, various dates, error, and executing. 2017-09-09 10:19:52 -05:00
Chris Goller 08ecc10ddb Update swagger docs with new kapacitor rule fields 2017-09-09 10:19:52 -05:00
Chris Goller bebe0f364a WIP 2017-09-09 10:19:52 -05:00
Nathan Haugo 3387c941af Bump version to 1.3.8.0 2017-09-07 16:29:56 -07:00
Tim Raymond f8580d907e Refactor set membership validation
The pattern of using a select with a list of options and a default that
returns an error isn't bad for a one-off validation:

select myProp {
  case "validOption1", "validOption2":
    // no-op
  default:
    panic("invalid!")
}

However, we're doing this multiple times in this method, so it makes
sense to pull this out into a new method to make it clearer what's
happening.

This adds a `oneOf` function that takes some property and a variadic
list of valid options and reports whether or not that property is among
that list.
2017-08-24 15:45:51 -04:00
Tim Raymond c24db57385 Add validation around Base and Scale
The Base and Scale options on axes can only be one of two parameters. We
weren't validating that this was the case. This patch ensures that Base
can only ever be "10" or "2", and Scale must be either "linear" or
"log".

Associated test coverage was also added.
2017-08-24 15:37:19 -04:00
Tim Raymond 63087a1bb8 Update Swagger for new axes options
New options were introduced to control things like scale, base, etc. on
axes and these were previously not documented. This adds documentation
of the newly supported parameters by the API.
2017-08-24 14:50:12 -04:00
Nathan Haugo 7a85e3a152 Merge 1.3.7.x 2017-08-23 16:01:30 -07:00
Nathan Haugo 5a13db41ba Bump to 1.3.7.0 2017-08-23 15:56:00 -07:00
Tim Raymond fed021ed9c Merge branch 'master' into feature/tr-kapa-rule-pagination 2017-08-23 16:44:59 -04:00
Tim Raymond f46335fb27 Remove kapacitor mock logic
This logic was originally left in place to help future test writers, but
its presence was vexing because it was not exercised in existing test
cases. It has been commented out should future tests need to leverage
it.
2017-08-23 16:39:12 -04:00
Timothy J. Raymond 61bffeb7cb Merge pull request #1859 from influxdata/feature/tr-layout-cell-axes
Add Axes to Layout Cells
2017-08-16 16:45:26 -04:00
Tim Raymond 9b71477509 Switch KapacitorRulesGet to use Pagination
Kapacitor responses are paginated, and sometimes users have more than
the default 100 tasks that are returned from Kapacitor. This replaces
the previous Kapa client with one that automatically follows paginated
responses from Kapacitor's ListTasks endpoint and returns the full
response.

Tests for the KapacitorRulesGet endpoint had to be updated because they
did not account for "limit" and "offset", and so led to an infinite
loop with the paginated client. A correct kapacitor backend will not
have this behavior
2017-08-15 17:30:29 -04:00
Tim Raymond fcf325bbbe Add PaginatingKapacitorClient
The kapacitor client used in the kapacitor endpoints is limited to
fetching whatever limit you provide it. If you provide no limit, it
defaults to a limit of 100. We use this default behavior currently.

Some users have more than 100 tasks, so we need a client that's capable
of continually fetching tasks from Kapacitor until there are none left,
and returning the full response to the frontend.

This introduces a PaginatingKapacitorClient which does exactly that.
Also, test coverage was added around the KapacitorRulesGet endpoint,
since it was previously untested.
2017-08-15 16:55:47 -04:00
Timothy J. Raymond 246cf75ce7 Merge pull request #1866 from influxdata/bugfix/tr-missing-cell-type
Fix missing cell type
2017-08-14 14:04:36 -04:00
Tim Raymond 74f464800d Fix missing cell type
Because we are now creating new instances of dashboards when we create a
response, it's critical to copy every element of Dashboards from the
previous to the new instance.

We were not previously copying the Type field of cells, so this was
defaulting to the empty string zero value. This patch adds "Type" to the
tests and ensures that it's properly copied
2017-08-14 13:41:31 -04:00
Jared Scheib 974e9eaf7d Add 'type' to new-sources server flag example 2017-08-11 11:54:16 -07:00
Tim Raymond c77630ff49 Ensure "x", "y", and "y2" axes present
Similar to DashboardCells, this ensures that the "x", "y", and "y2" axes
are always present in a layout's cells.
2017-08-10 13:53:07 -07:00
Tim Raymond c2a5083777 Add test coverage to /layouts endpoint
In anticipation of adding Axes to cells, I wanted some test coverage to
be in place before I made the change.

This covers the happy path case as well as focusing on individual
applications. To come are focusing on a measurement and a test for when
the store is unavailable.
2017-08-10 13:52:26 -07:00
Tim Raymond 532a6a8c48 Merge branch 'master' into feature/1602-graph-bounds-setting
Also removed LegacyBounds marshaling since it was no longer necessary

Conflicts resolved:
	bolt/internal/internal.go
	bolt/internal/internal.pb.go
	bolt/internal/internal.proto
	bolt/internal/internal_test.go
	chronograf.go
	server/cells_test.go
	server/dashboards_test.go
	server/swagger.json
2017-08-02 11:29:29 -04:00
Tim Raymond e545f91d8f Add Label to DashboardCell Axis
It's useful for the frontend to be able to specify a label on a
particular axis. This adds a property to Axis to facilitate that.
2017-08-02 11:12:47 -04:00
Tim Raymond e703107644 Copy missing properties from Dashboards
When creating new dashboards to set defaults, not all properties of the
dashboard were being copied. This ensures that they are so that zero
values are not used for things like the ID and Name.
2017-07-31 17:24:43 -04:00
Tim Raymond 7aad733682 Fix data races in dashboard response construction
Dashboard responses had data races because multiple goroutines were
reading and modifying dashboards before sending them out on the wire.
This patch introduces immutability in the construction of the response,
so that each goroutine is working with its own set of dashboardResponse
structs.
2017-07-31 16:36:20 -04:00
Tim Raymond 08bf8aeff5 Ensure cell bounds come back as empty array
The contract with the frontend states that bounds should come back as an
empty array instead of null when there are no bounds present. We must
explicitly specify []string{} for this to happen.
2017-07-31 16:36:16 -04:00
Tim Raymond 4391004e7f Enforce presence of "x", "y", and "y2" axes
Certain aspects of the frontend requires the presence of these three
axes, so part of the contract established is that the backend will
always provide them. Since we centralize creation of
dashboardCellResponses, this is where these axes are added to all cell
responses.

Additionally, because there was previously no coverage over the
dashboard cells endpoints, a test has been added to cover the
DashboardCells method of Service.
2017-07-31 16:36:07 -04:00
Tim Raymond 2ff3e27e1f Convert Axis Bounds to []string
Due to various limitations with the previous implementation of Bounds as
a [2]int64{}, we've decided to change this to a []string{}. This will
allow clients to store arbitrary data specifying a bound and interpret
it as they wish.
2017-07-31 16:35:53 -04:00
Chris Goller 2d8b1ef340 Release 1.3.5.0 2017-07-25 15:08:02 -05:00
Chris Goller cef0e66df0 Update influx Authorization Headers for write and query path 2017-07-25 12:13:46 -05:00
Tim Raymond ede85f6964 Enforce only "x", "y", and "y2" axes
For the forseeable future, we will only be using the "x", "y", and "y2"
axes, even though the underlying serialization can support arbitrary
axes (for the future).

This ensures that only "x", "y", and "y2" axes are present and updates
the Swagger docs to reflect that fact
2017-07-24 14:06:15 -04:00
Tim Raymond db4d093a0c Update Swagger with Cell Axes
Cells now have axes which represent their visualization's viewport. This
updates the Swagger documentation to reflect this.

Things to be aware of
=====================

The form of "axes" is that of a map<string,object>, which is represented
in Swagger by an "additionalProperties" key (search for "string to model
mapping" here: https://swagger.io/specification/).
2017-07-24 14:03:48 -04:00
Jared Scheib d6db7ee084 Merge pull request #1724 from influxdata/feature/pushover_support-1680
Add Pushover alert support
2017-07-21 14:04:22 -07:00
Jared Scheib 6540ea308d Clarify BoltPath server flag help text with default path 2017-07-21 11:41:54 -07:00
Tim Raymond ee6a2fa54b Enforce only "x", "y", and "y2" axes
For the forseeable future, we will only be using the "x", "y", and "y2"
axes, even though the underlying serialization can support arbitrary
axes (for the future).

This ensures that only "x", "y", and "y2" axes are present and updates
the Swagger docs to reflect that fact
2017-07-21 12:09:49 -04:00
Jared Scheib 200b24788b Merge branch 'master' into feature/pushover_support-1680 2017-07-20 16:23:54 -07:00
Tim Raymond a423a98d36 Update Swagger with Cell Axes
Cells now have axes which represent their visualization's viewport. This
updates the Swagger documentation to reflect this.

Things to be aware of
=====================

The form of "axes" is that of a map<string,object>, which is represented
in Swagger by an "additionalProperties" key (search for "string to model
mapping" here: https://swagger.io/specification/).
2017-07-19 11:18:01 -04:00
Chris Goller 8dc08278bd Add JWT shared secret influxdb auth
Refactor --new-sources to simplify adding shared secrets
2017-07-19 01:39:06 -05:00
Jared Scheib fb8d5cfc8e Add Pushover to swagger 2017-07-14 16:55:59 -07:00
Hunter Trujillo 8307a3b336 I think this goes here in the swagger doc... 2017-07-10 16:18:05 -06:00
Jared Scheib 5ec506b8fb Merge branch 'master' into feature/persist_datasource_flag-1555 2017-07-07 14:45:00 -07:00
Tim Raymond a7fc16cb17 Fix bad merge conflict resolution
Duplicate definitions of the same property were present because of
confusing placement of merge conflict markers.
2017-07-07 16:59:19 -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
Jared Scheib 12f1a8ce4b Add test for creating NewSources via server flag
Move TestLogger to mocks

Signed-off-by: Tim Raymond <tim@timraymond.com>
2017-07-07 12:56:12 -07:00
Jared Scheib fea0a330eb Correct comment 2017-07-06 15:04:04 -07:00
Jared Scheib 10c317c083 Refactor process new sources into named func 2017-07-06 14:27:14 -07:00
Jared Scheib d7e73f55ad Move NewSources input prep to server
Signed-off-by: Tim Raymond <tim@timraymond.com>
2017-07-06 14:12:07 -07:00
Jared Scheib ac0598f95c Allow server to run even if NewSources errors out 2017-07-06 12:05:05 -07:00
Jared Scheib 3c3602a724 Update error messages to use plural 2017-07-06 11:48:14 -07:00
Jared Scheib abff00f88f Add sample usage
Make flag identifier plural since JSON array of objects
2017-07-06 11:44:42 -07:00
Jared Scheib 52e65be69d Successfully persist new source and kapa via server flag
Move this to after BoltDb connection is opened
2017-07-05 18:12:08 -07:00
Tim Raymond b1f8ff81c3 Parse JSON for --new-source into struct
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-07-05 15:00:59 -07:00
Jared Scheib 0c8b543806 Add pseudocode outline for parsing and persisting source and server
Signed-off-by: Tim Raymond <tim@timraymond.com>
2017-06-29 15:33:22 -07:00
Jared Scheib de9d0df860 Group flags more semantically consistently 2017-06-29 14:27:30 -07:00
Jared Scheib 639bce7217 Group flags more semantically consistently 2017-06-29 14:25:41 -07:00
Jared Scheib 788aec07db Improve description of custom link use, and give example (#1676) 2017-06-28 14:41:13 -07: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
Jared Scheib e9f6568074 Clarify error output for missing Name or URL 2017-06-27 13:40:26 -07:00
Jared Scheib 33127d7915 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 91bae804e1 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 200225d2e2 Conserve memory allocation for customLinks slice
Signed-off-by: Chris Goller <goller@gmail.com>
2017-06-27 12:00:05 -07:00
Jared Scheib 3b76f82d47 Remove omitempty from CustomLink definition since should never b 2017-06-27 11:02:28 -07:00
Jared Scheib 0ab48663a8 Return and test for nil on invalid NewCustomLink input 2017-06-27 10:59:04 -07:00
Jared Scheib fcf9971d86 Pass through CustomLinks error message directly 2017-06-26 18:02:22 -05:00
Jared Scheib 3e3bf8988c Add full test coverage for NewCustomLinks 2017-06-26 17:18:53 -05:00
Jared Scheib b38439321d Move external links structs to links.go 2017-06-26 16:13:23 -05:00
Jared Scheib def34560e0 Only test one CustomLink to avoid map key order failing test 2017-06-26 16:12:54 -05:00
Jared Scheib 81aa909329 Add custom links to routes test 2017-06-26 16:00:27 -05:00
Jared Scheib 987141cffa Use appropriate error when NewCustomLinks fails 2017-06-26 15:44:56 -05:00
Jared Scheib a32c17a18d Comment CustomLink struct 2017-06-26 15:43:03 -05:00
Jared Scheib cac72eea60 Change 'Url' prop key to 'URL' to satisfy Go convention 2017-06-26 15:42:36 -05:00
Jared Scheib 9198e5cb7a Update comment for ServeHTTP to mention External Links 2017-06-26 15:35:42 -05:00
Jared Scheib 4bf242f955 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 a6dcb3a382 Add 'custom' prop and example to /chronograf/v1 in swagger docs 2017-06-26 11:56:05 -07:00
Jared Scheib c1bdbcaa89 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 a251071254 WIP Parse custom links from CLI 2017-06-23 15:12:02 -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
Timothy J. Raymond 34808ddb9d 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 17984600cb Fix generic redirect URL 2017-06-21 12:19:21 +08:00
Kent Wang 9c597d2c8f Replace string concat to path.Join 2017-06-18 10:47:02 +08:00
Kent Wang 0bb20c8a0f Don't pass RedirectURL if PublicURL not set 2017-06-18 10:40:07 +08:00
Jared Scheib 7df4a6ed1a Merge branch 'master' into feature/status_page-1556 2017-06-16 17:52:16 -07:00
Jared Scheib 255daba611 Update default JSON feed URL to final, secure link 2017-06-16 14:23:46 -07:00
Kent Wang a231e9f942 Add redirect url to generic oauth 2017-06-16 17:35:57 +08:00
Jared Scheib 73fd58ef35 Update swagger docs for external and statusFeed props 2017-06-15 18:23:42 -07:00
Jared Scheib 59e184b1f1 Comment new StatusFeed member of AllRoutes 2017-06-15 17:55:46 -07:00
Jared Scheib 7a6131bd40 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 95e2c18c5a Add test for all routes with ExternalLinks 2017-06-14 16:22:30 -07:00
Jared Scheib 741ce0c4b6 Remove unused fragment 2017-06-14 13:51:08 -07:00
Tim Raymond 1723f30bdf correct TemplateVar collection type in Queries 2017-06-14 10:52:29 -04:00
Jared Scheib 9e38616783 Add default InfluxData JSON feed url 2017-06-13 19:23:52 -07:00
Jared Scheib f63cba3581 Add status-feed-url build flag within new externalLinks prop in AllRoutes 2017-06-13 13:40:20 -07:00
Tim Raymond fd5036ed20 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 87eff2c86c Update swagger docs. 2017-06-12 15:30:10 -06:00
Regan Kuchan 5a0abe2de7 Update version and changelog for v1.3.2.0 2017-06-02 13:34:23 -06:00
Jared Scheib cb394dd716 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 0c4c74ce36 Add kapacitor rule validation on update 2017-05-25 12:10:25 -05:00
Chris Goller d19f8062ec Fix kapacitor PUT/POST returning request rather than response 2017-05-24 15:30:45 -07:00
Regan Kuchan 7331971e23 Update version number and bumpversion 2017-05-22 11:57:23 -07:00
Tim Raymond befccf44d0 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 33b3ccc298 Update version to 1.3 for javascript and swagger 2017-05-09 08:24:04 -07:00
Tim Raymond b4d10754e4 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 49feb39e90 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 ee5760bfd3 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 0141f0870c 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 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
Tim Raymond 43ee0e4baf Add logging of response times
This makes monitoring Chronograf 👍
2017-05-08 14:40:50 -07:00
Jared Scheib 1e2e3c1362 Notify user about --prefix-routes when using --basepath 2017-05-08 14:40:50 -07:00
Chris Goller 243286892f Fix null queryConfig and add substantial test coverage to kapacitor
storage
2017-05-05 16:14:02 -05:00
Chris Goller 3821b1ccff Update Kapacitor alerts to set queryConfig to null if not parsable. 2017-05-05 14:30:20 -05:00
Andrew Watkins 92bd5d10b4 Resolve conflicts
Conflicts:
	ui/src/utils/influxql.js
2017-05-05 10:01:26 -07:00
Chris Goller 365434783d Merge branch 'master' into feature/influx-write 2017-05-05 08:10:14 -05:00
Chris Goller e54554e8de Update influxql AST parsing to return full binary exprs (#1380) 2017-05-03 15:57:19 -07:00
Chris Goller 7b08acb621 Add line-protocol /write endpoint to all data sources 2017-05-03 00:06:40 -05:00
Chris Goller bc1ac4c0ce Update swagger.json to mention queryConfig's range 2017-05-02 15:20:06 -05:00
Chris Goller 7a577f6618 Add Range.Lower and Range.Upper to query config to persist custom ranges 2017-05-02 15:08:51 -05:00
Chris Goller f8652efdee Update /queries endpoint to handle templates 2017-04-28 15:12:28 -05:00
Luke Morris b9327c412e Remove unused dependencies from dashboard_test.go 2017-04-28 12:57:16 -07:00
Hunter Trujillo 116c2e3c23 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 32386f8ab2 make kapacitor patching work 2017-04-21 12:42:35 -07:00
Jade McGough cbdf067a56 persist the currently active kapacitor in boltdb 2017-04-21 12:42:35 -07:00
Jade McGough 05688ef634 WIP 2017-04-21 12:39:41 -07:00