Commit Graph
65 Commits
Author SHA1 Message Date
Jeff Mitchell 322b13ae98 Standardize static group -> group naming (#236) 2020-07-31 17:46:04 -04:00
Todd Knight 3204e54dc2 Add lookup, list, update, and delete methods for auth methods. (#230) 2020-07-31 14:35:56 -07:00
Jim cb89422d9d define immutable fields including PKs. (#205) 2020-07-30 16:04:15 -04:00
Michael Gaffney e03a0ff9d7 Simplify SetTableName pattern (#214) 2020-07-23 17:58:41 -04:00
Todd Knight f47046f158 Update Watchtower to use grpc-gateway v2 (#204)
* Migration to grpc gateway v2.
2020-07-23 11:26:15 -07:00
Todd Knight ed05652729 Add Handlers for Add/Set/Remove Group Members (#209)
* Adding members to groups.

* Adding Group membership handler and API methods.

* Adding custom methods to permision actions list.
2020-07-22 15:10:21 -07:00
Michael Gaffney 799242fce4 Bump deps and run 'make gen' (#212) 2020-07-22 17:00:22 -04:00
Todd Knight 078376da07 Fixing some errors. 2020-07-22 12:30:58 -07:00
Jeff Mitchell 388a13b10d Convert scopes to the new paradigm (#206) 2020-07-22 00:14:28 -04:00
Todd KnightandJeff Mitchell 168ae3a726 Create MaskManager to guarantee wire/storage update mask consistency (#121)
* Feature: Create MaskManager logic to handle project -> scope update mask logic.

* Updating resource protos and services to use new mask manager setup.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-07-20 11:17:09 -07:00
Jeff Mitchell dec1f07266 Update deps and make proto 2020-07-20 13:47:27 -04:00
Jim c83e90ed38 implement SetTableName patttern that allows table name to be set back to the default for the storage type. (#196) 2020-07-17 16:20:56 -04:00
Todd Knight 5bb13e71fe Include Principals and Grants on Roles When Updating the Role. (#203) 2020-07-17 09:31:10 -07:00
Jim 4dfc41514b refactor direct sql into query.go (#192) 2020-07-15 13:32:36 -04:00
Jim 1bebe7a261 Convert option db.WithVersion to *uint32 (#195) 2020-07-15 13:12:15 -04:00
Todd Knight 28dbcd84bd Authenticate Handler API and SDK, and much more (#183) 2020-07-14 17:32:47 -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
Jim e1afed75ff fix dbMask and role tests... (#188)
* fix up tests.

* case sensitive dbMask
2020-07-10 20:44:00 -04:00
Todd KnightandJeff Mitchell 847ca1cc78 Grant management added to Roles API and SDK (#185)
* Adding grants related methods to Roles.

* Adding grants back after the merge of Principals.

* Adding tests for Grant related custom methods.

* Improving api handler methods.

* Fixing tests and sdk field.

* Adding todos for adding principals and grants to List and Update Role responses.

* Fix up Set* tests and fix SetPrincipals bug.

* Making AddPrincipals and RemovePrincipals similar to the tests for AddGrants and RemoveGrants.

* Add JSON grants to output (#187)

I also changed canonical_grants to grants_canonical and used
grants_json. I believe that when members are simply different formats of
other members this is the preferred way to have it in the API. Let me
know if you disagree and we can dig in more.

* Regenerate the API role resource.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-07-10 17:42:47 -07:00
JimandJeff Mitchell 260703febe add group member capabilities (#178)
* add group member capabilities

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-07-10 19:01:23 -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
Todd KnightandJeff Mitchell 1ddc59f81e Adding principal custom methods to roles handler. (#180)
* Adding Add/Set/Remove principals API calls.

* Add SDK custom methods.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-07-10 11:21:11 -07:00
Jim 136e923583 make iam_role scope_id immutable (#179) 2020-07-10 10:22:38 -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
Jim 6c1b45f7f5 add principal roles (users and groups) to iam (#163) 2020-07-08 17:02:01 -04:00
Todd Knight bb4a185412 Pushing test db cleanup up to where the database objects are created using t.Cleanup. (#166) 2020-07-06 10:15:01 -07:00
Jim 3e3144117e iam and auth integration (#144) 2020-06-29 08:18:57 -04:00
Jeff Mitchell d8f11af4d7 Move actions, resource (types), and scopes to packages. (#149) 2020-06-26 11:00:14 -04:00
Todd Knight 0c8385b423 Updating TxHandler to accept a reader as well in order to support reads inside the same transactions as writes. (#139) 2020-06-22 13:27:26 -07:00
Todd Knight 0a0d37668d Org List and Get API Methods (#132)
* Create the organization Get handler.

* Added org listing.

* Make sure the cmp.Diff always sorts the returned organizations before comparing.

* Connect organization service to the Controller handler.
2020-06-19 10:55:50 -07:00
Jim ed60cac7fe add listing for groups and roles (#130) 2020-06-19 12:06:25 -04:00
Jim 1974e355c8 delete all users at the start of each test. (#129) 2020-06-19 11:27:35 -04:00
Jim 342bef7767 listing projects and organizations (#124) 2020-06-18 14:53:11 -04:00
Jim d9073a03d5 listing users (#118) 2020-06-16 18:59:30 -04:00
Jim ffddf24f86 iam roles (#116) 2020-06-15 12:42:08 -04:00
Todd Knight 1637403624 fix: Removing unused imports and proto files. (#119) 2020-06-13 18:36:05 -07:00
Jim cc5114bdef refactor scopes to conform to public id usage and repo error msgs (#117) 2020-06-12 15:22:23 -04:00
Jim 5c2cff3ad2 iam groups (#112) 2020-06-11 16:36:47 -04:00
Michael Gaffney 4f30983c14 Bump deps and run make gen (#115) 2020-06-11 10:08:54 -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
Jim 10e08e90f0 cleanup tests: properly use require, catch defer errors, use testing functions (#113) 2020-06-10 12:10:34 -04:00
Todd Knight 6804c98b0b Applying Host Catalog comments to Projects (#105)
* NewService for the project service now returns a non pointer and an error.

* Replacing t.Fatal calls with require.NoError calls.

* Initialize empty slices following the recommended way.

* Don't inline the prefix strings when validating requests.

* Check error when cleaning up the test.

* Add check that update updates the time.

* Use google.golang.org/protobuf where possible instead of github.com/golang/protobuf.

* Shorten the validateX function names.

* Inline API responses.

* Change test cleanup error logging to t.Errorf.

* Remove unneeded creation of an extra project.

* Inline regex check for invalid id.

* Build the pb.Project inline when converting from db to wire proto.

* Change stored repos into repo creating functions.

* Using iam.TestScopes instead of creating them myself.

* Remove out of date comments.

* Update name to match go test naming standards.

* Adding project service comments.

* Using scopeType's new prefix method inside scope.go

* Setting test project's name and desc to default to pass tests.

* Change host catalog to project in test.

* Fixing merge errors.

* Fixing some more merge errors.

* Fix typo in comments.

* Fix typos in project_service.go.

* Update error indicating provided id and the expected prefix.

* Make the RepoFactory types in a common directory.
2020-06-08 14:43:13 -07:00
Jim 7d4993fb61 iam users (#96) 2020-06-04 20:05:08 -04:00
Michael Gaffney 5bdd8a46ea Extract timestamp scanners into reusable package (#91)
* Refactor: move Timestamp from static/store to db/timestamp

* Refactor: convert remaining Timestamps to timestamp.Timestamp

* Use new db timestamp
2020-06-01 11:46:50 -04:00
Michael Gaffney 6a8fd56864 Fix after merging in #90 2020-06-01 10:27:49 -04:00
Jim ef6edbd515 Null updates (#78) 2020-05-31 19:55:56 -04:00
Jeff Mitchell 31ef4a65ac Bump deps and make gen 2020-05-29 11:21:12 -04:00
0c7f6da936 Static Host Catalog (#51)
* database: add wt_public_id domain type

* static-hosts: add migrations

* Rename migrations

* migrations: add description column and fix foreign keys

* Add protobuf for static host

* Add HostCatalog and HostSet

* Add Options

* Add foreign key constraint

* Add package doc

* Add copied scanner code

* Add NewHostCatalog with tests

* Override default table name for static host catalog

* WIP: save static host catalog to database

* WIP: Print db url for debugging

* Add iam test helper function

* Make gorm default to null for names and descriptions

* Add foreign key constraint from host catalog to scope

* Names are not needed for the test org and project

* Avoid an ordering dependency in down migrations

* Use wt_timestamp

* Add check constraint on host address column

* Add Host

* Add HostSet

* Add HostSetMember

* Test a HostSetMember can be written to the database

* Move the getters and setters for table name to a new file

The TableName methods are needed by gorm and the SetTableName methods
are for oplog. Moving them to a new file so related functionality is in
the same file.

* Add repository

* Add NewRepository

* Close connection before cleanup of database

* Add comments to protobuf file and regenerate

* Define repository methods for HostCatalog

* Assign PublicId when resource is inserted into the database

* Wrap a nil parameter error

* Add oplog tickets for static host types

* WIP: first cut at CreateCatalog

* CreateHostCatalog: more tests

* Detect unique constraint violation

* Use const for PublicId prefixes

* Use PostgreSQL error name instead of error code

* Add TODO comments

* Fix comments

* Use PublicId not PublicID

* Refactor: move error variables from host/static to db

The error variables defined in host/static are generic and can be reused
by other packages.

* Create a new repository for each test

* Validate CreateCatalog returns a new HostCatalog

* Do not modify the HostCatalog passed in

* Implement UpdateCatalog

* Minor cleanup to make folds work

* Implement LookupCatalog

* Refactor: extract allocCatalog function

* Add comment

* Refactor: extract newCatalogMetadata function

* Make error strings more consistent

* Move database specific error check to internal/db package

* Change signature of DeleteCatalog and update docs

* Implement DeleteCatalog

* Make error strings more consistent

* Add examples

* Update docs

* Add package level doc and example for repository

* No need for using reflect.DeepEqual

* Remove redundant comment

* Clarify ErrMultipleRecords results in the transaction being rolled back

* Remove redundant error checks

* Remove unnecessary check

* Return early instead of using nested 'else' statements

* Update and Delete must return a row count

* catch err on defers (#82)

Co-authored-by: Jim Lambert <jimlambrt@Jims-MBP-3.home>

* Remove 'if assert' pattern

* Use assert package in test helper function

* Add test for updating a non existent catalog

* Use a single assert when a specific error is expected

* Use assert package when it clarifies the check

* Catch errors in cleanup functions

* Update comments in protobuf file

* Update doc for UpdateCatalog to reflect the new behavior

* Add common error values for field mask errors

* Require a field mask when calling update methods

* Add TODO for removing direct call to gorm

* Export Public ID prefixes

* Add db timestamp guards

* Remove unused option

Co-authored-by: Jim <jlambert@hashicorp.com>
Co-authored-by: Jim Lambert <jimlambrt@Jims-MBP-3.home>
2020-05-27 18:16:43 -04:00