diff --git a/go.mod b/go.mod index 18632a0a3..ea15add2c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/hashicorp/boundary -go 1.15 +go 1.14 replace github.com/hashicorp/boundary/api => ./api @@ -27,7 +27,6 @@ require ( github.com/hashicorp/go-kms-wrapping v0.5.16 github.com/hashicorp/go-multierror v1.1.0 github.com/hashicorp/go-retryablehttp v0.6.7 - github.com/hashicorp/go-sockaddr v1.0.2 github.com/hashicorp/go-uuid v1.0.2 github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/shared-secure-libs v0.0.2 diff --git a/website/content/docs/developing/building.mdx b/website/content/docs/developing/building.mdx index 5d103d2d0..8fc04d6ef 100644 --- a/website/content/docs/developing/building.mdx +++ b/website/content/docs/developing/building.mdx @@ -9,7 +9,7 @@ description: Building Boundary Building Boundary from source requires: -- [Golang](https://golang.org/dl/) 1.15 or greater +- [Go](https://golang.org/dl/) 1.14 or greater. (Note that HashiCorp currently develops against Go 1.15.) - `make` installed - [Docker](https://docs.docker.com/get-docker/) installed - Basic development environment (git, xcode if you're on Mac, etc) @@ -19,6 +19,10 @@ Building Boundary from source requires: 2. `$ cd boundary` 3. `$ make dev` +The first time you run `make dev` it will build UI assets, which will take a +long time. After the initial build, you can update those assets to the +currently-pinned version via `make build-ui`. + Once you've built Boundary, the binary will be available at `/bin/boundary`. Move this binary to somewhere in your `$PATH` such as `/usr/local/bin`. diff --git a/website/content/docs/developing/sdk/authenticate.mdx b/website/content/docs/developing/sdk/authenticate.mdx index 7905c3bae..73770f295 100644 --- a/website/content/docs/developing/sdk/authenticate.mdx +++ b/website/content/docs/developing/sdk/authenticate.mdx @@ -21,32 +21,32 @@ We'll cover how to authenticate to Boundary via both of these workflows. This is the most common way for a client to authenticate to Boundary. To demonstrate this, we'll use the [authmethods](https://github.com/hashicorp/boundary/tree/main/api/authmethods) library to generate -a valid token for a client in go. +a valid token for a client in Go. -For this example, we're going to use the password auth method. This example assumes there's already -a valid user and an associated account in Boundary for the client to authenticate as. To simplify this -example, we're assuming you're running a Boundary instance in dev mode, where the default auth method, login name, -and password are pre-configured. +For this example, we're going to use the Password auth method. This example +assumes there's already a valid user and an associated account in Boundary +against which the client can authenticate. To simplify this example, we're +assuming you're running a Boundary instance in dev mode, where the default auth +method, login name, and password are pre-configured. -First, we need to create a net/http client from the Boundary API and set the address to reach Boundary: +First, we need to create a client from the Boundary API and set the address to reach Boundary: ```golang import github.com/boundary/api -// assumes Boundary in dev mode -const boundaryAddr := "http://localhost:9200" - +// The default address points to the default dev mode address client, err := api.NewClient(nil) if err != nil { return err } - -client.SetAddr(boundaryAddr) ``` -The [auth method client](https://github.com/hashicorp/boundary/blob/main/api/authmethods/authenticate.go) uses a basic `map[string]interface{}` to pass credential information. For this example, -we assume you're using the password auth method and so we're going to tailor a credentials object -to pass this data as: +The [authenticate +method](https://github.com/hashicorp/boundary/blob/main/api/authmethods/authenticate.go) +uses a basic `map[string]interface{}` to pass credential information, in order +to eventually support multiple auth method types. For this example, we assume +you're using the password auth method and so we're going to tailor a credentials +object to pass this data as: ```golang credentials := map[string]interface{}{ @@ -55,14 +55,16 @@ credentials := map[string]interface{}{ } ``` -Now lets create an auth method client using the base client from above: +Now let's create an auth method client using the base client from above: ```golang -import github.com/boundary/api/authmethods +import "github.com/boundary/api/authmethods" am := authmethods.NewClient(client) ``` +~> This creates a shallow copy of the base client. Modifications made to the client via `am.ApiClient()` will not be reflected in the base client. + The last thing you'll need is the ID of the auth method in Boundary. You can get this on the CLI with: @@ -91,6 +93,7 @@ if err != nil { Lastly, let's update the original client with the token we got from the `Authenticate()` call: ```golang +// pass this client to any other resource specific API resources client.SetToken(at.Item.Token) ``` @@ -102,21 +105,17 @@ import ( github.com/boundary/api/authmethods ) -// assumes Boundary in dev mode -const boundaryAddr := "http://localhost:9200" - credentials := map[string]interface{}{ "login_name": "admin", "password": "password", } +// The default address points to the default dev mode address client, err := api.NewClient(nil) if err != nil { return err } -client.SetAddr(boundaryAddr) - am := authmethods.NewClient(client) at, err := am.Authenticate(context.Background(), "ampw_1234567890", credentials) if err != nil { @@ -129,13 +128,19 @@ client.SetToken(at.Item.Token) ## Recovery KMS Workflow -The recovery KMS workflow allows you to use a valid [KMS configuration](/docs/configuration/kms) to generate a token for a Boundary -client. For this example, we're going to assume you've read the above and know how to get a base Boundary API -client. +The recovery KMS workflow allows you to use a valid [KMS +configuration](/docs/configuration/kms) to authenticate and authorize calls +within the Boundary API. For this example, we're going to assume you've read the +above and know how to get a base Boundary API client. -Lets start with a valid KMS configuration for recovery that uses a hard coded AEAD key as the basis. To authenticate with Boundary using this config we're assuming you have a instance of Boundary that declares this as the recovery KMS in the Boundary controller config as well. +Lets start with a valid KMS configuration for recovery that uses a hard coded +AEAD key as the basis. To authenticate with Boundary using this config we're +assuming you have an instance of Boundary that declares this as the recovery KMS +in the Boundary controller config as well. ```golang +import "github.com/hashicorp/boundary/sdk/wrapper" + const kmsConfig := ` kms "aead" { purpose = "recovery" @@ -149,20 +154,14 @@ kms "aead" { Now lets use this config to configure our Boundary API client: ```golang -client.SetRecoveryKmsWrapper(kmsConfig) -``` - -And finally, execute `Authenticate()`: - -```golang -am := authmethods.NewClient(client) -at, err := am.Authenticate(context.Background(), "ampw_1234567890", credentials) +w, err := wrapper.GetWrapperFromHcl(kmsConfig, "recovery") if err != nil { return err } -// pass this client to any other resource specific API resources -client.SetToken(at.Item.Token) +client.SetRecoveryKmsWrapper(w) ``` - +The client will now use the recovery KMS wrapper for all authenticated calls +(even if you have previously set a token). You can remove it by instantiating a +new client, or by passing `nil` into `SetRecoveryKmsWrapper`. \ No newline at end of file diff --git a/website/content/docs/developing/sdk/index.mdx b/website/content/docs/developing/sdk/index.mdx index e4f7cb072..4af474e5c 100644 --- a/website/content/docs/developing/sdk/index.mdx +++ b/website/content/docs/developing/sdk/index.mdx @@ -8,8 +8,8 @@ description: |- # Overview -The Boundary SDK is written in golang and the reference documentation here assume basic golang experience including a local -environment for developing golang code bases. +The Boundary SDK is written in Go and the reference documentation here assumes basic Go experience including a local +environment for developing Go code bases. ## Getting Started