Commit Graph
188 Commits
Author SHA1 Message Date
Timothy Messier 0a4df95fdd ci: Run sdk and api tests in ci
This adds new makefile targets and configuration to run the tests in the
api and sdk modules. These do not run by default since `go test ./...`
does not cross module boundaries.
2021-12-02 07:27:54 -05:00
Jeff MitchellandJim 866bfceefc Add secrets_hmac to host catalog output (#1712)
Co-authored-by: Jim <jlambert@hashicorp.com>
2021-11-16 18:54:38 -05:00
Jeff Mitchell b3fd23863f Add external ID to host output (#1705)
This also fixes a bug if no hosts were returned where the job would run
over and over in a loop, and some other cleanup.
2021-11-13 17:18:20 -05:00
Jeff Mitchell 30e9f944a2 Add sync interval to host sets (#1680)
This adds a parameter to host sets allowing the sync interval to be
user-specified on a per-host-set basis. A value of -1 disables syncing;
a value of null uses the current default.
2021-11-11 11:28:08 -05:00
Jeff Mitchell 3f3f6d974c Update API go.mod to require Go 1.17 2021-11-10 15:10:18 -05:00
Jeff Mitchell 80d41b9044 Merge branch 'main' into plugin-hostcatalogs 2021-11-04 09:02:39 -04:00
Todd 808b986834 Read and List Plugin based Hosts (#1655)
* Add ability to read and list hosts.  Tests to follow.

* Add tests for reading and listing as well as validation checks to not modify hosts.

* Add IpAddress and DnsNames to the api resource.  Populate the plugin info.

* Adding go sdk tests for reading and listing hosts and ensuring update and deleting is disallowed.
2021-11-02 14:06:20 -07:00
Timothy Messier 1da403a2d2 feat(api): Add support for egress credentials for targets endpoint 2021-11-01 13:33:54 -04:00
Jeff Mitchell 158ab09952 Merge branch 'main' into plugin-hostcatalogs 2021-10-05 16:27:28 -04:00
Jeff MitchellandTodd 7d71618df0 Add more host-catalog and host-set CLI support (#1567)
Add more host-catalog and host-set CLI support

Co-authored-by: Todd <T.Alan.Knight@gmail.com>
2021-09-28 09:40:12 -04:00
Jim 6c7333cbe0 chore: Update sdk dep 2021-09-27 16:28:51 -04:00
Jeff Mitchell a834a14785 Add attribute flag building and parsing (#1562)
This adds a few command sketches but that's not the main point of the PR
and filling those out will come in a different PR. This adds a new flag
type that can combine inputs to a single target slice, retaining the
ability to distinguish where it came from but also keep ordering across
different flag names. It also implements a function that does the
heuristic parsing with fallback.
2021-09-26 11:48:43 -04:00
Todd a4ea99047f Remove Prefix Id and Plugin Name fields (#1563)
* Remove Prefix Id and Plugin Name fields.  Creating catalogs now require either the plugin id or the name of the plugin resource (but not both).  Host Catalogs and Host Sets API resources now have a read only plugin field populated with plugin info.  Host Catalogs have a plugin id field as a top level field.
2021-09-24 13:16:13 -07:00
Jeff Mitchell 01d4383c1b Add preferred endpoints logic to API/handler/DB and some CLI bits (#1529) 2021-09-20 12:48:38 -04:00
Jeff Mitchell 71cba858e3 Add secrets to host catalogs API struct (#1512)
This also changes the address from a plugin from a scalar value to other
fields, starting with an IP address array.
2021-09-08 12:41:57 -04:00
Jeff Mitchell e9a8ede0d6 Move wrapper package back to SDK (#1511)
TF uses this, so SDK is a decent place for it. It doesn't create
dependencies between it and API.
2021-09-08 12:15:42 -04:00
Jeff Mitchell 8d8290b83e Remove unneeded replace directive 2021-09-07 22:15:16 -04:00
Jeff Mitchell 081de3cf79 Migrate sdk/recovery to api/ and sdk/wrapper to internal (#1507)
* `recovery` is only used by the API (and the main module, for decryption)
* `wrapper` is only used by the CLI right now

Moving these brings them closer to the code that uses them, and makes
the SDK package a bit more clear in terms of functionality.
2021-09-07 22:13:19 -04:00
Jim 48c6195829 chore (api): update sdk dep 2021-09-03 14:52:09 -04:00
Jeff Mitchell f8a51b987c Migrate target host sets -> host sources (#1424)
This follows the same model as https://github.com/hashicorp/boundary/pull/1413

See there and CHANGELOG for more details.
2021-07-30 08:48:03 -04:00
ab6f3eaeb4 Migrate credential-library nomenclature around targets to credential-source (#1413)
See the CHANGELOG entry for more information.

Co-authored-by: Jim <jlambert@hashicorp.com>

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2021-07-27 12:48:36 -04:00
Jeff Mitchell 528d54b4ad Add token/userinfo claims to account read output (#1419)
This is very useful when trying to write managed groups filters as you
can directly look at the structure of the claims for the accounts you're
trying to filter.

The output of the claims in text format on the CLI currently leaves
something to be desired. I started revamping some of the formatting
functions and it quickly got very fragile. Fundamentally at this point
we're likely better off -- now that we have a good idea what our output
format/standards are like -- rewriting the formatting code. I'll take
that as a tasker as I have a lot of ideas...
2021-07-26 17:52:18 -04:00
Jeff Mitchell 5b7544c81f Update API against shared libs and sdk 2021-07-14 17:24:06 -07:00
Jeff Mitchell 2cbcf9a563 Update usage of shared-secure-libs (#1393) 2021-07-12 21:06:22 -04:00
Jeff Mitchell 7c3d5be4f6 Update format of secret to return both raw and decoded when possible (#1372) 2021-06-30 18:02:03 -04:00
Jim 4c0276b4af update sdk dep 2021-06-29 07:05:08 -04:00
Jeff Mitchell 86c9a90554 Update target credential library service, API, SDK, CLI (#1343) 2021-06-25 14:06:31 -04:00
df35699c4e Integrate with Vault to retrieve and manage per session credentials (#1308)
* Fix down migrations

* Udpates due to merge

* Sentinel values only have to be greater than 0

* Create credential related sdk structs and methods.

* Post merge interface updating.

* Removing scratch code that was not cleaned up.

* updates

* Convert client certificate and client certificate keys into pem blocks and validate.

* Add newline at end of file.

* Faster check for "s" at the end of a resource name when generating from templates.

* make fmt

* updates

* Add dynamic credentials to a session

* Refactor: move contents of file

* updates

* Updates

* Add InvalidDynamicCredential error

* Assign credentials

* Allow updating client certificates seperate from the client certificate key.

* Replace application purpose string with enum value

* PR feedback / fix go test .

* Delete dead code

* Use common view

* Refactor: extract interface and rename method

* Refactor: move code to eliminate privPurpLibrary

* Add comment to requestMap

* Refactor: do not export methods on an unexported struct

* Update internal/db/schema/migrations/postgres/10/03_vault_credential.up.sql

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* Add comments to credential Purpose constants

* Reorder switch statements to handle errors first

* PR feedback

* update

* fix merge

* Organizing the scheduler code and extract the individual store creation test helper function.

* Run 'make fmt'

* Create certificate when creating store.  Allow vault address to be passed in as option

* Refactor: rename database views and associated structs

This change renames two database views and associated go structs to use
a consistent naming pattern. Views ending in 'private' contain encrypted
credentials needed for connecting to Vault. Views ending in 'public'
mirror the 'private' views but do not include any encrypted values.

This change does not include any changes to functionality or behavior.

* Adding SAD target operations for credential libraries to the SDK.

* Add status field and enumeration table for credential status

* Refactor: rename Status to TokenStatus

* Add status to vault credentials

* Creating the template for the CLI and helper functions.

* Add private database view for vault credentials

* Add scope_id to view and cleanup TODO comment

* Reformat embedded sql queries

* Add vault client helpers

* updates

* white space

* Add LookupLease test

* CLI commands for Store work.  Renamed fields in proto w/ vault prefix.

* Test issue credentials with client TLS

* Add additional checks to vault ping

* Add an error for vault token capabilities and create a VaultToken error kind

* Add support for working with Vault policies

* Use Vault 1.7.2 for testing

* Add testing helper for creating a vault client with a non-root token

* Fix Vault renew lease test

The Vault renew lease endpoint accepts an optional duration parameter
for requesting the number of seconds to extend the lease by. However,
Vault is not required to honor this request.

* Add a var for the required capabilities of a boundary Vault token

* Enhance the test helper for adding a policy to Vault

* Allow the test role in postgresql to revoke credentials

* Remove out of date comments

* Enhance Vault test helpers for the database secrets engine

* Reformat comments

* Add a method for getting the capabilities of the current Vault token

* Add revoke lease to internal Vault client

* Reformat: combine err return line with check for nil line

* Remove redundant checks in test code

Remove checks in test code that are redundant with checks in the test
harness.

* Refactor CreateToken test helper to return the secret and the token

* Fix build failures caused by signature change in vault.CreateToken

* Fix Vault version and Vault API link in comments

* ran `make gen` after merging from mgaffney-vault.

* Remove Vault prefix from attribute fields in API, create a base CLI option for adding field prefixes. format now uses that prefix for error reporting.

* Template now allows attaching attribute field prefixes.

* Credential store uses PrefixAttributeFieldErrorsWithSubactionPrefix.

* Fixing naming of vault flags and helper flags.

* Updating more references to generated api methods.

* Make the capabilities String method more readable

* Add comment outlining PrintApiError usage of Options.

* Refactor test to move declarations closer to first use

* Fix comment

* Implement revoke method on vault repository

* Tests now verify certs, CA, and tokens, addresses can be updated in a store.

* Added test for creating store with pk/cert in same field.

* Allo updating certificates seperate from private key.  Only contact backing vault service when updating token.

* Fixing bad tests and removing unused code.

* Adding tests for various ways of updating tokens.

* Add private credential

* Add token revocation job and cred renewal/revocation job

* Regen after merge.

* Fixing field mask related merge error.

* Create Library CLI. Removes vault prefix from path. Adds a WithoutCleanup testOption for vault.

* Set all credentials to revoked when a token is revoked

* Fixing missed renaming update.

* fix copy/paste error.

* Fixing code generation errors after merge.

* make gen after merge.

* Update internal/cmd/commands/credentialstorescmd/vault_funcs.go

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* Update internal/cmd/commands/credentialstorescmd/vault_funcs.go

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* Update internal/cmd/commands/credentialstorescmd/vault_funcs.go

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* Refactor: move migrations from 10 to 12

* Removing logic from transaction.

* wrapping client errors in the calling op for CredentialStore's client() method.

* Redact token

* redact client key

* updates

* Add trigger to revoke credentials when session is canceled or terminated

* Fixing some help text for some flags.

* Add ability to load values from files (file://) or environment variables (env://).

* Updating comments

* fix bad merge

* feedback

* Adding issued credentials to sessions.

* Error on capabilities

* updates

* Expose NewVaulTestServer

* Add godoc

* Adding generated SessionCredential struct for API.

* Progress on building handler test for Authorize Session.

* feedback

* Update policies

* Add 'revoke' as a status for Vault Tokens

* Add delete_time to vault credential store

* Create dynamic credentials at session creation time.

* Tests pass with credentials attached to AuthorizedSession result.

* Only call issue if there are credentials to issue.

* Fixing output only issues. Adding type to credential library.

* Fix test to clear un/pw generated.  confirm generated un/pw changes from 1 authorize session call to another.

* Update lookupTokenError

* Add delete_time to private credential store

* Refactor: move private store to separate file

* Fixing tests for AuthorizeSession and verifying error cases.

* Only create the credential repo if there are credentials to issue.

* Rename Library field to CredentialLibrary.

* Fixing missing change of Library to CredentialLibrary.

* Removing Default SDK functions for fields which are required and update CLI to match.

* Replace resource specific id variables with "id" and the input parmater for paths to be just a single string and the resource name as it should show up in the path.

* Soft delete vault credential stores

* Prevent new SQL functions from silently overwriting existing functions

* Rename "Hmac" to "HMAC" in the human readable cli response table.

* Fix tests

* Add vault database cleanup jobs

* Add ability to set the token period in the vault test harness

* updates

* Add not_null_columns func test

* remove unused struct

* Up no output timeout

* Validate current vault token on addr update

* Fix client cert change test

* add cert test

* Update revocation job where

* Fix comment

* Use Vault's default port in CLI help strings

* Remove down migrations

* Increase migration file numbers by 1

* Run make migrations

* Move migrations from 12 to 10

* Increase Circle CI timeout for acceptance tests

* Fix spelling mistake in error messages

* ASD cmds for Target and returning credentials to AuthSession request (#1338)

* Add Add/Set/Remove commands for libraries on Targets.  Return credentials on AuthorizeSession request.

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

Co-authored-by: Louis Ruch <louisruch@gmail.com>
Co-authored-by: Todd Knight <T.Alan.Knight@gmail.com>
Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2021-06-22 22:26:26 -04:00
Jeff Mitchell 306d4fb4d3 Add API/CLI for managed groups (#1265) 2021-06-02 14:05:10 -04:00
Jeff Mitchell 179a49657e Managed Groups service (#1262) 2021-06-02 14:01:37 -04:00
Jim 2437cdcc8d OIDC: add support for account claim maps (#1186) 2021-05-04 08:41:04 -04:00
Jim 25e657fa51 Ongoing OIDC: support to request additional OIDC scopes from the IdP (#1175) 2021-04-28 06:53:13 -04:00
Jeff Mitchell 4690225c1e Update delete action behavior and JSON format output (#1155)
This PR changes delete behavior:

* On success, a 204 is returned rather than a 200 with an empty JSON object
* The CLI now passes through the 404 error if encountered instead of swallowing it

It also updates formatting for JSON to use the response body, which means that the item (or items) in the JSON format are actually the format across the wire, instead of being reinterpreted by unmarshaling into the Go SDK and then remarshaling.
2021-04-26 20:38:55 -04:00
Jeff Mitchell 77a85636c2 If we're going to use replace directives, use SDK too 2021-04-21 12:05:37 -04:00
Jim 75108cbc8b Ongoing OIDC: return the primary account info along with the user. (#1145) 2021-04-20 20:33:56 -04:00
Jeff Mitchell 941e74388a Fix curl string building (#1106)
I'm not sure why it was doing it the other way with assuming the string
being built would always have a space at the end, but, this way is
easier to understand and fixes a bug where there wasn't a space being
left between some fields.
2021-04-13 16:08:51 -04:00
Todd Knight 14c222709c Make oidc auth callback redirect on most errors (#1105) 2021-04-13 09:21:26 -07:00
Todd Knight 71673ea161 Pass disable_discovered_config_validation in the API change-state call (#1100) 2021-04-12 08:49:22 -07:00
Jeff Mitchell f05f37d0fa Fix panic in non-generated API calls when printing as JSON (#1095)
Fixes #992
2021-04-09 13:09:51 -04:00
dd0f34bc35 Add new OIDC auth method. (#1090)
Co-authored-by: Todd Knight <T.Alan.Knight@gmail.com>
Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2021-04-08 20:54:32 -04:00
Jeff Mitchell 6605b4c9f8 Revamp authenticate (#1025) 2021-03-24 16:07:43 -04:00
Jeff Mitchell 845f582213 Update api's sdk 2021-03-09 13:52:44 -05:00
Jeff Mitchell 519efa6dd1 Add -filter to CLI listing and website docs (#967)
* Add -filter to CLI listing.

This doesn't include docs/Changelog yet, that will come shortly.

* Add changelog

* Add website docs and fix a curl output bug
2021-03-01 09:23:17 -08:00
Jeff Mitchell f5490e95a6 Sync API deps to main in preparation for tag 2021-02-25 12:41:18 -05:00
Jeff Mitchell ea23737258 Port over API bits from #962 (#965) 2021-02-25 12:39:51 -05:00
Todd Knight cac1e60e11 Add filters to listing different resources in the go sdk. (#957) 2021-02-22 13:31:17 -07:00
Jeff Mitchell 46f0f55a28 Update SDK in API 2021-02-12 11:46:02 -05:00
Kevin Maris 8a8b2fb8e1 Fix nil TLSClientConfig (#901) 2021-02-02 20:50:30 -05:00
Jeff Mitchell 9879841e00 Update SDK in API 2021-01-29 18:28:52 -05:00
Jeff Mitchell 6cd97a4a6e Add support for recursive listing (#885) 2021-01-25 19:37:40 -05:00