Commit Graph
100 Commits
Author SHA1 Message Date
Jeff Mitchell 28df6eb7b0 Update config encrypt/decrypt CLI command (#309)
This updates the command to our emergent standards. It also enables
using a separate config file for a config kms, which allows non-string
values to be encrypted.

This allowed some nice cleanup as well.
2020-08-27 16:38:44 -04:00
Jeff Mitchell 274afa6b02 Shave off an IAM lookup if the user is the anonymous user (#305)
* Shave off an IAM lookup if the user is the anonymous user

* Fix build

* If authz failures are turned off, make the token type unknown instead of invalid

* Change returned token format when authz failures are disabled

* Change logic back

* Fix logic
2020-08-26 23:28:38 -04:00
Jeff Mitchell b53812a5c1 Add ability to skip automatic auth method creation (#306)
This is useful if you, for instance, want Terraform to be 100%
responsible for creation of resources (outside of the static ones that
cannot be removed or modified, like u_anon). This will mean using the
recovery mechanism for initial setup, but that isn't an issue once TF
supports that :-)
2020-08-26 23:27:46 -04:00
Jeff Mitchell 490be8a7e4 Add ability to skip role creation on scope create (#308)
* Initial work on scope creation skipping

* Fix things
2020-08-26 23:27:25 -04:00
Jeff Mitchell 39721047e4 Fix CORS test 2020-08-25 12:45:16 -04:00
Jeff Mitchell 8f579c75c3 paum -> ampw (#303) 2020-08-25 00:21:08 -04:00
Jeff Mitchell 74544f6324 Encrypt tokens on the way out and decrypt on the way in (#302)
* Encrypt tokens on the way out and decrypt on the way in

This isn't a security feature related to tokens specifically; it's so
that we can discard cryptographically bad tokens before we ever hit the
DB. This way we can't pass through a DDoS to the database due to
fetching obviously invalid token values.

I'm using base58 to encode the resulting value as there aren't great
base62 options, and allowing base64 / and + values can hamper usability
by creating copying/highlighting breaks.
2020-08-25 00:20:50 -04:00
Jeff Mitchell 647d5502b5 Change ListServers to use SeachWhere (#300) 2020-08-24 14:10:41 -04:00
Jeff Mitchell ac4d9fa311 Add nonce storage and replay prevention test (#293) 2020-08-24 13:22:10 -04:00
Jeff Mitchell a1490228b8 Add address to worker status tracing 2020-08-21 16:53:47 -04:00
Jeff Mitchell bc32272ca7 Update go-retryablehttp, strcase, gorm 2020-08-20 17:59:47 -04:00
Jeff Mitchell 414a2ab2c3 Remove some dead, dead, dead, dead code 2020-08-20 17:58:29 -04:00
Jeff Mitchell 627a353ccb Don't return an empty resource if there was an apiErr (#294) 2020-08-20 17:31:38 -04:00
Jeff Mitchell b47cca0329 Add (non-db aspects of) the recovery key workflow (#286) 2020-08-20 13:34:03 -04:00
Jeff Mitchell 8dad85fef4 Add test.hcl to gitignore 2020-08-20 01:05:57 -04:00
Jeff Mitchell 6bf4a5ce38 Add not null checks to wt_private_id, wt_scope_id, and wt_user_id (#284) 2020-08-19 21:45:46 -04:00
Jeff Mitchell a11ca2e3a8 Make gen 2020-08-18 21:58:59 -04:00
Jeff Mitchell e20c150617 Fix some tests broken by merge 2020-08-18 19:16:52 -04:00
Jeff Mitchell adfc5681be Auth methods CLI (#277) 2020-08-18 17:46:34 -04:00
Jeff Mitchell 282177afc2 Remove the default org (#270) 2020-08-17 15:38:41 -04:00
Jeff Mitchell 4655f58365 Make gen 2020-08-17 11:50:59 -04:00
Jeff Mitchell 7b36571788 Change auth validity feedback (#273)
* Change auth validity feedback

Move from a bool indicating validity to lack of an error. This allows
the error to be directly returned and typed.

* Fix erroneous line
2020-08-16 00:42:36 -04:00
Jeff Mitchell fff15bc9f3 Rename KMS purpose 'controller' to 'root' 2020-08-14 10:12:31 -04:00
Jeff Mitchell efaf58b568 Add users CLI command and do some cleanup (#269) 2020-08-13 20:59:32 -04:00
Jeff Mitchell 6080d93f8f Add authtokens CLI command (#268) 2020-08-13 20:25:28 -04:00
Jeff Mitchell d3a1cd949b Update password auth method flags to fit current standards 2020-08-13 18:32:58 -04:00
Jeff Mitchell bb6b189513 Create a default role on new scope creation (#265) 2020-08-13 17:39:48 -04:00
Jeff Mitchell e89e9d1349 Add groups CLI command (#266) 2020-08-13 17:35:55 -04:00
Jeff Mitchell b75a6fc5e5 Update scopes CLI command in the model of the roles command (#262)
* Update scopes CLI command in the model of the roles command

* Pull help functions to helper methods
2020-08-13 11:20:22 -04:00
Jeff Mitchell f1d69ea1ee Fix breakage from change to api generation 2020-08-12 21:57:44 -04:00
Jeff Mitchell 2c4c991cca Export API clients 2020-08-12 17:34:56 -04:00
Jeff Mitchell 419e2146d4 Revert "Move api tests to internal package to remove issue with external resources depending on internal libs"
This reverts commit 326086e352.
2020-08-12 17:19:21 -04:00
Jeff Mitchell b0c0129ab2 Add a dummy file to ui package 2020-08-12 17:16:10 -04:00
Jeff Mitchell 326086e352 Move api tests to internal package to remove issue with external resources depending on internal libs 2020-08-12 17:06:09 -04:00
Jeff Mitchell 5d104a7a01 Migrate off Vault's internalshared folder to the separated-out repo 2020-08-12 16:12:45 -04:00
Jeff Mitchell c195c4bc9b Remove disabled property and sync up field ordering and numbering (#259) 2020-08-12 13:00:49 -04:00
Jeff Mitchell 203e2b5dc2 Initial worker porting steps (#232) 2020-08-12 00:40:39 -04:00
Jeff Mitchell 73a38b1433 Remove some unneeded resource types and fix the resource typing for default role in global scope (#256) 2020-08-12 00:02:26 -04:00
Jeff Mitchell 4cfab04307 Migrate user name to login name (#255) 2020-08-11 17:25:00 -04:00
Jeff Mitchell 61378381c6 Add version to account update (#252) 2020-08-11 12:28:11 -04:00
Jeff Mitchell 78d7f539c5 Add versioning to host catalogs/sets/hosts and fix up tests (#247)
* Start adding version to host resources and fixing up tests

* Add versioning to host resources and update API tests

* Fix nil in test

* Add missing update
2020-08-11 11:20:06 -04:00
Jeff Mitchell 565059ed63 Add versioning to auth methods and accounts (#249) 2020-08-11 11:19:29 -04:00
Jeff Mitchell 6661117d4c The name. The name. The name! 2020-08-10 17:15:02 -04:00
Jeff Mitchell 0c18e35b9d Fix group service proto for versions 2020-08-08 19:27:49 -04:00
Jeff Mitchell 4e58c55d66 Fix up user API tests 2020-08-08 18:28:08 -04:00
Jeff Mitchell 827d86bef1 Update API role tests and fix the structure of the protos so versioning works 2020-08-08 17:46:41 -04:00
Jeff Mitchell f1b3ad373e Go mod tidy 2020-08-08 10:50:30 -04:00
Jeff Mitchell 6a21e8dedb Fix some speling and a test 2020-08-07 21:14:07 -04:00
Jeff Mitchell 99ed9d9b0c Fix group api tests 2020-08-07 21:09:52 -04:00
Jeff Mitchell bbd200101f Move update versioning to query parameter, and fix up scope API tests (#244)
* Move update versioning to query parameter, and fix up scope API tests

* Add version checks for update requests in other services
2020-08-07 17:56:55 -04:00
Jeff Mitchell 0d0660b061 Fix some tests I broke 2020-08-07 17:46:33 -04:00
Jeff Mitchell f07bb9dae6 Fix breakage after change to template from previous PR 2020-08-07 15:18:44 -04:00
Jeff Mitchell df4730b1a0 Minor fixes and first API test changeover (#243) 2020-08-07 15:01:18 -04:00
Jeff Mitchell d74e30d94a Minor, easy, linting fixes 2020-08-07 13:50:39 -04:00
Jeff Mitchell 8dd5de49b9 Minor update to default role description text 2020-08-07 13:42:04 -04:00
Jeff Mitchell 5bf307797b Fix typo and also set default min user name length to 3 because jeff, jim, todd, mike 2020-08-07 13:38:44 -04:00
Jeff Mitchell 908a299ea3 Convert SDK to the new options API (#238) 2020-08-07 12:55:02 -04:00
Jeff Mitchell 2ca7e0b88e Fix some linting complaining 2020-08-03 13:13:20 -04:00
Jeff Mitchell 322b13ae98 Standardize static group -> group naming (#236) 2020-07-31 17:46:04 -04:00
Jeff Mitchell 194db3a6d8 make proto 2020-07-27 15:14:21 -04:00
Jeff Mitchell c0f3a72bac go mod tidy 2020-07-27 12:01:40 -04:00
Jeff Mitchell 65dc095fbc Remove another duplicated entry 2020-07-22 21:45:58 -04:00
Jeff Mitchell b1937c3b18 Remove duplicated inject tag statement in Makefile 2020-07-22 21:38:30 -04:00
Jeff Mitchell e8325a9f59 Don't rely on token for scopes collection actions (#210)
Don't rely on token for scopes collection actions

This requires `scope_id` to be passed (via query param) for actions on
the scopes collection; that is, listing or creating. However, it removes
the dependency on using the token for the scope of the command. For
actions on a specific scope, we use the given ID to determine the scope
we should be operating at, doing a lookup if necessary.

Existing tests have been updated. Of particular note, the CORS test was
already operating on the scopes collection so served as a good test to
ensure that from an API level the scope_id parameter was being parsed
and passed through (the tests fail without adding that query parameter
in).
2020-07-22 15:10:44 -04:00
Jeff Mitchell 2bbc1163c4 Save the entire token, not just the ID (#211)
This allows us to use the token's scope to set the default scope for an
action in the client instead of relying on env vars.
2020-07-22 15:02:58 -04:00
Jeff Mitchell 995b76bbc5 Fix error that slipped in during review in #206
A strings.LastIndex call check was meant to be `-1` and got
clumsy-fingered to `-11`. This causes panics with API clients.
2020-07-22 13:29:53 -04:00
Jeff Mitchell 388a13b10d Convert scopes to the new paradigm (#206) 2020-07-22 00:14:28 -04:00
Jeff Mitchell 982693d8f5 Update tests 2020-07-20 13:52:16 -04:00
Jeff Mitchell dec1f07266 Update deps and make proto 2020-07-20 13:47:27 -04:00
Jeff Mitchell fa5f45260b Bump Vault dep 2020-07-17 15:32:48 -04:00
Jeff Mitchell 99653727bb Migrate grants to more structured output (#194) 2020-07-16 22:18:27 -04:00
Jeff Mitchell 1a1d3058c9 Move verification to a shared package (#197)
* Move verification to a shared package

The verifier is constructed at HTTP request time and added to the
context. It can then be called from appropriate handlers with
standardized error handling after all the routing.

I intentionally did not add to the handlers yet as I am a good distance
into the scope updates and didn't want to cause even more merge
conflicts. So at the moment authz is again disabled, but once the scope
updates are done, this will be integrated back in.
2020-07-16 22:12:26 -04:00
Jeff Mitchell acce195dcb Organizations -> orgs consistency (#189)
* Organizations -> orgs consistency

* Fix up some tests and some mistaken substitutions
2020-07-11 12:00:49 -04:00
Jeff MitchellandJim Lambert c657e4b9fc Fix test broken through various merges (#186)
Co-authored-by: Jim Lambert <jlambert@hashicorp.com>
2020-07-10 18:59:39 -04:00
Jeff Mitchell f30d4d08ef Pass grant scope ID through API handlers (#184) 2020-07-10 17:56:33 -04:00
bcdcaffa6f Port over 162 and 165 to master (#176)
Co-authored-by: Jim Lambert <jlambert@hashicorp.com>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2020-07-10 15:46:26 -04:00
Jeff Mitchell 732c07126d Introduce global scope (#168)
Introduce the global scope, which holds some resources that don't necessarily belong at either the org or project level.
2020-07-08 17:20:20 -04:00
Jeff Mitchell 4decf9502a Fix handler test by moving it to a new file with a build tag 2020-07-07 20:42:17 -05:00
Jeff Mitchell 8987d8d435 Separate out ui handler under build tag (#170) 2020-07-07 16:57:54 -07:00
Jeff Mitchell 316b250a24 Use dockertest v3 consistently (#167) 2020-07-06 12:41:09 -04:00
Jeff Mitchell c965cf1bc5 Attempt to fix content-length header in index (#159) 2020-06-30 17:37:24 -04:00
Jeff MitchellandRandall Morey 8da4effd5e Add mechanism for bundling UI assets. (#153)
* Add mechanism for bundling UI assets.

The scripts/uigen.sh script will check out the UI repo, build assets,
create a static assets file, and clean up.

The dev Makefile target has been modified to run this script if no
assets file is found. There is also a build-ui target that will
unilaterally update (the dev target only builds if the file isn't found,
but doesn't update).

The handler has been updated to add the default org ID as a header if
the request path is "/".

Co-authored-by: Randall Morey <randall@randallmorey.com>
2020-06-30 11:26:22 -04:00
Jeff Mitchell d8f11af4d7 Move actions, resource (types), and scopes to packages. (#149) 2020-06-26 11:00:14 -04:00
Jeff Mitchell 9d1d0ba08e Simplify UI passthrough logic (#148)
I realized we can handle the special case of `/index.html` by ensuring
that `/` does the right thing because that's _also_ standard behavior to
fetch `/index.html`. As a result this allows a lot of simplification.
2020-06-25 15:03:03 -04:00
Jeff Mitchell 94f66c9ee6 Fix test function breakage after merging encrypted config 2020-06-25 12:16:59 -05:00
Jeff Mitchell 16b56a37ed Rename base.New -> base.NewCommand for clarity 2020-06-24 15:10:12 -05:00
Jeff Mitchell 8de5371499 Enable UI handling logic with dev passthrough directories. (#145)
* Enable UI handling logic with dev passthrough directories.

* Add tests and fix a couple of things
2020-06-24 16:06:19 -04:00
Jeff Mitchell 993a6f1680 Remove "projects" from grant strings (#143)
This removes the ability for a grant string to switch projects, in
accordance with our updated design. It mostly removes code, with a few
test fixes, and also adds one additional check (and test) to ensure a
grant errors rather than do-nothing succeeds if both id and type are
empty.
2020-06-23 11:28:44 -04:00
Jeff Mitchell f41bf6e31e Add permission grant string parsing and validation and ACL implementation (#109)
This adds parsing and validation for grant strings along with the ability to create canonical JSON and text strings from a grant.

It also adds an ACL implementation, allowing a collection of grant strings to then be checked against a resource/action tuple and indicate if it's allowed.

Note that only specific sets of provided data in grant strings is allowed. This vastly simplifies logic.

Test coverage is 100%.

A future update will consolidate and migrate types between this and IAM but I didn't want to mix that in with this.
2020-06-10 17:58:52 -04:00
Jeff Mitchell 5333482ff8 Fix gorm newlines issue (#108)
Even if you made a custom formatter for gorm, it would blithely println
anything returned, including nils, resulting in lots of new lines when
we were ignoring output. This also creates a custom logger that doesn't
do anything when newlines are found.
2020-06-08 21:12:00 -04:00
Jeff Mitchell c175fcde8d Add a gorm log formatter to adapt to hclog (#93)
This is also added in a test that otherwise output to stdout, which
validates functionality.
2020-06-01 17:32:48 -04:00
Jeff Mitchell 31ef4a65ac Bump deps and make gen 2020-05-29 11:21:12 -04:00
Jeff Mitchell b718091419 Update signatures of generated files to match our tool versions 2020-05-26 13:29:33 -04:00
Jeff Mitchell 1e78d01c6b Fix panic in handler test by providing empty config 2020-05-21 17:45:45 -04:00
Jeff Mitchell 374a3991a2 Add a passthrough directory feature. (#76)
This is only compiled in when a `dev` build tag is specified (see #75)
for safety. Attempting to use the flag without that tag at build time
will fail. However, it is always available within the codebase itself so
that tests can be written against this functionality in a programmatic
way.

Manual testing was performed; no plans to add automated ones as this
isn't production-necessary nor exported functionality.
2020-05-21 16:12:31 -04:00
Jeff Mitchell 9fd86faf15 Adds a dev target to Makefile and ports over build script (#75)
* Initial work on dev builds

* Fix build script
2020-05-21 16:03:21 -04:00
Jeff Mitchell 8d5a987859 Bump g-k-w dep 2020-05-21 15:35:57 -04:00
Jeff Mitchell fafdcbbfa4 CORS support (#73)
This adds per-listener CORS support. Logic is ported from Vault, along with a fully new test suite.
2020-05-21 12:12:08 -04:00
Jeff Mitchell 66978d637a Fix tools bootstrap 2020-05-21 10:38:07 -04:00
Jeff Mitchell a04ac2202d Fix build after dep update 2020-05-19 20:12:01 -04:00