Commit Graph

44 Commits (master)

Author SHA1 Message Date
Pavel Zavora 2846dc27c2 chore(server): staticcheck - remove useless return 2022-04-21 22:41:00 +02:00
Pavel Zavora 15dbecfb0f feat(server): add reader role 2022-04-21 22:41:00 +02:00
Greg 26458417c7
feat: add ability to authenticate single superadmin user (#5400)
* feat: add ability to authenticate single superadmin user

This short-circuits any configured authentication, allowing a user
with the correctly signed message to act against the api.

* Present an expiring message to be signed/verified

* Add chronoctl command to ouput token for use in auth header

* Add command to generate and store RSA keypair

* Test new superadmin token checks
2020-02-28 14:14:46 -07:00
Jared Scheib ae475c7ae8 Add OrganizationConfigStore & refactor org config to be per org
As previously implemented, OrganizationConfig was a global
object. This refactor adds the organization id to context for
every request, even when auth is disabled, so that org id
can be used to get/update an organization config.

Along those lines, this also removes OrganizationConfigStore
.Initialize and replaces .Get with .FindOrCreate, handling
the creation of organization configs upon first attempted
access.

Co-authored-by: Jared Scheib <jared.scheib@gmail.com>
2018-07-09 17:36:19 -07:00
Michael Desa 23a4c34a17 Populate links response with organiation on JWT 2018-01-17 12:26:28 -05:00
Michael Desa 2d7828b602 Nest user routes under organization
Add global user routes
2018-01-16 16:45:58 -05:00
Michael Desa 0d6a508a00 Modify CRUD user handlers for global operations
Add raw query param middleware performing raw ops

This commit introduces middleware that allows SuperAdmin Users to
specify a query param `raw=true` which will give them raw access to the
data store. Raw access means that it is not in behind the usual
organization facade.

Currently, only the user routes use this middleware.
2018-01-09 13:43:33 -05:00
Michael Desa d8d20547ab Change Organization ID to string from uint64 2017-12-19 10:13:43 -08:00
Michael Desa f2591c9eb1 Change HTTP Status 401 to 403 in AuthorizedUser
This signals to the front end that a user must go through another ouath
flow.
2017-11-21 18:55:26 -05:00
Michael Desa cf82990623 Return HTTP Status 403 if org not found in /me
Fix returning non-standard status from AuthorizedUser
2017-11-21 18:53:42 -05:00
Michael Desa 85bb71033c Expose some organization routes to admins
Cleanup tests appropriately

Prevent Admins from patching organizations
2017-11-10 12:48:10 -05:00
Michael Desa 1832ecb4f7 Change UserKey to UserContextKey
Fix name of arguments in tests
2017-11-10 11:18:06 -05:00
Michael Desa 71851d142f Put entire user on context 2017-11-10 11:09:16 -05:00
Michael Desa 4e46b4b2c7 Differentiate between SuperAdminContext and ServerContext
Previously, the server just hijacked the super admin context in order to
get raw access to the underlying data stores, this introduces a way to
specify the it is explicitly the server making the request and no longer
hijack the super admin context.

This also adds test coverage to ensure that the correct values are being
set on context in the AuthorizedUser method.
2017-11-10 11:09:16 -05:00
Michael de Sa 5062773e4e Add verification that user does not have more than one role in org
Signed-off-by: Jared Scheib <jared.scheib@gmail.com>
2017-11-07 15:02:31 -05:00
Jared Scheib 4df7e38779 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 6f66dd8a47 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 cbbf9d96d7 Add comments suggested from PR review
Add tests to server/stores_test.go
2017-11-07 13:59:40 -05:00
Michael Desa 859d94ab15 Move user roles and role names to roles package 2017-11-06 11:27:13 -05:00
Michael Desa 5e1ad82660 Add role ctx where appropriate in AuthorizedUser 2017-11-06 11:25:46 -05:00
Michael Desa c7e49001d4 Add default org check even when no auth is used 2017-11-06 10:17:17 -05:00
Michael Desa 3370774e8f 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 6539e5ebeb Properly pass organization context to handlers 2017-11-03 09:13:03 -04:00
Michael Desa dc63e8af8f Add parseOrganizationID method 2017-11-01 12:34:00 -04:00
Michael Desa 6fbfde5060 Add comments throughout codebase 2017-11-01 12:30:42 -04:00
Michael Desa 3eaca382d3 User explicit type when setting context 2017-11-01 09:49:02 -04:00
Michael Desa a9d5bf9c05 WIP cleanup 2017-10-31 20:58:40 -04:00
Michael Desa d1488a973b WIP make app usable by frontend 2017-10-31 19:50:03 -04:00
Michael Desa 391bd189c1 Add support for super admin 2017-10-31 18:27:24 -04:00
Michael Desa 5f63e2738a Refactor data stores into a common interface 2017-10-31 16:41:17 -04:00
Jared Scheib 1a06fefa04 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 10c63ee00c 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 c994e8c5ac 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 c1b56f241d Fix formating of server/auth.go 2017-10-19 12:54:06 -04:00
Michael Desa 34414df016 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 4687ecf794 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 e0f4ac74d1 Add comment to AuthorizedUser 2017-10-18 12:45:58 -04:00
Michael Desa 28fac10baa Add AuthorizedUser middleware 2017-10-18 12:35:40 -04:00
Chris Goller 3c6f0db623 Update oauth2 Authenticator signatures to use extend 2017-04-17 11:49:45 -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
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
Tim Raymond d07c7ca1d6 Reorganize OAuth2 Logic
Created an oauth2 package which encapsulates all oauth2 providers,
utility functions, types, and interfaces. Previously some methods of the
Github provider were used as http.HandlerFuncs. These have now been
pulled into a concrete type called a JWTMux to implement other Oauth2
providers.

JWTMux has all of the functionality required to take a token from any
provider and store it as a JWT in a browser, and that is the extent of
its responsibilities. It implements the oauth2.Mux interface which would
potentially allow other strategies of oauth2 credential storage.
2017-02-14 16:18:41 -05:00
Chris Goller f1e7ae30c3 WIP 2017-02-13 18:02:43 -06:00
Chris Goller d1359c09b3 Refactor to remove autogenerated code. 2016-10-26 22:10:52 -05:00