Commit Graph
19 Commits
Author SHA1 Message Date
Jeff Mitchell 8987d8d435 Separate out ui handler under build tag (#170) 2020-07-07 16:57:54 -07:00
Todd Knight c44a4c4795 Tools for auth token interception and authentication (#152) 2020-07-07 12:14:26 -07: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 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 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 Malnick 6c2a17c845 feat: use root path for passthrough (#141) 2020-06-23 10:34:07 -07:00
Todd Knight 5b1e4a680d Create Role CUDLR API and SDK (#135)
* Implement the Role CRUD API.

* Implement the Role List API.

* Adding Roles SDK.
2020-06-22 06:56:27 -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
Todd Knight 6ea448a7f3 Adding Groups API endpoint and SDK (#122)
* feat: Add group grpc handler.

* feat: Add group sdk hooks.

* fix:  Adding forgotten generated group sdk file.

* fix:  Fix a copy/paste error in test msg.

* fix:  Correct assert error msg.

* fix: Remove unused proto imports.
2020-06-15 15:22:41 -07:00
Todd Knight df6ca5289f Create User Service Handler and SDK (#106)
* Create user handler stuff.

* Fixing Not Found errors from DB.

* Fixing param names.

* Update the proto's go package generation.

* Generate the user resource.

* Adding SDK methods for users.

* Fix the base type of Users and add tests.

* Connect user service to the controller handler.

* Attach the default org to the Test Controller's client.

* Take into account the provided request paths when the client builds the org/project path prefix.

* Adding comments to the API.

* rename repo function to repoFn.

* Fix typo in update mask errors.

* Clean up tests.

* Remove special checks for request url content in the api client and fix CORS test.
2020-06-09 11:20:59 -07: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
Todd Knight 7f6e78e66e Handler hostcatalogs (#86)
* Created host catalog service.

* Fixing uri generation for create.

* Use newly submitted static host catalog.

* Copying over tests from projects.

* Fix UpdateHostCatalogRequest merging proto.

* Properly use static host catalog prefixes in tests.

* Correct test to verify the expected uri and id prefix is set.

* Add test for unsetting descriptions.

* Correct bad spelling in comment.

* Tweaking variable names.

* Adding Stringer to the catalog type and setting the type on the response.

* Setting up the catalogType to contain more info regarding its type.

* Validate the type field in requests.

* Remove unused method.

* Comment describing invariants around types.

* Wiring in the repo into the static catalog handler.

* Updated comments to the exported methods.

* fix: return the result of handlers.NotFoundError instead of just calling it.

* Fixing typos referencing just hosts instead of host catlogs.

* Update NewService returns an error and a non pointer type.

* Pull "org_id" and "project_id" into constants and the validation of them into the ValidateAncestors.

* Check errors for all Register*HandlerServer calls.

* fix: Remove left over reference that could cause a panic.

* fix: Changing "x := []string{}" to "var x []string"

* fix: Log errors in test cleanup.

* Changing the code to use google.golang.org/protobuf instead of the older github based protobuf library.

* Changing all t.Fatal checks to require.NoError calls.

* Changing unrecognized prefixes to Invalid Argument instead of Not Found.

* fix: toDbUpdateMask now returns error if it was unable to find any valid paths.

* Define CreatedTime, UpdatedTime, and Type at initialization time in toProto.

* Remove unused host catalog from test.

* Change a t.Fatal to a require.NoError that I missed earlier.

* Change shutdown error logging to t.Errorfs.

* Shorten validateX function names.

* Inline API responses.

* Add todo to make a new repo per request.

* Inline regex check for invalid id.

* Change stored repos into repo creating functions which satisfies ICU-223.

* Wrap proto comments to be under 80 characters long.

* Remove the exception on the read only fields that can be set in an Update request.

* Removing out of date comment.

* Use iam.TestScopes instead of making the project myself.

* Renaming files to be consistant with go test standards and resource naming standards.

* Remove TODO related to a task completed in an earlier commit.

* Fix the previous commit which removed the wrong TODO.
2020-06-05 11:52:59 -07:00
Todd Knight 44152ae63e Add API Error Handler (#74)
* Add error handler that converts from rpc.Status errors to Watchtower API errors.

* Better testing for ErrorHandler.

* Rename testcase and remove empty default switch case.

* Change the error status back to int64.

* Converting everything to int32s.

jsonpb wraps int64s as a string which we dont like.  We'll figure out how to use values larger than int64s when it comes up.

* Remove special casing for TraceId which isn't needed anymore.

* Removing wrappers from error details since we never need to know when they are set or unset from the end user.

* Using the helper error functions inside the project service.

* Correct usage of hclog, replace panic with Error log.

* Adding periods to all API returned errors, correct spelling, fix missed invalid argument error not using helper function.

* Change our logged errors to Error instead of Warn.

* Add TODO for defining and using our own defined API error codes.

* Add TODO to remove internal error messages.
2020-05-26 13:46:21 -07: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 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
c0c6a9b0b8 Handler project (#44)
* Renamed fakeRepo to mockRepo

* Changing around TODOs to capture current plans with the code.

* Remove the repo interface and use a real DB for tests.

* Fixed a few tests.

* Adding checks for properly formatted identifiers.

* Updating code to account for recent merges.  Relaxing some restrictions on what an id can look like.

* Added small comment explaining why RegisterGrpcGatewayer interface exists.

* Move project service up a call level.

Long term I think it would make sense to define these services even higher up the call stack, potentially at the initialization of the controller server, near where the DB is initialized.

* Making these fields align with those in the resources under hosts/...

* Hard code the service initialization in the handler registration code.

* Regenerate project related code proto code.

* Removing type field for project.

* Adds basic project handling in CLI/SDK (#47)

*    Adds SDK for creating and reading projects
*    Reorganizes a bit
*    Adds CLI for creating and reading projects
*    Fixes some some generation bugs
*    Adds redirect support for default org ID

* Fix protobuf import references being moved.

* Update client test to look for "orgs" and "projects" instead of "org" and "project"

* Update expected segments test

* Fix setAddr handling when default organization is in use

* Set client in target after create or read

Co-authored-by: Jim Lambert <jimlambrt@Jims-MBP-3.home>
Co-authored-by: Jim <jlambert@hashicorp.com>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-05-12 17:35:48 -07:00
Jeff Mitchell 6254e18698 Fix compilation of command 2020-05-04 12:41:36 -04:00
Todd KnightandJeff Mitchell c7126ae69b Static Catalog Api definition (#12)
* Setup buf to see and process protos correctly.

This commit adds a proposed directory structure for protos.  Included is a rough draft of the Ec2Catalog protos.

* Add host and host_catalog service apis.

This also has for the first time the move away from holding individual ids for resources and instead using the full uri path as the api facing identifier.  There are some issues with the swagger generation stripping out the format of the path matching so currently only PATCH uses the approach I would like to move to.  In follow up commits I'll try to either get swagger to display the correct expected paths or I'll resolve if that is even needed by our clients.

* Move all protos and generated files to under the internal directory.

This also required updating the buf config to explicitly name the exluded linted proto files under oplog since previously /internal/ was listed as a root in buf.  Future commit will move oplog proto files to be with the others.

* Moved oplog related protos to under the proto directory and regenerated.

* Update the oplog protos to be compliant with buf lint.

* Clean up comments in tools.

* Merged in recent changes to oplog protos.

* Add resource result messages to contain the read only fields and separate them from the writable fields.

* Merge the ec2 catalog resources in with the more generic host_catalog resource.

* Cleaning the generated swagger.

This included adding summaries for each proto rpc method, Making the resources be the full fqn, removing the default error, and a few other tweaks.

* Make project plural in the paths.

* Adding the ability to add and remove hosts from a host set.

* Add the ignore result limit for host set request.

* Make size and host lists read only.

* Add documentation about what host references are allowed to be added.

* Remove ignore result limit when listing items.  These can be added in later.

* Add handlers and tests for unimplemented services.

* Add bootstrap target and update how tools are built (#13)

* Update tool installation method, add bootstrap target to makefile

* Changing org to orgs in all paths and org param to org_id.

* Adding tests for unimplemented service implementations.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2020-05-01 12:38:01 -07:00
Jeff Mitchell 482b4d56dd Initial commit 2020-03-04 12:51:46 -05:00