Generate new version of SDK resources and Add Tests (#331)
This commit is contained in:
1 parent
96e4b1cdba
commit
c3ecea172d
93 files changed
+3414
-2826
No files matched your search
+6
-244
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/recovery"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
@@ -149,26 +148,12 @@ func Verify(ctx context.Context, opt ...Option) (ret VerifyResults) {
|
||||
return
|
||||
}
|
||||
|
||||
// check if it's new style
|
||||
if opts.withAction != action.Unknown {
|
||||
v.act = opts.withAction
|
||||
v.res = &perms.Resource{
|
||||
ScopeId: opts.withScopeId,
|
||||
Id: opts.withId,
|
||||
Pin: opts.withPin,
|
||||
Type: opts.withType,
|
||||
}
|
||||
} else {
|
||||
// This remains for legacy
|
||||
v.requestInfo.scopeId = opts.withScopeId
|
||||
if err := v.parseAuthParams(); err != nil {
|
||||
v.logger.Trace("error reading auth parameters from URL", "url", v.requestInfo.Path, "method", v.requestInfo.Method, "error", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
if v.res == nil {
|
||||
v.logger.Trace("got nil resource information after decorating auth parameters")
|
||||
return
|
||||
v.act = opts.withAction
|
||||
v.res = &perms.Resource{
|
||||
ScopeId: opts.withScopeId,
|
||||
Id: opts.withId,
|
||||
Pin: opts.withPin,
|
||||
Type: opts.withType,
|
||||
}
|
||||
|
||||
var authResults *perms.ACLResults
|
||||
@@ -192,229 +177,6 @@ func Verify(ctx context.Context, opt ...Option) (ret VerifyResults) {
|
||||
return
|
||||
}
|
||||
|
||||
func (v *verifier) parseAuthParams() error {
|
||||
// Remove trailing and leading slashes
|
||||
trimmedPath := strings.Trim(v.requestInfo.Path, "/")
|
||||
// Remove `v1/`
|
||||
splitPath := strings.Split(strings.TrimPrefix(trimmedPath, "v1/"), "/")
|
||||
splitLen := len(splitPath)
|
||||
|
||||
// It must be at least length 1. If so, figure out new vs. legacy parsing
|
||||
if len(splitPath) == 0 {
|
||||
return fmt.Errorf("parse auth params: invalid path")
|
||||
}
|
||||
|
||||
for i := 1; i < splitLen; i++ {
|
||||
if splitPath[i] == "" {
|
||||
return fmt.Errorf("parse auth params: empty segment found")
|
||||
}
|
||||
}
|
||||
|
||||
// The first segment must be "scopes"
|
||||
if splitPath[0] != "scopes" {
|
||||
return fmt.Errorf("parse auth params: invalid first segment %q", splitPath[0])
|
||||
}
|
||||
|
||||
v.act = action.Unknown
|
||||
v.res = &perms.Resource{
|
||||
// Start out with scope, and replace when we walk backwards if it's
|
||||
// actually something else
|
||||
Type: resource.Scope,
|
||||
}
|
||||
|
||||
// Handle non-custom types. We'll deal with custom types, including list,
|
||||
// after parsing the path.
|
||||
switch v.requestInfo.Method {
|
||||
case "GET":
|
||||
v.act = action.Read
|
||||
case "POST":
|
||||
v.act = action.Create
|
||||
case "PATCH":
|
||||
v.act = action.Update
|
||||
case "DELETE":
|
||||
v.act = action.Delete
|
||||
default:
|
||||
return fmt.Errorf("parse auth params: unknown method %q", v.requestInfo.Method)
|
||||
}
|
||||
|
||||
// Look for a custom action
|
||||
colonSplit := strings.Split(splitPath[splitLen-1], ":")
|
||||
switch len(colonSplit) {
|
||||
case 1:
|
||||
// No custom action specified
|
||||
|
||||
case 2:
|
||||
// Parse and validate the action, then elide it
|
||||
actStr := colonSplit[len(colonSplit)-1]
|
||||
v.act = action.Map[actStr]
|
||||
if v.act == action.Unknown || v.act == action.All {
|
||||
return fmt.Errorf("parse auth params: unknown action %q", actStr)
|
||||
}
|
||||
// Keep going with the logic without the custom action
|
||||
splitPath[splitLen-1] = colonSplit[0]
|
||||
|
||||
default:
|
||||
return fmt.Errorf("parse auth params: unexpected number of colons in last segment %q", colonSplit[len(colonSplit)-1])
|
||||
}
|
||||
|
||||
// Get scope information and handle it in a special case; that is, for
|
||||
// operating on scopes, scope from the request ID, not the path scope
|
||||
switch splitLen {
|
||||
case 1:
|
||||
// We've already validated that this is "scopes"
|
||||
if v.act == action.Read {
|
||||
v.act = action.List
|
||||
}
|
||||
if v.requestInfo.scopeId == "" {
|
||||
return errors.New("parse auth params: missing scope ID information for scopes collection operation")
|
||||
}
|
||||
v.res.ScopeId = v.requestInfo.scopeId
|
||||
return nil
|
||||
|
||||
case 2:
|
||||
id := splitPath[1]
|
||||
// The next segment should be the scope ID, but it takes place not in
|
||||
// its own scope but in the parent scope. Rather than require the user
|
||||
// to provide it, look up the parent.
|
||||
switch {
|
||||
case id == "global", strings.HasPrefix(id, scope.Org.Prefix()):
|
||||
// Org scope parent is always global. Set scope for global
|
||||
// operations to global as well (it's basically acting as its own
|
||||
// parent scope). We want this so that users can e.g. modify the
|
||||
// name or description of the global scope if they have permissions
|
||||
// in the scope.
|
||||
v.res.ScopeId = "global"
|
||||
|
||||
default:
|
||||
// Project case
|
||||
iamRepo, err := v.iamRepoFn()
|
||||
if err != nil {
|
||||
return fmt.Errorf("perform auth check: failed to get iam repo: %w", err)
|
||||
}
|
||||
|
||||
scp, err := iamRepo.LookupScope(v.ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("perform auth check: failed to lookup scope: %w", err)
|
||||
}
|
||||
if scp == nil {
|
||||
return fmt.Errorf("perform auth check: non-existent scope %q", id)
|
||||
}
|
||||
v.res.ScopeId = scp.GetParentId()
|
||||
}
|
||||
v.res.Id = id
|
||||
return nil
|
||||
|
||||
case 3:
|
||||
// If a custom action was being performed within a scope, it will have
|
||||
// been elided above. If the last path segment is now empty, address
|
||||
// this scenario. In this case the action took place _in_ the scope so
|
||||
// it should be bound accordingly. (This is for actions like
|
||||
// /scopes/o_abc/:deauthenticate where the action is _in_ the scope, not
|
||||
// on the scope.)
|
||||
if splitPath[2] == "" {
|
||||
v.res.ScopeId = splitPath[1]
|
||||
v.res.Id = splitPath[1]
|
||||
return nil
|
||||
}
|
||||
|
||||
fallthrough
|
||||
|
||||
default:
|
||||
// In all other cases the scope ID is the next segment
|
||||
v.res.ScopeId = splitPath[1]
|
||||
}
|
||||
|
||||
// Walk backwards. As we walk backwards we look for a pin and figure out if
|
||||
// we're operating on a resource or a collection. The rules for the pin are
|
||||
// as follows:
|
||||
//
|
||||
// * If the last segment is a collection, the pin is the immediately
|
||||
// preceding ID. This does not include scopes since those are permission
|
||||
// boundaries.
|
||||
//
|
||||
// * If the last segment is an ID, the pin is the immediately preceding ID
|
||||
// not including the last segment
|
||||
//
|
||||
// * If at the end of the logic the pin is the id of a scope then there is
|
||||
// no pin. The scopes are already enclosing so a pin is redundant.
|
||||
nextIdIsPin := true
|
||||
// Use an empty string so we can detect if we found anything in this loop.
|
||||
var foundId string
|
||||
var typStr string
|
||||
// We stop at [2] because we've already dealt with the first two segments
|
||||
// (scopes/<scope_id> above.
|
||||
for i := splitLen - 1; i >= 2; i-- {
|
||||
segment := splitPath[i]
|
||||
|
||||
if segment == "" {
|
||||
return fmt.Errorf("parse auth parameters: unexpected empty segment")
|
||||
}
|
||||
|
||||
// If the segment contains whitespace, it's not valid
|
||||
if fields := strings.Fields(segment); len(fields) != 1 || fields[0] != segment {
|
||||
return fmt.Errorf("parse auth params: segment %q contains whitespace", segment)
|
||||
}
|
||||
|
||||
// Collections don't contain underscores; every resource ID does.
|
||||
segmentIsCollection := !strings.Contains(segment, "_")
|
||||
|
||||
// If we see an ID, ensure that it's not the right-most ID; if not, it's
|
||||
// the pin
|
||||
if !segmentIsCollection && i != splitLen-1 && nextIdIsPin {
|
||||
v.res.Pin = segment
|
||||
// By definition this is the last thing we'd be looking for as
|
||||
// scopes were found above, so we can now break out
|
||||
break
|
||||
}
|
||||
|
||||
if typStr == "" {
|
||||
// The resource check takes place inside the type check because if
|
||||
// we've identified the type we have either already identified the
|
||||
// right-most resource ID or we're operating on a collection, so
|
||||
// this prevents us from finding a different ID earlier in the path.
|
||||
// We still work backwards to identify a pin.
|
||||
if foundId == "" && !segmentIsCollection {
|
||||
foundId = segment
|
||||
} else {
|
||||
// Every collection is the plural of the resource type so drop
|
||||
// the last 's'
|
||||
if !strings.HasSuffix(segment, "s") {
|
||||
return fmt.Errorf("parse auth params: invalid collection syntax for %q", segment)
|
||||
}
|
||||
typStr = strings.TrimSuffix(segment, "s")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if foundId != "" {
|
||||
v.res.Id = foundId
|
||||
}
|
||||
|
||||
if typStr != "" {
|
||||
v.res.Type = resource.Map[typStr]
|
||||
if v.res.Type == resource.Unknown {
|
||||
return fmt.Errorf("parse auth params: unknown resource type %q", typStr)
|
||||
}
|
||||
} else {
|
||||
// If we found no other type information, we walked backwards all the
|
||||
// way to the scope boundary, so the type is scope
|
||||
v.res.Type = resource.Scope
|
||||
}
|
||||
|
||||
// If we're operating on a collection (that is, the ID is blank) and it's a
|
||||
// GET, it's actually a list
|
||||
if v.res.Id == "" && v.act == action.Read {
|
||||
v.act = action.List
|
||||
}
|
||||
|
||||
// If the pin ended up being a scope, nil it out
|
||||
if v.res.Pin != "" && v.res.Pin == v.res.ScopeId {
|
||||
v.res.Pin = ""
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v verifier) performAuthCheck() (aclResults *perms.ACLResults, userId string, scopeInfo *scopes.ScopeInfo, retErr error) {
|
||||
// Ensure we return an error by default if we forget to set this somewhere
|
||||
retErr = errors.New("unknown")
|
||||
|
||||
@@ -13,263 +13,11 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestHandler_AuthDecoration(t *testing.T) {
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
wrapper := db.TestWrapper(t)
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
org, proj := iam.TestScopes(t, iamRepo)
|
||||
cases := []struct {
|
||||
name string
|
||||
path string
|
||||
method string
|
||||
action action.Type
|
||||
scope string
|
||||
resource resource.Type
|
||||
id string
|
||||
pin string
|
||||
wantErrContains string
|
||||
}{
|
||||
{
|
||||
name: "global scope, read, with id",
|
||||
path: "/v1/scopes/global/users/u_anon",
|
||||
method: "GET",
|
||||
action: action.Read,
|
||||
scope: "global",
|
||||
resource: resource.User,
|
||||
id: "u_anon",
|
||||
},
|
||||
{
|
||||
name: "global scope, update, with id",
|
||||
path: "/v1/scopes/global/auth-methods/am_1234",
|
||||
method: "PATCH",
|
||||
action: action.Update,
|
||||
scope: "global",
|
||||
resource: resource.AuthMethod,
|
||||
id: "am_1234",
|
||||
},
|
||||
{
|
||||
name: "global scope, delete org",
|
||||
path: "/v1/scopes/o_1234",
|
||||
method: "DELETE",
|
||||
action: action.Delete,
|
||||
scope: "global",
|
||||
resource: resource.Scope,
|
||||
id: "o_1234",
|
||||
},
|
||||
{
|
||||
name: "org scope, delete project",
|
||||
path: fmt.Sprintf("/v1/scopes/%s", proj.GetPublicId()),
|
||||
method: "DELETE",
|
||||
action: action.Delete,
|
||||
scope: org.GetPublicId(),
|
||||
resource: resource.Scope,
|
||||
id: proj.GetPublicId(),
|
||||
},
|
||||
{
|
||||
name: "empty segments",
|
||||
path: "/v1/scopes/o_abc1234/auth-methods//am_1234",
|
||||
wantErrContains: "empty segment found",
|
||||
},
|
||||
{
|
||||
name: "global scope, create",
|
||||
path: "/v1/scopes/global/roles",
|
||||
method: "POST",
|
||||
action: action.Create,
|
||||
scope: "global",
|
||||
resource: resource.Role,
|
||||
},
|
||||
{
|
||||
name: "global, invalid collection syntax",
|
||||
path: "/v1/scope",
|
||||
wantErrContains: `parse auth params: invalid first segment "scope"`,
|
||||
},
|
||||
{
|
||||
name: "invalid scopes segment with id",
|
||||
path: "/v1/scope/o_abc",
|
||||
wantErrContains: `parse auth params: invalid first segment "scope"`,
|
||||
},
|
||||
{
|
||||
name: "org, custom action",
|
||||
path: "/v1/scopes/o_123/auth-methods/am_1234:authenticate",
|
||||
method: "POST",
|
||||
action: action.Authenticate,
|
||||
scope: "o_123",
|
||||
resource: resource.AuthMethod,
|
||||
id: "am_1234",
|
||||
},
|
||||
{
|
||||
name: "unknown action in first segment",
|
||||
path: "/v1/:authentifake",
|
||||
wantErrContains: `parse auth params: invalid first segment ":authentifake"`,
|
||||
},
|
||||
{
|
||||
name: "root, unknown action",
|
||||
path: "/v1/scopes/o_abc/:authentifake",
|
||||
wantErrContains: `parse auth params: unknown action "authentifake"`,
|
||||
},
|
||||
{
|
||||
name: "root, unknown empty action",
|
||||
path: "/v1/:",
|
||||
wantErrContains: `parse auth params: invalid first segment ":"`,
|
||||
},
|
||||
{
|
||||
name: "root, invalid method",
|
||||
path: "/v1/scopes/o_abc/:authenticate",
|
||||
method: "FOOBAR",
|
||||
wantErrContains: `unknown method "FOOBAR"`,
|
||||
},
|
||||
{
|
||||
name: "root, wrong number of colons",
|
||||
path: "/v1/scopes/o_abc/:auth:enticate",
|
||||
wantErrContains: "unexpected number of colons",
|
||||
},
|
||||
{
|
||||
name: "root, action on global",
|
||||
path: "/v1/scopes/global",
|
||||
method: "GET",
|
||||
action: action.Read,
|
||||
scope: "global",
|
||||
resource: resource.Scope,
|
||||
id: "global",
|
||||
},
|
||||
{
|
||||
name: "org scope, valid",
|
||||
path: "/v1/scopes/o_abc123/auth-methods",
|
||||
method: "POST",
|
||||
action: action.Create,
|
||||
scope: "o_abc123",
|
||||
resource: resource.AuthMethod,
|
||||
},
|
||||
{
|
||||
name: "project scope, valid",
|
||||
path: "/v1/scopes/p_1234/host-catalogs",
|
||||
method: "POST",
|
||||
action: action.Create,
|
||||
scope: "p_1234",
|
||||
resource: resource.HostCatalog,
|
||||
},
|
||||
{
|
||||
name: "project scope, action on project",
|
||||
path: "/v1/scopes/p_1234/:deauthenticate",
|
||||
method: "POST",
|
||||
action: action.Deauthenticate,
|
||||
scope: "p_1234",
|
||||
resource: resource.Scope,
|
||||
id: "p_1234",
|
||||
},
|
||||
{
|
||||
name: "global scope, action on org, token scope",
|
||||
path: "/v1/scopes/o_1234:set-principals",
|
||||
method: "POST",
|
||||
action: action.SetPrincipals,
|
||||
scope: "global",
|
||||
resource: resource.Scope,
|
||||
id: "o_1234",
|
||||
},
|
||||
{
|
||||
name: "global action, valid",
|
||||
path: "/v1/scopes/global/:read",
|
||||
action: action.Read,
|
||||
scope: "global",
|
||||
resource: resource.Scope,
|
||||
id: "global",
|
||||
},
|
||||
{
|
||||
name: "top level, invalid",
|
||||
path: "/v1/",
|
||||
wantErrContains: `invalid first segment "v1"`,
|
||||
},
|
||||
{
|
||||
name: "non-api path",
|
||||
path: "/",
|
||||
wantErrContains: `parse auth params: invalid first segment ""`,
|
||||
},
|
||||
{
|
||||
name: "project scope, pinning collection",
|
||||
path: "/v1/scopes/p_1234/host-catalogs/hc_1234/host-sets",
|
||||
action: action.List,
|
||||
scope: "p_1234",
|
||||
pin: "hc_1234",
|
||||
resource: resource.HostSet,
|
||||
},
|
||||
{
|
||||
name: "project scope, pinning collection, custom action",
|
||||
path: "/v1/scopes/p_1234/host-catalogs/hc_1234/host-sets:create",
|
||||
action: action.Create,
|
||||
scope: "p_1234",
|
||||
pin: "hc_1234",
|
||||
resource: resource.HostSet,
|
||||
},
|
||||
{
|
||||
name: "project scope, pinning id",
|
||||
path: "/v1/scopes/p_1234/host-catalogs/hc_1234/host-sets/hs_abc",
|
||||
action: action.Read,
|
||||
id: "hs_abc",
|
||||
scope: "p_1234",
|
||||
pin: "hc_1234",
|
||||
resource: resource.HostSet,
|
||||
},
|
||||
{
|
||||
name: "project scope, pinning id, custom action",
|
||||
path: "/v1/scopes/p_1234/host-catalogs/hc_1234/host-sets/hs_abc:update",
|
||||
action: action.Update,
|
||||
id: "hs_abc",
|
||||
scope: "p_1234",
|
||||
pin: "hc_1234",
|
||||
resource: resource.HostSet,
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
require, assert := require.New(t), assert.New(t)
|
||||
if tc.method == "" {
|
||||
tc.method = "GET"
|
||||
}
|
||||
req, err := http.NewRequest(tc.method, fmt.Sprintf("http://127.0.0.1:9200:%s", tc.path), nil)
|
||||
require.NoError(err)
|
||||
|
||||
v := &verifier{
|
||||
requestInfo: RequestInfo{
|
||||
Path: req.URL.Path,
|
||||
Method: tc.method,
|
||||
},
|
||||
iamRepoFn: iamRepoFn,
|
||||
}
|
||||
|
||||
err = v.parseAuthParams()
|
||||
if tc.wantErrContains != "" {
|
||||
require.Error(err)
|
||||
assert.Contains(err.Error(), tc.wantErrContains, err.Error())
|
||||
return
|
||||
}
|
||||
require.NoError(err, pretty.Sprint(v))
|
||||
|
||||
if tc.path == "/" {
|
||||
return
|
||||
}
|
||||
|
||||
require.NotNil(v.res)
|
||||
require.NotEqual(action.Unknown, v.act)
|
||||
assert.Equal(tc.scope, v.res.ScopeId, "scope "+pretty.Sprint(v))
|
||||
assert.Equal(tc.action, v.act, "action "+pretty.Sprint(v))
|
||||
assert.Equal(tc.resource, v.res.Type, "type "+pretty.Sprint(v))
|
||||
assert.Equal(tc.id, v.res.Id, "id "+pretty.Sprint(v))
|
||||
assert.Equal(tc.pin, v.res.Pin, "pin "+pretty.Sprint(v))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthTokenAuthenticator(t *testing.T) {
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
rw := db.New(conn)
|
||||
|
||||
@@ -288,7 +288,7 @@ func TestRepository_ChangePassword(t *testing.T) {
|
||||
wantIsErr: db.ErrInvalidParameter,
|
||||
},
|
||||
{
|
||||
name: "invalid-no-old-password",
|
||||
name: "invalid-no-current-password",
|
||||
args: args{
|
||||
acctId: acct.PublicId,
|
||||
old: "",
|
||||
@@ -325,7 +325,7 @@ func TestRepository_ChangePassword(t *testing.T) {
|
||||
wantIsErr: db.ErrRecordNotFound,
|
||||
},
|
||||
{
|
||||
name: "auth-failure-wrong-old-password",
|
||||
name: "auth-failure-wrong-current-password",
|
||||
args: args{
|
||||
acctId: acct.PublicId,
|
||||
old: "wrong-password",
|
||||
@@ -455,13 +455,13 @@ func TestRepository_SetPassword(t *testing.T) {
|
||||
createAcct func(string) *Account
|
||||
}{
|
||||
{
|
||||
name: "valid-new-password-no-old-password",
|
||||
name: "valid-new-password-no-current-password",
|
||||
createAcct: createAccount("validnewpwnoold"),
|
||||
oldPw: "",
|
||||
newPw: "abcdefghijk",
|
||||
},
|
||||
{
|
||||
name: "valid-new-password-delete-old-password",
|
||||
name: "valid-new-password-delete-current-password",
|
||||
createAcct: createAccount("validnewpwyesold"),
|
||||
oldPw: origPasswd,
|
||||
newPw: "abcdefghijk",
|
||||
|
||||
@@ -53,7 +53,6 @@ type Command struct {
|
||||
flagsOnce sync.Once
|
||||
|
||||
flagAddr string
|
||||
flagScope string
|
||||
flagVerbose bool
|
||||
|
||||
flagTLSCACert string
|
||||
@@ -69,6 +68,7 @@ type Command struct {
|
||||
FlagRecoveryConfig string
|
||||
flagOutputCurlString bool
|
||||
|
||||
FlagScopeId string
|
||||
FlagId string
|
||||
FlagName string
|
||||
FlagDescription string
|
||||
@@ -233,39 +233,12 @@ func (c *Command) Client(opt ...Option) (*api.Client, error) {
|
||||
c.UI.Error(fmt.Sprintf("Error unmarshaling stored token information after reading from system credential store: %s", err))
|
||||
} else {
|
||||
c.client.SetToken(authToken.Token)
|
||||
if !opts.withNoTokenScope {
|
||||
c.client.SetScopeId(authToken.Scope.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We do this here so we override the stored token info if it's set above
|
||||
if c.flagScope != NotSetValue {
|
||||
c.client.SetScopeId(c.flagScope)
|
||||
if c.flagFormat == "table" && c.flagVerbose {
|
||||
if c.flagScope == os.Getenv("BOUNDARY_TOKEN") {
|
||||
c.UI.Info(fmt.Sprintf("Scope of %q set from BOUNDARY_TOKEN env var", c.flagScope))
|
||||
} else {
|
||||
c.UI.Info(fmt.Sprintf("Scope of %q set from -scope command flag", c.flagScope))
|
||||
}
|
||||
}
|
||||
} else if c.client.ScopeId() != "" && !opts.withNoTokenScope {
|
||||
// If it didn't come from env or a flag but isn't empty, it must have come from the token
|
||||
if c.flagFormat == "table" && c.flagVerbose {
|
||||
c.UI.Info(fmt.Sprintf("Scope of %q set from saved token with name %q", c.client.ScopeId(), tokenName))
|
||||
}
|
||||
}
|
||||
// At this point if we haven't figured out the scope, default to "global"
|
||||
if c.client.ScopeId() == "" {
|
||||
c.client.SetScopeId("global")
|
||||
if c.flagFormat == "table" && c.flagVerbose {
|
||||
c.UI.Info(`Scope of "global" set by default`)
|
||||
}
|
||||
}
|
||||
|
||||
if opts.withNoTokenValue {
|
||||
c.client.SetToken("")
|
||||
}
|
||||
@@ -300,15 +273,6 @@ func (c *Command) FlagSet(bit FlagSetBit) *FlagSets {
|
||||
Usage: "Addr of the Boundary controller, as a complete URL (e.g. https://boundary.example.com:9200).",
|
||||
})
|
||||
|
||||
f.StringVar(&StringVar{
|
||||
Name: FlagNameScope,
|
||||
Target: &c.flagScope,
|
||||
Default: NotSetValue,
|
||||
EnvVar: api.EnvBoundaryScopeId,
|
||||
Completion: complete.PredictAnything,
|
||||
Usage: `Scope in which to make the request. If not specified, will default to the scope of a saved token (if found), otherwise will default to "global".`,
|
||||
})
|
||||
|
||||
f.StringVar(&StringVar{
|
||||
Name: FlagNameCACert,
|
||||
Target: &c.flagTLSCACert,
|
||||
|
||||
@@ -4,9 +4,6 @@ const (
|
||||
// FlagNameAddr is the flag used in the base command to read in the
|
||||
// address of the Boundary server.
|
||||
FlagNameAddr = "addr"
|
||||
// FlagNameScope is the flag used in the base command to read in the scope
|
||||
// in which to make a request.
|
||||
FlagNameScope = "scope"
|
||||
// FlagnameCACert is the flag used in the base command to read in the CA
|
||||
// cert.
|
||||
FlagNameCACert = "ca-cert"
|
||||
|
||||
@@ -51,7 +51,7 @@ func WrapSlice(prefixSpaces int, input []string) string {
|
||||
for _, v := range input {
|
||||
ret = append(ret, fmt.Sprintf("%s%s",
|
||||
strings.Repeat(" ", prefixSpaces),
|
||||
fmt.Sprintf("%s: ", v),
|
||||
v,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
+172
-2
@@ -6,6 +6,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/accounts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/authenticate"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/authmethods"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/authtokens"
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/proxy"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/roles"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/scopes"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/targets"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/users"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/worker"
|
||||
|
||||
@@ -77,6 +79,66 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}, nil
|
||||
},
|
||||
|
||||
"accounts": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
},
|
||||
"accounts read": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "read",
|
||||
}, nil
|
||||
},
|
||||
"accounts delete": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "delete",
|
||||
}, nil
|
||||
},
|
||||
"accounts list": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "list",
|
||||
}, nil
|
||||
},
|
||||
"accounts set-password": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "set-password",
|
||||
}, nil
|
||||
},
|
||||
"accounts change-password": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "change-password",
|
||||
}, nil
|
||||
},
|
||||
"accounts create": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "create",
|
||||
}, nil
|
||||
},
|
||||
"accounts create password": func() (cli.Command, error) {
|
||||
return &accounts.PasswordCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "create",
|
||||
}, nil
|
||||
},
|
||||
"accounts update": func() (cli.Command, error) {
|
||||
return &accounts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "update",
|
||||
}, nil
|
||||
},
|
||||
"accounts update password": func() (cli.Command, error) {
|
||||
return &accounts.PasswordCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "update",
|
||||
}, nil
|
||||
},
|
||||
|
||||
"auth-methods": func() (cli.Command, error) {
|
||||
return &authmethods.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
@@ -335,11 +397,53 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}, nil
|
||||
},
|
||||
|
||||
"hosts create": func() (cli.Command, error) {
|
||||
return &hosts.CreateCommand{
|
||||
"hosts": func() (cli.Command, error) {
|
||||
return &hosts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
},
|
||||
"hosts read": func() (cli.Command, error) {
|
||||
return &hosts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "read",
|
||||
}, nil
|
||||
},
|
||||
"hosts delete": func() (cli.Command, error) {
|
||||
return &hosts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "delete",
|
||||
}, nil
|
||||
},
|
||||
"hosts list": func() (cli.Command, error) {
|
||||
return &hosts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "list",
|
||||
}, nil
|
||||
},
|
||||
"hosts create": func() (cli.Command, error) {
|
||||
return &hosts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "create",
|
||||
}, nil
|
||||
},
|
||||
"hosts create static": func() (cli.Command, error) {
|
||||
return &hosts.StaticCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "create",
|
||||
}, nil
|
||||
},
|
||||
"hosts update": func() (cli.Command, error) {
|
||||
return &hosts.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "update",
|
||||
}, nil
|
||||
},
|
||||
"hosts update static": func() (cli.Command, error) {
|
||||
return &hosts.StaticCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "update",
|
||||
}, nil
|
||||
},
|
||||
|
||||
"roles": func() (cli.Command, error) {
|
||||
return &roles.Command{
|
||||
@@ -449,6 +553,72 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}, nil
|
||||
},
|
||||
|
||||
"targets": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
},
|
||||
"targets read": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "read",
|
||||
}, nil
|
||||
},
|
||||
"targets delete": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "delete",
|
||||
}, nil
|
||||
},
|
||||
"targets list": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "list",
|
||||
}, nil
|
||||
},
|
||||
"targets create": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "create",
|
||||
}, nil
|
||||
},
|
||||
"targets create tcp": func() (cli.Command, error) {
|
||||
return &targets.TcpCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "create",
|
||||
}, nil
|
||||
},
|
||||
"targets update": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "update",
|
||||
}, nil
|
||||
},
|
||||
"targets update tcp": func() (cli.Command, error) {
|
||||
return &targets.TcpCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "update",
|
||||
}, nil
|
||||
},
|
||||
"targets add-host-sets": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "add-host-sets",
|
||||
}, nil
|
||||
},
|
||||
"targets remove-host-sets": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "remove-host-sets",
|
||||
}, nil
|
||||
},
|
||||
"targets set-host-sets": func() (cli.Command, error) {
|
||||
return &targets.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
Func: "set-host-sets",
|
||||
}, nil
|
||||
},
|
||||
|
||||
"users": func() (cli.Command, error) {
|
||||
return &users.Command{
|
||||
Command: base.NewCommand(ui),
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/accounts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/common"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/vault/sdk/helper/password"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*Command)(nil)
|
||||
var _ cli.CommandAutocomplete = (*Command)(nil)
|
||||
|
||||
type Command struct {
|
||||
*base.Command
|
||||
|
||||
Func string
|
||||
|
||||
flagAuthMethodId string
|
||||
flagPassword string
|
||||
flagCurrentPassword string
|
||||
flagNewPassword string
|
||||
}
|
||||
|
||||
func (c *Command) Synopsis() string {
|
||||
switch c.Func {
|
||||
case "create":
|
||||
return "Create account resources within Boundary"
|
||||
case "update":
|
||||
return "Update account resources within Boundary"
|
||||
default:
|
||||
return common.SynopsisFunc(c.Func, "account")
|
||||
}
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"auth-method-id"},
|
||||
"set-password": {"id", "password", "version"},
|
||||
"change-password": {"id", "current-password", "new-password", "version"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("account")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows operations on Boundary account resources. Example:",
|
||||
"",
|
||||
" Read a account:",
|
||||
"",
|
||||
` $ boundary accounts read -id apw_1234567890`,
|
||||
"",
|
||||
" Please see the accounts subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary account resources. Example:",
|
||||
"",
|
||||
" Create a password-type account:",
|
||||
"",
|
||||
` $ boundary accounts create password -name prodops -description "For ProdOps usage"`,
|
||||
"",
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary account resources. Example:",
|
||||
"",
|
||||
" Update a password-type account:",
|
||||
"",
|
||||
` $ boundary accounts update password -id apw_1234567890 -name devops -description "For DevOps usage"`,
|
||||
"",
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "set-password":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts set-password [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows setting the password on account-type resources, if the types match and the operation is allowed by the given account type. Example:",
|
||||
"",
|
||||
" Set the password on a password-type account:",
|
||||
"",
|
||||
` $ boundary accounts set-password -id apw_1234567890 -password <empty, to be read by stdin>`,
|
||||
})
|
||||
case "change-password":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts change-password [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows changing the password (with verification of the current password) on account-type resources, if the types match and the operation is allowed by the given account type. Example:",
|
||||
"",
|
||||
" Change the password on a password-type account:",
|
||||
"",
|
||||
` $ boundary accounts change-password -id apw_1234567890 -current-password <empty, to be read by stdin> -new-password <empty, to be read by stdin>`,
|
||||
})
|
||||
default:
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
f := set.NewFlagSet("Command Options")
|
||||
|
||||
if len(flagsMap[c.Func]) > 0 {
|
||||
common.PopulateCommonFlags(c.Command, f, resource.Account.String(), flagsMap[c.Func])
|
||||
}
|
||||
|
||||
for _, name := range flagsMap[c.Func] {
|
||||
switch name {
|
||||
case "auth-method-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "auth-method-id",
|
||||
Target: &c.flagAuthMethodId,
|
||||
Usage: "The auth-method resource in which to create or update the account resource",
|
||||
})
|
||||
case "password":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "password",
|
||||
Target: &c.flagPassword,
|
||||
Usage: "The password for the account. If not specified, the command will prompt for the password to be entered in a non-echoing way.",
|
||||
})
|
||||
case "current-password":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "current-password",
|
||||
Target: &c.flagCurrentPassword,
|
||||
Usage: "The current password for the account. If not specified, the command will prompt for the password to be entered in a non-echoing way.",
|
||||
})
|
||||
case "new-password":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "new-password",
|
||||
Target: &c.flagNewPassword,
|
||||
Usage: "The new password for the account. If not specified, the command will prompt for the password to be entered in a non-echoing way.",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *Command) Run(args []string) int {
|
||||
switch c.Func {
|
||||
case "", "create", "update":
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "auth-method-id") && c.flagAuthMethodId == "" {
|
||||
c.UI.Error("Auth Method ID must be passed in via -auth-method-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
var opts []accounts.Option
|
||||
|
||||
switch c.FlagName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, accounts.DefaultName())
|
||||
default:
|
||||
opts = append(opts, accounts.WithName(c.FlagName))
|
||||
}
|
||||
|
||||
switch c.FlagDescription {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, accounts.DefaultDescription())
|
||||
default:
|
||||
opts = append(opts, accounts.WithDescription(c.FlagDescription))
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "password") && c.flagPassword == "" {
|
||||
fmt.Print("Password is not set as flag, please enter it now (will be hidden): ")
|
||||
value, err := password.Read(os.Stdin)
|
||||
fmt.Print("\n")
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("An error occurred attempting to read the password. The raw error message is shown below but usually this is because you attempted to pipe a value into the command or you are executing outside of a terminal (TTY). The raw error was:\n\n%s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
c.flagPassword = strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "current-password") && c.flagCurrentPassword == "" {
|
||||
fmt.Print("Current password is not set as flag, please enter it now (will be hidden): ")
|
||||
value, err := password.Read(os.Stdin)
|
||||
fmt.Print("\n")
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("An error occurred attempting to read the password. The raw error message is shown below but usually this is because you attempted to pipe a value into the command or you are executing outside of a terminal (TTY). The raw error was:\n\n%s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
c.flagCurrentPassword = strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "new-password") && c.flagNewPassword == "" {
|
||||
fmt.Print("New password is not set as flag, please enter it now (will be hidden): ")
|
||||
value, err := password.Read(os.Stdin)
|
||||
fmt.Print("\n")
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("An error occurred attempting to read the password. The raw error message is shown below but usually this is because you attempted to pipe a value into the command or you are executing outside of a terminal (TTY). The raw error was:\n\n%s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
c.flagNewPassword = strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
// Perform check-and-set when needed
|
||||
var version uint32
|
||||
switch c.Func {
|
||||
case "create":
|
||||
// These don't update so don't need the existing version
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, accounts.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
}
|
||||
|
||||
accountClient := accounts.NewClient(client)
|
||||
|
||||
var existed bool
|
||||
var account *accounts.Account
|
||||
var listedAccounts []*accounts.Account
|
||||
var apiErr *api.Error
|
||||
|
||||
switch c.Func {
|
||||
case "read":
|
||||
account, apiErr, err = accountClient.Read(c.Context, c.FlagId, opts...)
|
||||
case "delete":
|
||||
existed, apiErr, err = accountClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedAccounts, apiErr, err = accountClient.List(c.Context, c.flagAuthMethodId, opts...)
|
||||
case "set-password":
|
||||
account, apiErr, err = accountClient.SetPassword(c.Context, c.FlagId, c.flagPassword, version, opts...)
|
||||
case "change-password":
|
||||
account, apiErr, err = accountClient.ChangePassword(c.Context, c.FlagId, c.flagCurrentPassword, c.flagNewPassword, version, opts...)
|
||||
}
|
||||
|
||||
plural := "account"
|
||||
if c.Func == "list" {
|
||||
plural = "accounts"
|
||||
}
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr)))
|
||||
return 1
|
||||
}
|
||||
|
||||
switch c.Func {
|
||||
case "delete":
|
||||
switch base.Format(c.UI) {
|
||||
case "json":
|
||||
c.UI.Output("null")
|
||||
case "table":
|
||||
output := "The delete operation completed successfully"
|
||||
switch existed {
|
||||
case true:
|
||||
output += "."
|
||||
default:
|
||||
output += ", however the resource did not exist at the time."
|
||||
}
|
||||
c.UI.Output(output)
|
||||
}
|
||||
return 0
|
||||
|
||||
case "list":
|
||||
switch base.Format(c.UI) {
|
||||
case "json":
|
||||
if len(listedAccounts) == 0 {
|
||||
c.UI.Output("null")
|
||||
return 0
|
||||
}
|
||||
b, err := base.JsonFormatter{}.Format(listedAccounts)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
|
||||
case "table":
|
||||
if len(listedAccounts) == 0 {
|
||||
c.UI.Output("No accounts found")
|
||||
return 0
|
||||
}
|
||||
var output []string
|
||||
output = []string{
|
||||
"",
|
||||
"Account information:",
|
||||
}
|
||||
for i, m := range listedAccounts {
|
||||
if i > 0 {
|
||||
output = append(output, "")
|
||||
}
|
||||
if true {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" ID: %s", m.Id),
|
||||
fmt.Sprintf(" Version: %d", m.Version),
|
||||
fmt.Sprintf(" Type: %s", m.Type),
|
||||
)
|
||||
}
|
||||
if m.Name != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Name: %s", m.Name),
|
||||
)
|
||||
}
|
||||
if m.Description != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Description: %s", m.Description),
|
||||
)
|
||||
}
|
||||
}
|
||||
c.UI.Output(base.WrapForHelpText(output))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(generateAccountTableOutput(account))
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(account)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/api/accounts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
)
|
||||
|
||||
func generateAccountTableOutput(in *accounts.Account) string {
|
||||
var ret []string
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
"Auth Method ID": in.AuthMethodId,
|
||||
}
|
||||
|
||||
if in.Name != "" {
|
||||
nonAttributeMap["Name"] = in.Name
|
||||
}
|
||||
if in.Description != "" {
|
||||
nonAttributeMap["Description"] = in.Description
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
for k := range nonAttributeMap {
|
||||
if len(k) > maxLength {
|
||||
maxLength = len(k)
|
||||
}
|
||||
}
|
||||
if len(in.Attributes) > 0 {
|
||||
for k, v := range in.Attributes {
|
||||
if attributeMap[k] != "" {
|
||||
in.Attributes[attributeMap[k]] = v
|
||||
delete(in.Attributes, k)
|
||||
}
|
||||
}
|
||||
for k := range in.Attributes {
|
||||
if len(k) > maxLength {
|
||||
maxLength = len(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = append(ret, "", "Account information:")
|
||||
|
||||
ret = append(ret,
|
||||
// We do +2 because there is another +2 offset for attributes below
|
||||
base.WrapMap(2, maxLength+2, nonAttributeMap),
|
||||
)
|
||||
|
||||
if len(in.Attributes) > 0 {
|
||||
if true {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
)
|
||||
}
|
||||
ret = append(ret,
|
||||
base.WrapMap(4, maxLength, in.Attributes),
|
||||
)
|
||||
}
|
||||
|
||||
return base.WrapForHelpText(ret)
|
||||
}
|
||||
|
||||
var attributeMap = map[string]string{
|
||||
"login_name": "Login Name",
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/textproto"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/accounts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/common"
|
||||
"github.com/hashicorp/vault/sdk/helper/password"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*PasswordCommand)(nil)
|
||||
var _ cli.CommandAutocomplete = (*PasswordCommand)(nil)
|
||||
|
||||
type PasswordCommand struct {
|
||||
*base.Command
|
||||
|
||||
Func string
|
||||
|
||||
flagAuthMethodId string
|
||||
flagLoginName string
|
||||
flagPassword string
|
||||
}
|
||||
|
||||
func (c *PasswordCommand) Synopsis() string {
|
||||
return fmt.Sprintf("%s a password-type account within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
|
||||
}
|
||||
|
||||
var passwordFlagsMap = map[string][]string{
|
||||
"create": {"auth-method-id", "name", "description", "login-name", "password"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
}
|
||||
|
||||
func (c *PasswordCommand) Help() string {
|
||||
var info string
|
||||
switch c.Func {
|
||||
case "create":
|
||||
info = base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts password create [options] [args]",
|
||||
"",
|
||||
" Create a password-type account. Example:",
|
||||
"",
|
||||
` $ boundary accounts password create -name prodops -description "Password account for ProdOps" -address "127.0.0.1"`,
|
||||
"",
|
||||
"",
|
||||
})
|
||||
|
||||
case "update":
|
||||
info = base.WrapForHelpText([]string{
|
||||
"Usage: boundary accounts password update [options] [args]",
|
||||
"",
|
||||
" Update a password-type account given its ID. Example:",
|
||||
"",
|
||||
` $ boundary accounts password update -id hst_1234567890 -name "devops" -description "Password account for DevOps" -address "10.20.30.40"`,
|
||||
"",
|
||||
"",
|
||||
})
|
||||
}
|
||||
return info + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *PasswordCommand) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
f := set.NewFlagSet("Command Options")
|
||||
|
||||
if len(passwordFlagsMap[c.Func]) > 0 {
|
||||
common.PopulateCommonFlags(c.Command, f, "password-type account", passwordFlagsMap[c.Func])
|
||||
}
|
||||
|
||||
for _, name := range passwordFlagsMap[c.Func] {
|
||||
switch name {
|
||||
case "auth-method-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "auth-method-id",
|
||||
Target: &c.flagAuthMethodId,
|
||||
Usage: "The auth-method resource in which to create or update the account resource",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
f = set.NewFlagSet("Password Account Options")
|
||||
|
||||
for _, name := range passwordFlagsMap[c.Func] {
|
||||
switch name {
|
||||
case "login-name":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "login-name",
|
||||
Target: &c.flagLoginName,
|
||||
Usage: "The login name for the account",
|
||||
})
|
||||
case "password":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "password",
|
||||
Target: &c.flagPassword,
|
||||
Usage: "The password for the account. If not specified, the command will prompt for the password to be entered in a non-echoing way.",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *PasswordCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *PasswordCommand) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *PasswordCommand) Run(args []string) int {
|
||||
if c.Func == "" {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(passwordFlagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(passwordFlagsMap[c.Func], "auth-method-id") && c.flagAuthMethodId == "" {
|
||||
c.UI.Error("Auth Method ID must be passed in via -auth-method-id")
|
||||
return 1
|
||||
}
|
||||
if c.Func == "create" && c.flagLoginName == "" {
|
||||
c.UI.Error("Login Name must be passed in via -login-name")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
var opts []accounts.Option
|
||||
|
||||
switch c.FlagName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, accounts.DefaultName())
|
||||
default:
|
||||
opts = append(opts, accounts.WithName(c.FlagName))
|
||||
}
|
||||
|
||||
switch c.FlagDescription {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, accounts.DefaultDescription())
|
||||
default:
|
||||
opts = append(opts, accounts.WithDescription(c.FlagDescription))
|
||||
}
|
||||
|
||||
switch c.flagLoginName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, accounts.DefaultPasswordAccountLoginName())
|
||||
default:
|
||||
opts = append(opts, accounts.WithPasswordAccountLoginName(c.flagLoginName))
|
||||
}
|
||||
|
||||
if strutil.StrListContains(passwordFlagsMap[c.Func], "password") {
|
||||
switch c.flagPassword {
|
||||
case "":
|
||||
fmt.Print("Password is not set as flag, please enter it now (will be hidden): ")
|
||||
value, err := password.Read(os.Stdin)
|
||||
fmt.Print("\n")
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("An error occurred attempting to read the password. The raw error message is shown below but usually this is because you attempted to pipe a value into the command or you are executing outside of a terminal (TTY). The raw error was:\n\n%s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
opts = append(opts, accounts.WithPasswordAccountPassword(strings.TrimSpace(value)))
|
||||
default:
|
||||
opts = append(opts, accounts.WithPasswordAccountPassword(c.flagPassword))
|
||||
}
|
||||
}
|
||||
|
||||
accountClient := accounts.NewClient(client)
|
||||
|
||||
// Perform check-and-set when needed
|
||||
var version uint32
|
||||
switch c.Func {
|
||||
case "create":
|
||||
// These don't update so don't need the existing version
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, accounts.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
}
|
||||
|
||||
var account *accounts.Account
|
||||
var apiErr *api.Error
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
account, apiErr, err = accountClient.Create(c.Context, c.flagAuthMethodId, opts...)
|
||||
case "update":
|
||||
account, apiErr, err = accountClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
plural := "password-type account"
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr)))
|
||||
return 1
|
||||
}
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(generateAccountTableOutput(account))
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(account)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -56,14 +56,14 @@ func (c *PasswordCommand) Flags() *base.FlagSets {
|
||||
Name: "login-name",
|
||||
Target: &c.flagLoginName,
|
||||
EnvVar: envLoginName,
|
||||
Usage: "Login name",
|
||||
Usage: "The login name corresponding to an account within the given auth method",
|
||||
})
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "password",
|
||||
Target: &c.flagPassword,
|
||||
EnvVar: envPassword,
|
||||
Usage: "Password",
|
||||
Usage: "The password associated with the login name",
|
||||
})
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
@@ -121,7 +121,11 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
// note: Authenticate() calls SetToken() under the hood to set the
|
||||
// auth bearer on the client so we do not need to do anything with the
|
||||
// returned token after this call, so we ignore it
|
||||
result, apiErr, err := authmethods.NewClient(client).Authenticate(c.Context, c.flagAuthMethodId, c.flagLoginName, c.flagPassword)
|
||||
result, apiErr, err := authmethods.NewClient(client).Authenticate(c.Context, c.flagAuthMethodId,
|
||||
map[string]interface{}{
|
||||
"login_name": c.flagLoginName,
|
||||
"password": c.flagPassword,
|
||||
})
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to perform authentication: %s", err.Error()))
|
||||
return 2
|
||||
|
||||
@@ -37,10 +37,12 @@ func (c *Command) Synopsis() string {
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("auth-method")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
@@ -55,7 +57,7 @@ func (c *Command) Help() string {
|
||||
" Please see the auth-methods subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary auth-methods create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary auth-method resources. Example:",
|
||||
@@ -67,7 +69,7 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary auth-methods update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary auth-method resources. Example:",
|
||||
@@ -79,8 +81,9 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
default:
|
||||
return helpMap[c.Func]() + c.Flags().Help()
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
@@ -119,6 +122,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -157,7 +164,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = authmethodClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedMethods, apiErr, err = authmethodClient.List(c.Context, opts...)
|
||||
listedMethods, apiErr, err = authmethodClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
}
|
||||
|
||||
plural := "auth method"
|
||||
|
||||
@@ -26,6 +26,7 @@ func generateAuthMethodTableOutput(in *authmethods.AuthMethod) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
|
||||
@@ -32,7 +32,7 @@ func (c *PasswordCommand) Synopsis() string {
|
||||
}
|
||||
|
||||
var passwordFlagsMap = map[string][]string{
|
||||
"create": {"name", "description"},
|
||||
"create": {"scope-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(passwordFlagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -174,7 +178,7 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, authmethods.WithAutomaticVersioning())
|
||||
opts = append(opts, authmethods.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -185,7 +189,7 @@ func (c *PasswordCommand) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
method, apiErr, err = authmethodClient.Create(c.Context, "password", opts...)
|
||||
method, apiErr, err = authmethodClient.Create(c.Context, "password", c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
method, apiErr, err = authmethodClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ func (c *Command) Synopsis() string {
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
@@ -76,6 +77,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -96,7 +101,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = authtokenClient.Delete(c.Context, c.FlagId)
|
||||
case "list":
|
||||
listedTokens, apiErr, err = authtokenClient.List(c.Context)
|
||||
listedTokens, apiErr, err = authtokenClient.List(c.Context, c.FlagScopeId)
|
||||
}
|
||||
|
||||
plural := "auth token"
|
||||
|
||||
@@ -75,6 +75,7 @@ func generateGroupTableOutput(in *groups.Group) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
|
||||
@@ -43,10 +43,11 @@ var helpMap = func() map[string]func() string {
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"create": {"name", "description"},
|
||||
"create": {"scope-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
"add-members": {"id", "member", "version"},
|
||||
"set-members": {"id", "member", "version"},
|
||||
"remove-members": {"id", "member", "version"},
|
||||
@@ -95,6 +96,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -151,7 +156,7 @@ func (c *Command) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, groups.WithAutomaticVersioning())
|
||||
opts = append(opts, groups.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -164,7 +169,7 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
group, apiErr, err = groupClient.Create(c.Context, opts...)
|
||||
group, apiErr, err = groupClient.Create(c.Context, c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
group, apiErr, err = groupClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
case "read":
|
||||
@@ -172,7 +177,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = groupClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedGroups, apiErr, err = groupClient.List(c.Context, opts...)
|
||||
listedGroups, apiErr, err = groupClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
case "add-members":
|
||||
group, apiErr, err = groupClient.AddMembers(c.Context, c.FlagId, version, members, opts...)
|
||||
case "set-members":
|
||||
|
||||
@@ -13,6 +13,7 @@ func generateHostCatalogTableOutput(in *hostcatalogs.HostCatalog) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
@@ -54,12 +55,8 @@ func generateHostCatalogTableOutput(in *hostcatalogs.HostCatalog) string {
|
||||
)
|
||||
|
||||
if len(in.Attributes) > 0 {
|
||||
if true {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
)
|
||||
}
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
base.WrapMap(4, maxLength, in.Attributes),
|
||||
)
|
||||
}
|
||||
@@ -67,4 +64,6 @@ func generateHostCatalogTableOutput(in *hostcatalogs.HostCatalog) string {
|
||||
return base.WrapForHelpText(ret)
|
||||
}
|
||||
|
||||
var attributeMap = map[string]string{}
|
||||
var attributeMap = map[string]string{
|
||||
"address": "Address",
|
||||
}
|
||||
@@ -26,7 +26,7 @@ type Command struct {
|
||||
func (c *Command) Synopsis() string {
|
||||
switch c.Func {
|
||||
case "create":
|
||||
return "Create host-catalolg resources within Boundary"
|
||||
return "Create host-catalog resources within Boundary"
|
||||
case "update":
|
||||
return "Update host-catalog resources within Boundary"
|
||||
default:
|
||||
@@ -37,10 +37,12 @@ func (c *Command) Synopsis() string {
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("host-catalog")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
@@ -55,7 +57,7 @@ func (c *Command) Help() string {
|
||||
" Please see the host-catalogs subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-catalogs create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary host-catalog resources. Example:",
|
||||
@@ -67,7 +69,7 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-catalogs update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary host-catalog resources. Example:",
|
||||
@@ -79,8 +81,9 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
default:
|
||||
return helpMap[c.Func]() + c.Flags().Help()
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
@@ -119,6 +122,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -157,7 +164,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = hostcatalogClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedCatalogs, apiErr, err = hostcatalogClient.List(c.Context, opts...)
|
||||
listedCatalogs, apiErr, err = hostcatalogClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
}
|
||||
|
||||
plural := "host catalog"
|
||||
|
||||
@@ -28,7 +28,7 @@ func (c *StaticCommand) Synopsis() string {
|
||||
}
|
||||
|
||||
var staticFlagsMap = map[string][]string{
|
||||
"create": {"name", "description"},
|
||||
"create": {"scope-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
}
|
||||
|
||||
@@ -95,6 +95,10 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(staticFlagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -130,7 +134,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, hostcatalogs.WithAutomaticVersioning())
|
||||
opts = append(opts, hostcatalogs.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -141,7 +145,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
catalog, apiErr, err = hostcatalogClient.Create(c.Context, "static", opts...)
|
||||
catalog, apiErr, err = hostcatalogClient.Create(c.Context, "static", c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
catalog, apiErr, err = hostcatalogClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/api/hosts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
)
|
||||
|
||||
func generateHostTableOutput(in *hosts.Host) string {
|
||||
var ret []string
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
"Host Catalog ID": in.HostCatalogId,
|
||||
}
|
||||
|
||||
if in.Name != "" {
|
||||
nonAttributeMap["Name"] = in.Name
|
||||
}
|
||||
if in.Description != "" {
|
||||
nonAttributeMap["Description"] = in.Description
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
for k := range nonAttributeMap {
|
||||
if len(k) > maxLength {
|
||||
maxLength = len(k)
|
||||
}
|
||||
}
|
||||
if len(in.Attributes) > 0 {
|
||||
for k, v := range in.Attributes {
|
||||
if attributeMap[k] != "" {
|
||||
in.Attributes[attributeMap[k]] = v
|
||||
delete(in.Attributes, k)
|
||||
}
|
||||
}
|
||||
for k := range in.Attributes {
|
||||
if len(k) > maxLength {
|
||||
maxLength = len(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = append(ret, "", "Host information:")
|
||||
|
||||
ret = append(ret,
|
||||
// We do +2 because there is another +2 offset for attributes below
|
||||
base.WrapMap(2, maxLength+2, nonAttributeMap),
|
||||
)
|
||||
|
||||
if len(in.HostSetIds) > 0 {
|
||||
ret = append(ret,
|
||||
" Host Set IDs:",
|
||||
base.WrapSlice(4, in.HostSetIds),
|
||||
)
|
||||
}
|
||||
|
||||
if len(in.Attributes) > 0 {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
base.WrapMap(4, maxLength, in.Attributes),
|
||||
)
|
||||
}
|
||||
|
||||
return base.WrapForHelpText(ret)
|
||||
}
|
||||
|
||||
var attributeMap = map[string]string{}
|
||||
@@ -0,0 +1,278 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/hosts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/common"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*Command)(nil)
|
||||
var _ cli.CommandAutocomplete = (*Command)(nil)
|
||||
|
||||
type Command struct {
|
||||
*base.Command
|
||||
|
||||
Func string
|
||||
|
||||
flagHostCatalogId string
|
||||
}
|
||||
|
||||
func (c *Command) Synopsis() string {
|
||||
switch c.Func {
|
||||
case "create":
|
||||
return "Create host resources within Boundary"
|
||||
case "update":
|
||||
return "Update host resources within Boundary"
|
||||
default:
|
||||
return common.SynopsisFunc(c.Func, "host")
|
||||
}
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"host-catalog-id"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("host")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
"Usage: boundary hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows operations on Boundary host resources. Example:",
|
||||
"",
|
||||
" Read a host:",
|
||||
"",
|
||||
` $ boundary hosts read -id hst_1234567890`,
|
||||
"",
|
||||
" Please see the hosts subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary hosts create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary host resources. Example:",
|
||||
"",
|
||||
" Create a static-type host:",
|
||||
"",
|
||||
` $ boundary hosts create static -name prodops -description "For ProdOps usage"`,
|
||||
"",
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary hosts update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary host resources. Example:",
|
||||
"",
|
||||
" Update a static-type host:",
|
||||
"",
|
||||
` $ boundary hosts update static -id hst_1234567890 -name devops -description "For DevOps usage"`,
|
||||
"",
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
default:
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
f := set.NewFlagSet("Command Options")
|
||||
|
||||
if len(flagsMap[c.Func]) > 0 {
|
||||
common.PopulateCommonFlags(c.Command, f, resource.Host.String(), flagsMap[c.Func])
|
||||
}
|
||||
|
||||
for _, name := range flagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-catalog-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host resource",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *Command) Run(args []string) int {
|
||||
switch c.Func {
|
||||
case "", "create", "update":
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "host-catalog-id") && c.flagHostCatalogId == "" {
|
||||
c.UI.Error("Host Catalog ID must be passed in via -host-catalog-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
var opts []hosts.Option
|
||||
|
||||
switch c.FlagName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, hosts.DefaultName())
|
||||
default:
|
||||
opts = append(opts, hosts.WithName(c.FlagName))
|
||||
}
|
||||
|
||||
switch c.FlagDescription {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, hosts.DefaultDescription())
|
||||
default:
|
||||
opts = append(opts, hosts.WithDescription(c.FlagDescription))
|
||||
}
|
||||
|
||||
hostClient := hosts.NewClient(client)
|
||||
|
||||
var existed bool
|
||||
var host *hosts.Host
|
||||
var listedHosts []*hosts.Host
|
||||
var apiErr *api.Error
|
||||
|
||||
switch c.Func {
|
||||
case "read":
|
||||
host, apiErr, err = hostClient.Read(c.Context, c.FlagId, opts...)
|
||||
case "delete":
|
||||
existed, apiErr, err = hostClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedHosts, apiErr, err = hostClient.List(c.Context, c.flagHostCatalogId, opts...)
|
||||
}
|
||||
|
||||
plural := "host"
|
||||
if c.Func == "list" {
|
||||
plural = "hosts"
|
||||
}
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr)))
|
||||
return 1
|
||||
}
|
||||
|
||||
switch c.Func {
|
||||
case "delete":
|
||||
switch base.Format(c.UI) {
|
||||
case "json":
|
||||
c.UI.Output("null")
|
||||
case "table":
|
||||
output := "The delete operation completed successfully"
|
||||
switch existed {
|
||||
case true:
|
||||
output += "."
|
||||
default:
|
||||
output += ", however the resource did not exist at the time."
|
||||
}
|
||||
c.UI.Output(output)
|
||||
}
|
||||
return 0
|
||||
|
||||
case "list":
|
||||
switch base.Format(c.UI) {
|
||||
case "json":
|
||||
if len(listedHosts) == 0 {
|
||||
c.UI.Output("null")
|
||||
return 0
|
||||
}
|
||||
b, err := base.JsonFormatter{}.Format(listedHosts)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
|
||||
case "table":
|
||||
if len(listedHosts) == 0 {
|
||||
c.UI.Output("No hosts found")
|
||||
return 0
|
||||
}
|
||||
var output []string
|
||||
output = []string{
|
||||
"",
|
||||
"Host information:",
|
||||
}
|
||||
for i, m := range listedHosts {
|
||||
if i > 0 {
|
||||
output = append(output, "")
|
||||
}
|
||||
if true {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" ID: %s", m.Id),
|
||||
fmt.Sprintf(" Version: %d", m.Version),
|
||||
fmt.Sprintf(" Type: %s", m.Type),
|
||||
)
|
||||
}
|
||||
if m.Name != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Name: %s", m.Name),
|
||||
)
|
||||
}
|
||||
if m.Description != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Description: %s", m.Description),
|
||||
)
|
||||
}
|
||||
}
|
||||
c.UI.Output(base.WrapForHelpText(output))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(generateHostTableOutput(host))
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(host)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/api/hosts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*CreateCommand)(nil)
|
||||
var _ cli.CommandAutocomplete = (*CreateCommand)(nil)
|
||||
|
||||
type CreateCommand struct {
|
||||
*base.Command
|
||||
|
||||
flagAddress string
|
||||
flagName string
|
||||
flagCatalogId string
|
||||
flagDescription string
|
||||
}
|
||||
|
||||
func (c *CreateCommand) Synopsis() string {
|
||||
return "Creates a host in the given host catalog"
|
||||
}
|
||||
|
||||
func (c *CreateCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary hosts create
|
||||
|
||||
Creates a host in the given host catalog. This command will result in an
|
||||
error for any catalog that does not support manual host creation.
|
||||
|
||||
Example:
|
||||
|
||||
$ boundary hosts create -catalog-id=<id> -address=<addr> -name=<name>
|
||||
|
||||
` + c.Flags().Help()
|
||||
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *CreateCommand) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
f := set.NewFlagSet("Command Options")
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "address",
|
||||
Target: &c.flagAddress,
|
||||
Completion: complete.PredictAnything,
|
||||
Usage: "The host's address; can be an IP address or DNS name",
|
||||
})
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "name",
|
||||
Target: &c.flagName,
|
||||
Completion: complete.PredictAnything,
|
||||
Usage: "An optional name assigned to the host for display purposes",
|
||||
})
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "catalog-id",
|
||||
Target: &c.flagCatalogId,
|
||||
Completion: complete.PredictAnything,
|
||||
Usage: "The ID of the host catalog in which the host should be created",
|
||||
})
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "description",
|
||||
Target: &c.flagDescription,
|
||||
Completion: complete.PredictNothing,
|
||||
Usage: "An optional description assigned to the host for display purposes",
|
||||
})
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *CreateCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *CreateCommand) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *CreateCommand) Run(args []string) int {
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
switch {
|
||||
case c.flagCatalogId == "":
|
||||
c.UI.Error("Catalog ID must be provided via -catalog-id")
|
||||
return 1
|
||||
case c.flagAddress == "":
|
||||
c.UI.Error("Host address must be provided via -address")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 2
|
||||
}
|
||||
|
||||
host, apiErr, err := hosts.NewClient(client).Create(c.Context,
|
||||
c.flagCatalogId,
|
||||
hosts.WithStaticHostAddress(c.flagAddress),
|
||||
hosts.WithName(c.flagName),
|
||||
hosts.WithDescription(c.flagDescription))
|
||||
|
||||
switch {
|
||||
case err != nil:
|
||||
c.UI.Error(fmt.Errorf("error creating host: %w", err).Error())
|
||||
return 2
|
||||
case apiErr != nil:
|
||||
c.UI.Error(pretty.Sprint(apiErr))
|
||||
return 2
|
||||
default:
|
||||
c.UI.Info(pretty.Sprint(host))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/textproto"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/hosts"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/common"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*StaticCommand)(nil)
|
||||
var _ cli.CommandAutocomplete = (*StaticCommand)(nil)
|
||||
|
||||
type StaticCommand struct {
|
||||
*base.Command
|
||||
|
||||
Func string
|
||||
|
||||
flagHostCatalogId string
|
||||
flagAddress string
|
||||
}
|
||||
|
||||
func (c *StaticCommand) Synopsis() string {
|
||||
return fmt.Sprintf("%s a static-type host within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
|
||||
}
|
||||
|
||||
var staticFlagsMap = map[string][]string{
|
||||
"create": {"host-catalog-id", "name", "description", "address"},
|
||||
"update": {"id", "name", "description", "version", "address"},
|
||||
}
|
||||
|
||||
func (c *StaticCommand) Help() string {
|
||||
var info string
|
||||
switch c.Func {
|
||||
case "create":
|
||||
info = base.WrapForHelpText([]string{
|
||||
"Usage: boundary hosts static create [options] [args]",
|
||||
"",
|
||||
" Create a static-type host. Example:",
|
||||
"",
|
||||
` $ boundary hosts static create -name prodops -description "Static host for ProdOps" -address "127.0.0.1"`,
|
||||
"",
|
||||
"",
|
||||
})
|
||||
|
||||
case "update":
|
||||
info = base.WrapForHelpText([]string{
|
||||
"Usage: boundary hosts static update [options] [args]",
|
||||
"",
|
||||
" Update a static-type host given its ID. Example:",
|
||||
"",
|
||||
` $ boundary hosts static update -id hst_1234567890 -name "devops" -description "Static host for DevOps" -address "10.20.30.40"`,
|
||||
"",
|
||||
"",
|
||||
})
|
||||
}
|
||||
return info + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *StaticCommand) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
f := set.NewFlagSet("Command Options")
|
||||
|
||||
if len(staticFlagsMap[c.Func]) > 0 {
|
||||
common.PopulateCommonFlags(c.Command, f, "static-type host", staticFlagsMap[c.Func])
|
||||
}
|
||||
|
||||
for _, name := range staticFlagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-catalog-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host resource",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
f = set.NewFlagSet("Static Host Options")
|
||||
|
||||
for _, name := range staticFlagsMap[c.Func] {
|
||||
switch name {
|
||||
case "address":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "address",
|
||||
Target: &c.flagAddress,
|
||||
Usage: "The address of the host",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *StaticCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *StaticCommand) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *StaticCommand) Run(args []string) int {
|
||||
if c.Func == "" {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(staticFlagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(staticFlagsMap[c.Func], "host-catalog-id") && c.flagHostCatalogId == "" {
|
||||
c.UI.Error("Host Catalog ID must be passed in via -host-catalog-id")
|
||||
return 1
|
||||
}
|
||||
if c.Func == "create" && c.flagAddress == "" {
|
||||
c.UI.Error("Address must be passed in via -address")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
var opts []hosts.Option
|
||||
|
||||
switch c.FlagName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, hosts.DefaultName())
|
||||
default:
|
||||
opts = append(opts, hosts.WithName(c.FlagName))
|
||||
}
|
||||
|
||||
switch c.FlagDescription {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, hosts.DefaultDescription())
|
||||
default:
|
||||
opts = append(opts, hosts.WithDescription(c.FlagDescription))
|
||||
}
|
||||
|
||||
switch c.flagAddress {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, hosts.DefaultStaticHostAddress())
|
||||
default:
|
||||
opts = append(opts, hosts.WithStaticHostAddress(c.flagAddress))
|
||||
}
|
||||
|
||||
hostClient := hosts.NewClient(client)
|
||||
|
||||
// Perform check-and-set when needed
|
||||
var version uint32
|
||||
switch c.Func {
|
||||
case "create":
|
||||
// These don't update so don't need the existing version
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, hosts.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
}
|
||||
|
||||
var host *hosts.Host
|
||||
var apiErr *api.Error
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
host, apiErr, err = hostClient.Create(c.Context, c.flagHostCatalogId, opts...)
|
||||
case "update":
|
||||
host, apiErr, err = hostClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
plural := "static-type host"
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr)))
|
||||
return 1
|
||||
}
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(generateHostTableOutput(host))
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(host)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -13,6 +13,7 @@ func generateHostSetTableOutput(in *hostsets.HostSet) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
@@ -55,23 +56,15 @@ func generateHostSetTableOutput(in *hostsets.HostSet) string {
|
||||
)
|
||||
|
||||
if len(in.HostIds) > 0 {
|
||||
if true {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Host IDs:"),
|
||||
)
|
||||
}
|
||||
ret = append(ret,
|
||||
" Host IDs:",
|
||||
base.WrapSlice(4, in.HostIds),
|
||||
)
|
||||
}
|
||||
|
||||
if len(in.Attributes) > 0 {
|
||||
if true {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
)
|
||||
}
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
base.WrapMap(4, maxLength, in.Attributes),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ func (c *Command) Synopsis() string {
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"host-catalog-id"},
|
||||
"add-hosts": {"id", "host", "version"},
|
||||
"set-hosts": {"id", "host", "version"},
|
||||
"remove-hosts": {"id", "host", "version"},
|
||||
@@ -53,6 +54,7 @@ var flagsMap = map[string][]string{
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("host-set")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
@@ -67,7 +69,7 @@ func (c *Command) Help() string {
|
||||
" Please see the host-sets subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary host-set resources. Example:",
|
||||
@@ -79,7 +81,7 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary host-set resources. Example:",
|
||||
@@ -91,7 +93,7 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "add-hosts":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets add-hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows adding hosts to host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
|
||||
@@ -101,7 +103,7 @@ func (c *Command) Help() string {
|
||||
` $ boundary host-sets add-hosts -id hsst_1234567890 -host hst_1234567890 -host hst_0987654321`,
|
||||
})
|
||||
case "remove-hosts":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets remove-hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows removing hosts from host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
|
||||
@@ -111,7 +113,7 @@ func (c *Command) Help() string {
|
||||
` $ boundary host-sets remove-hosts -id hsst_1234567890 -host hst_0987654321`,
|
||||
})
|
||||
case "set-hosts":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets set-hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows setting the complete set of hosts on host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
|
||||
@@ -121,8 +123,9 @@ func (c *Command) Help() string {
|
||||
` $ boundary host-sets remove-hosts -id hsst_1234567890 -host hst_1234567890`,
|
||||
})
|
||||
default:
|
||||
return helpMap[c.Func]() + c.Flags().Help()
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
@@ -134,14 +137,14 @@ func (c *Command) Flags() *base.FlagSets {
|
||||
common.PopulateCommonFlags(c.Command, f, resource.HostSet.String(), flagsMap[c.Func])
|
||||
}
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
|
||||
for _, name := range flagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-catalog-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
case "host":
|
||||
f.StringSliceVar(&base.StringSliceVar{
|
||||
Name: "host",
|
||||
@@ -174,11 +177,14 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "host-catalog-id") && c.flagHostCatalogId == "" {
|
||||
c.UI.Error("Host Catalog ID must be passed in via -host-catalog-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -232,7 +238,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "add-hosts", "remove-hosts", "set-hosts":
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning())
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -250,17 +256,17 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "read":
|
||||
set, apiErr, err = hostsetClient.Read(c.Context, c.flagHostCatalogId, c.FlagId, opts...)
|
||||
set, apiErr, err = hostsetClient.Read(c.Context, c.FlagId, opts...)
|
||||
case "delete":
|
||||
existed, apiErr, err = hostsetClient.Delete(c.Context, c.flagHostCatalogId, c.FlagId, opts...)
|
||||
existed, apiErr, err = hostsetClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedSets, apiErr, err = hostsetClient.List(c.Context, c.flagHostCatalogId, opts...)
|
||||
case "add-hosts":
|
||||
set, apiErr, err = hostsetClient.AddHosts(c.Context, c.flagHostCatalogId, c.FlagId, version, c.flagHosts, opts...)
|
||||
set, apiErr, err = hostsetClient.AddHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
|
||||
case "remove-hosts":
|
||||
set, apiErr, err = hostsetClient.RemoveHosts(c.Context, c.flagHostCatalogId, c.FlagId, version, c.flagHosts, opts...)
|
||||
set, apiErr, err = hostsetClient.RemoveHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
|
||||
case "set-hosts":
|
||||
set, apiErr, err = hostsetClient.SetHosts(c.Context, c.flagHostCatalogId, c.FlagId, version, c.flagHosts, opts...)
|
||||
set, apiErr, err = hostsetClient.SetHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
|
||||
}
|
||||
|
||||
plural := "host set"
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c *StaticCommand) Synopsis() string {
|
||||
}
|
||||
|
||||
var staticFlagsMap = map[string][]string{
|
||||
"create": {"name", "description"},
|
||||
"create": {"host-catalog-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
}
|
||||
|
||||
@@ -71,11 +71,16 @@ func (c *StaticCommand) Flags() *base.FlagSets {
|
||||
common.PopulateCommonFlags(c.Command, f, "static-type host-set", staticFlagsMap[c.Func])
|
||||
}
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
for _, name := range staticFlagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-catalog-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
@@ -104,8 +109,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
|
||||
if c.flagHostCatalogId == "" {
|
||||
if strutil.StrListContains(staticFlagsMap[c.Func], "host-catalog-id") && c.flagHostCatalogId == "" {
|
||||
c.UI.Error("Host Catalog ID must be passed in via -host-catalog-id")
|
||||
return 1
|
||||
}
|
||||
@@ -144,7 +148,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning())
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -157,7 +161,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
case "create":
|
||||
set, apiErr, err = hostsetClient.Create(c.Context, c.flagHostCatalogId, opts...)
|
||||
case "update":
|
||||
set, apiErr, err = hostsetClient.Update(c.Context, c.flagHostCatalogId, c.FlagId, version, opts...)
|
||||
set, apiErr, err = hostsetClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
plural := "static-type host-set"
|
||||
|
||||
@@ -91,6 +91,7 @@ func generateRoleTableOutput(in *roles.Role) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
|
||||
@@ -22,6 +22,7 @@ type Command struct {
|
||||
|
||||
Func string
|
||||
|
||||
flagScope string
|
||||
flagGrantScopeId string
|
||||
flagPrincipals []string
|
||||
flagGrants []string
|
||||
@@ -51,10 +52,11 @@ var helpMap = func() map[string]func() string {
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"create": {"name", "description", "grantscopeid"},
|
||||
"create": {"scope-id", "name", "description", "grantscopeid"},
|
||||
"update": {"id", "name", "description", "grantscopeid", "version"},
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
"add-principals": {"id", "principal", "version"},
|
||||
"set-principals": {"id", "principal", "version"},
|
||||
"remove-principals": {"id", "principal", "version"},
|
||||
@@ -105,6 +107,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -198,7 +204,7 @@ func (c *Command) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, roles.WithAutomaticVersioning())
|
||||
opts = append(opts, roles.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -211,7 +217,7 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
role, apiErr, err = roleClient.Create(c.Context, opts...)
|
||||
role, apiErr, err = roleClient.Create(c.Context, c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
role, apiErr, err = roleClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
case "read":
|
||||
@@ -219,7 +225,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = roleClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedRoles, apiErr, err = roleClient.List(c.Context, opts...)
|
||||
listedRoles, apiErr, err = roleClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
case "add-principals":
|
||||
role, apiErr, err = roleClient.AddPrincipals(c.Context, c.FlagId, version, principals, opts...)
|
||||
case "set-principals":
|
||||
|
||||
@@ -12,6 +12,7 @@ func generateScopeTableOutput(in *scopes.Scope) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
|
||||
@@ -30,10 +30,11 @@ func (c *Command) Synopsis() string {
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"create": {"name", "description", "skip-role-creation"},
|
||||
"create": {"scope-id", "name", "description", "skip-role-creation"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
@@ -86,6 +87,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -123,7 +128,7 @@ func (c *Command) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, scopes.WithAutomaticVersioning())
|
||||
opts = append(opts, scopes.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -136,7 +141,7 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
scope, apiErr, err = scopeClient.Create(c.Context, client.ScopeId(), opts...)
|
||||
scope, apiErr, err = scopeClient.Create(c.Context, c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
scope, apiErr, err = scopeClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
case "read":
|
||||
@@ -144,7 +149,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = scopeClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedScopes, apiErr, err = scopeClient.List(c.Context, client.ScopeId(), opts...)
|
||||
listedScopes, apiErr, err = scopeClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
}
|
||||
|
||||
plural := "scope"
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package targets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/api/scopes"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
)
|
||||
|
||||
func generateTargetTableOutput(in *targets.Target) string {
|
||||
var ret []string
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
"Default Port": in.DefaultPort,
|
||||
}
|
||||
|
||||
if in.Name != "" {
|
||||
nonAttributeMap["Name"] = in.Name
|
||||
}
|
||||
if in.Description != "" {
|
||||
nonAttributeMap["Description"] = in.Description
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
for k := range nonAttributeMap {
|
||||
if len(k) > maxLength {
|
||||
maxLength = len(k)
|
||||
}
|
||||
}
|
||||
|
||||
var hostSetMaps []map[string]interface{}
|
||||
if len(in.HostSets) > 0 {
|
||||
for _, set := range in.HostSets {
|
||||
m := map[string]interface{}{
|
||||
"ID": set.Id,
|
||||
"Host Catalog ID": set.HostCatalogId,
|
||||
}
|
||||
hostSetMaps = append(hostSetMaps, m)
|
||||
}
|
||||
if l := len("Host Catalog ID"); l > maxLength {
|
||||
maxLength = l
|
||||
}
|
||||
}
|
||||
ret = append(ret, "", "Target information:")
|
||||
|
||||
ret = append(ret,
|
||||
// We do +2 because there is another +2 offset for host sets below
|
||||
base.WrapMap(2, maxLength+2, nonAttributeMap),
|
||||
)
|
||||
|
||||
if len(in.HostSets) > 0 {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Host Sets: %s", ""),
|
||||
)
|
||||
for _, m := range hostSetMaps {
|
||||
ret = append(ret,
|
||||
base.WrapMap(4, maxLength, m),
|
||||
"",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return base.WrapForHelpText(ret)
|
||||
}
|
||||
|
||||
func exampleOutput() string {
|
||||
in := &targets.Target{
|
||||
Id: "ttcp_1234567890",
|
||||
ScopeId: "global",
|
||||
Scope: &scopes.ScopeInfo{
|
||||
Id: "global",
|
||||
},
|
||||
Name: "foo",
|
||||
Description: "The bar of foos",
|
||||
CreatedTime: time.Now().Add(-5 * time.Minute),
|
||||
UpdatedTime: time.Now(),
|
||||
Version: 3,
|
||||
Type: "tcp",
|
||||
HostSetIds: []string{"hsst_1234567890", "hsst_0987654321"},
|
||||
HostSets: []*targets.HostSet{
|
||||
{
|
||||
Id: "hsst_1234567890",
|
||||
HostCatalogId: "hcst_1234567890",
|
||||
},
|
||||
{
|
||||
Id: "hsst_0987654321",
|
||||
HostCatalogId: "hcst_1234567890",
|
||||
},
|
||||
},
|
||||
DefaultPort: 22,
|
||||
}
|
||||
return generateTargetTableOutput(in)
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
package targets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/common"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*Command)(nil)
|
||||
var _ cli.CommandAutocomplete = (*Command)(nil)
|
||||
|
||||
type Command struct {
|
||||
*base.Command
|
||||
|
||||
Func string
|
||||
|
||||
flagHostSets []string
|
||||
}
|
||||
|
||||
func (c *Command) Synopsis() string {
|
||||
switch c.Func {
|
||||
case "create":
|
||||
return "Create target resources within Boundary"
|
||||
case "update":
|
||||
return "Update target resources within Boundary"
|
||||
default:
|
||||
return common.SynopsisFunc(c.Func, "target")
|
||||
}
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
"add-host-sets": {"id", "host-set", "version"},
|
||||
"remove-host-sets": {"id", "host-set", "version"},
|
||||
"set-host-sets": {"id", "host-set", "version"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("target")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
"Usage: boundary targets [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows operations on Boundary target resources. Example:",
|
||||
"",
|
||||
" Read a target:",
|
||||
"",
|
||||
` $ boundary targets read -id ttcp_1234567890`,
|
||||
"",
|
||||
" Please see the targets subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary targets create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary target resources. Example:",
|
||||
"",
|
||||
" Create a tcp-type target:",
|
||||
"",
|
||||
` $ boundary targets create tcp -name prodops -description "For ProdOps usage"`,
|
||||
"",
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary targets update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary target resources. Example:",
|
||||
"",
|
||||
" Update a tcp-type target:",
|
||||
"",
|
||||
` $ boundary targets update tcp -id ttcp_1234567890 -name devops -description "For DevOps usage"`,
|
||||
"",
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "add-host-sets":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary target add-host-sets [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows adding host-set resources to target resources. Example:",
|
||||
"",
|
||||
" Add host-set resources to a tcp-type target:",
|
||||
"",
|
||||
` $ boundary targets add-host-sets -id ttcp_1234567890 -host-set hsst_1234567890 -host-set hsst_0987654321`,
|
||||
})
|
||||
case "remove-host-sets":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary target remove-host-sets [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows removing host-set resources from target resources. Example:",
|
||||
"",
|
||||
" Remove host-set resources from a tcp-type target:",
|
||||
"",
|
||||
` $ boundary targets add-host-sets -id ttcp_1234567890 -host hsst_1234567890 -host-set hsst_0987654321`,
|
||||
})
|
||||
case "set-host-sets":
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary target set-host-sets [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows setting the complete set of host-set resources on a target resource. Example:",
|
||||
"",
|
||||
" Set host-set resources on a tcp-type target:",
|
||||
"",
|
||||
` $ boundary targets set-host-sets -id ttcp_1234567890 -host-set hsst_1234567890`,
|
||||
})
|
||||
default:
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
f := set.NewFlagSet("Command Options")
|
||||
|
||||
if len(flagsMap[c.Func]) > 0 {
|
||||
common.PopulateCommonFlags(c.Command, f, resource.Target.String(), flagsMap[c.Func])
|
||||
}
|
||||
|
||||
for _, name := range flagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-set":
|
||||
f.StringSliceVar(&base.StringSliceVar{
|
||||
Name: "host-set",
|
||||
Target: &c.flagHostSets,
|
||||
Usage: "The host-set resources to add, remove, or set. May be specified multiple times.",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *Command) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *Command) Run(args []string) int {
|
||||
if os.Getenv("BOUNDARY_EXAMPLE_CLI_OUTPUT") != "" {
|
||||
c.UI.Output(exampleOutput())
|
||||
return 0
|
||||
}
|
||||
|
||||
switch c.Func {
|
||||
case "", "create", "update":
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
var opts []targets.Option
|
||||
|
||||
switch c.FlagName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, targets.DefaultName())
|
||||
default:
|
||||
opts = append(opts, targets.WithName(c.FlagName))
|
||||
}
|
||||
|
||||
switch c.FlagDescription {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, targets.DefaultDescription())
|
||||
default:
|
||||
opts = append(opts, targets.WithDescription(c.FlagDescription))
|
||||
}
|
||||
|
||||
hostSets := c.flagHostSets
|
||||
switch c.Func {
|
||||
case "add-host-sets", "remove-host-sets":
|
||||
if len(c.flagHostSets) == 0 {
|
||||
c.UI.Error("No host-sets supplied via -host-set")
|
||||
return 1
|
||||
}
|
||||
|
||||
case "set-host-sets":
|
||||
switch len(c.flagHostSets) {
|
||||
case 0:
|
||||
case 1:
|
||||
if c.flagHostSets[0] == "null" {
|
||||
hostSets = []string{}
|
||||
}
|
||||
}
|
||||
if hostSets == nil {
|
||||
c.UI.Error("No host-sets supplied via -host-set")
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
// Perform check-and-set when needed
|
||||
var version uint32
|
||||
switch c.Func {
|
||||
case "add-host-sets", "remove-host-sets", "set-host-sets":
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, targets.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
default:
|
||||
// The only other one that needs it is update, handled by the static
|
||||
// file
|
||||
}
|
||||
|
||||
targetClient := targets.NewClient(client)
|
||||
|
||||
var existed bool
|
||||
var target *targets.Target
|
||||
var listedCatalogs []*targets.Target
|
||||
var apiErr *api.Error
|
||||
|
||||
switch c.Func {
|
||||
case "read":
|
||||
target, apiErr, err = targetClient.Read(c.Context, c.FlagId, opts...)
|
||||
case "delete":
|
||||
existed, apiErr, err = targetClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedCatalogs, apiErr, err = targetClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
case "add-host-sets":
|
||||
target, apiErr, err = targetClient.AddHostSets(c.Context, c.FlagId, version, c.flagHostSets, opts...)
|
||||
case "remove-host-sets":
|
||||
target, apiErr, err = targetClient.RemoveHostSets(c.Context, c.FlagId, version, c.flagHostSets, opts...)
|
||||
case "set-host-sets":
|
||||
target, apiErr, err = targetClient.SetHostSets(c.Context, c.FlagId, version, c.flagHostSets, opts...)
|
||||
}
|
||||
|
||||
plural := "target"
|
||||
if c.Func == "list" {
|
||||
plural = "targets"
|
||||
}
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr)))
|
||||
return 1
|
||||
}
|
||||
|
||||
switch c.Func {
|
||||
case "delete":
|
||||
switch base.Format(c.UI) {
|
||||
case "json":
|
||||
c.UI.Output("null")
|
||||
case "table":
|
||||
output := "The delete operation completed successfully"
|
||||
switch existed {
|
||||
case true:
|
||||
output += "."
|
||||
default:
|
||||
output += ", however the resource did not exist at the time."
|
||||
}
|
||||
c.UI.Output(output)
|
||||
}
|
||||
return 0
|
||||
|
||||
case "list":
|
||||
switch base.Format(c.UI) {
|
||||
case "json":
|
||||
if len(listedCatalogs) == 0 {
|
||||
c.UI.Output("null")
|
||||
return 0
|
||||
}
|
||||
b, err := base.JsonFormatter{}.Format(listedCatalogs)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
|
||||
case "table":
|
||||
if len(listedCatalogs) == 0 {
|
||||
c.UI.Output("No targets found")
|
||||
return 0
|
||||
}
|
||||
var output []string
|
||||
output = []string{
|
||||
"",
|
||||
"Target information:",
|
||||
}
|
||||
for i, m := range listedCatalogs {
|
||||
if i > 0 {
|
||||
output = append(output, "")
|
||||
}
|
||||
if true {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" ID: %s", m.Id),
|
||||
fmt.Sprintf(" Version: %d", m.Version),
|
||||
fmt.Sprintf(" Type: %s", m.Type),
|
||||
)
|
||||
}
|
||||
if m.Name != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Name: %s", m.Name),
|
||||
)
|
||||
}
|
||||
if m.Description != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Description: %s", m.Description),
|
||||
)
|
||||
}
|
||||
}
|
||||
c.UI.Output(base.WrapForHelpText(output))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(generateTargetTableOutput(target))
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(target)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package targets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/textproto"
|
||||
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/common"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
"github.com/kr/pretty"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var _ cli.Command = (*TcpCommand)(nil)
|
||||
var _ cli.CommandAutocomplete = (*TcpCommand)(nil)
|
||||
|
||||
type TcpCommand struct {
|
||||
*base.Command
|
||||
|
||||
Func string
|
||||
}
|
||||
|
||||
func (c *TcpCommand) Synopsis() string {
|
||||
return fmt.Sprintf("%s a tcp-type target within Boundary", textproto.CanonicalMIMEHeaderKey(c.Func))
|
||||
}
|
||||
|
||||
var tcpFlagsMap = map[string][]string{
|
||||
"create": {"scope-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
}
|
||||
|
||||
func (c *TcpCommand) Help() string {
|
||||
var info string
|
||||
switch c.Func {
|
||||
case "create":
|
||||
info = base.WrapForHelpText([]string{
|
||||
"Usage: boundary targets tcp create [options] [args]",
|
||||
"",
|
||||
" Create a tcp-type target. Example:",
|
||||
"",
|
||||
` $ boundary targets tcp create -name prodops -description "Tcp target for ProdOps"`,
|
||||
"",
|
||||
"",
|
||||
})
|
||||
|
||||
case "update":
|
||||
info = base.WrapForHelpText([]string{
|
||||
"Usage: boundary targets tcp update [options] [args]",
|
||||
"",
|
||||
" Update a tcp-type target given its ID. Example:",
|
||||
"",
|
||||
` $ boundary targets tcp update -id ttcp_1234567890 -name "devops" -description "Tcp target for DevOps"`,
|
||||
"",
|
||||
"",
|
||||
})
|
||||
}
|
||||
return info + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *TcpCommand) Flags() *base.FlagSets {
|
||||
set := c.FlagSet(base.FlagSetHTTP | base.FlagSetClient | base.FlagSetOutputFormat)
|
||||
|
||||
if len(tcpFlagsMap[c.Func]) > 0 {
|
||||
f := set.NewFlagSet("Command Options")
|
||||
common.PopulateCommonFlags(c.Command, f, "tcp-type target", tcpFlagsMap[c.Func])
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
func (c *TcpCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictAnything
|
||||
}
|
||||
|
||||
func (c *TcpCommand) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *TcpCommand) Run(args []string) int {
|
||||
if c.Func == "" {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
f := c.Flags()
|
||||
|
||||
if err := f.Parse(args); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(tcpFlagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(tcpFlagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error creating API client: %s", err.Error()))
|
||||
return 2
|
||||
}
|
||||
|
||||
var opts []targets.Option
|
||||
|
||||
switch c.FlagName {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, targets.DefaultName())
|
||||
default:
|
||||
opts = append(opts, targets.WithName(c.FlagName))
|
||||
}
|
||||
|
||||
switch c.FlagDescription {
|
||||
case "":
|
||||
case "null":
|
||||
opts = append(opts, targets.DefaultDescription())
|
||||
default:
|
||||
opts = append(opts, targets.WithDescription(c.FlagDescription))
|
||||
}
|
||||
|
||||
targetClient := targets.NewClient(client)
|
||||
|
||||
// Perform check-and-set when needed
|
||||
var version uint32
|
||||
switch c.Func {
|
||||
case "create":
|
||||
// These don't update so don't need the existing version
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, targets.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
}
|
||||
|
||||
var catalog *targets.Target
|
||||
var apiErr *api.Error
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
catalog, apiErr, err = targetClient.Create(c.Context, "tcp", c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
catalog, apiErr, err = targetClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
plural := "tcp-type target"
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error trying to %s %s: %s", c.Func, plural, err.Error()))
|
||||
return 2
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error from controller when performing %s on %s: %s", c.Func, plural, pretty.Sprint(apiErr)))
|
||||
return 1
|
||||
}
|
||||
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
c.UI.Output(generateTargetTableOutput(catalog))
|
||||
case "json":
|
||||
b, err := base.JsonFormatter{}.Format(catalog)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
c.UI.Output(string(b))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -12,6 +12,7 @@ func generateUserTableOutput(in *users.User) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
"Updated Time": in.UpdatedTime.Local().Format(time.RFC3339),
|
||||
|
||||
@@ -28,10 +28,11 @@ func (c *Command) Synopsis() string {
|
||||
}
|
||||
|
||||
var flagsMap = map[string][]string{
|
||||
"create": {"name", "description"},
|
||||
"create": {"scope-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"scope-id"},
|
||||
}
|
||||
|
||||
func (c *Command) Help() string {
|
||||
@@ -77,6 +78,10 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
|
||||
c.UI.Error("Scope ID must be passed in via -scope-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -112,7 +117,7 @@ func (c *Command) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, users.WithAutomaticVersioning())
|
||||
opts = append(opts, users.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -125,7 +130,7 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "create":
|
||||
user, apiErr, err = userClient.Create(c.Context, opts...)
|
||||
user, apiErr, err = userClient.Create(c.Context, c.FlagScopeId, opts...)
|
||||
case "update":
|
||||
user, apiErr, err = userClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
case "read":
|
||||
@@ -133,7 +138,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "delete":
|
||||
existed, apiErr, err = userClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedUsers, apiErr, err = userClient.List(c.Context, opts...)
|
||||
listedUsers, apiErr, err = userClient.List(c.Context, c.FlagScopeId, opts...)
|
||||
}
|
||||
|
||||
plural := "user"
|
||||
|
||||
@@ -4,11 +4,20 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
func PopulateCommonFlags(c *base.Command, f *base.FlagSet, resourceType string, flagNames []string) {
|
||||
for _, name := range flagNames {
|
||||
switch name {
|
||||
case "scope-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "scope-id",
|
||||
Target: &c.FlagScopeId,
|
||||
Default: "global",
|
||||
Completion: complete.PredictAnything,
|
||||
Usage: `Scope in which to make the request. Defaults to "global".`,
|
||||
})
|
||||
case "id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "id",
|
||||
|
||||
@@ -289,6 +289,40 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/auth-methods/{auth_method_id}:authenticate": {
|
||||
"post": {
|
||||
"summary": "Authenticate a user to an scope and retrieve an authentication token.",
|
||||
"operationId": "AuthenticationService_Authenticate",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.api.resources.authtokens.v1.AuthToken"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "auth_method_id",
|
||||
"description": "The id to the authmethod in the system being used for authentication. The auth method must be in the scope\nbeing logged in to.",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/controller.api.services.v1.AuthenticateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"controller.api.services.v1.AuthenticationService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/auth-methods/{id}": {
|
||||
"get": {
|
||||
"summary": "Gets a single AuthMethod",
|
||||
@@ -1881,7 +1915,7 @@
|
||||
"/v1/scopes/*/auth-methods/{auth_method_id}:authenticate": {
|
||||
"post": {
|
||||
"summary": "Authenticate a user to an scope and retrieve an authentication token.",
|
||||
"operationId": "AuthenticationService_Authenticate",
|
||||
"operationId": "AuthenticationService_Authenticate2",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
@@ -4984,7 +5018,7 @@
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"old_password": {
|
||||
"current_password": {
|
||||
"type": "string"
|
||||
},
|
||||
"new_password": {
|
||||
|
||||
@@ -659,10 +659,10 @@ type ChangePasswordRequest struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
|
||||
OldPassword string `protobuf:"bytes,3,opt,name=old_password,proto3" json:"old_password,omitempty"`
|
||||
NewPassword string `protobuf:"bytes,4,opt,name=new_password,proto3" json:"new_password,omitempty"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
|
||||
CurrentPassword string `protobuf:"bytes,3,opt,name=current_password,proto3" json:"current_password,omitempty"`
|
||||
NewPassword string `protobuf:"bytes,4,opt,name=new_password,proto3" json:"new_password,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ChangePasswordRequest) Reset() {
|
||||
@@ -711,9 +711,9 @@ func (x *ChangePasswordRequest) GetVersion() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ChangePasswordRequest) GetOldPassword() string {
|
||||
func (x *ChangePasswordRequest) GetCurrentPassword() string {
|
||||
if x != nil {
|
||||
return x.OldPassword
|
||||
return x.CurrentPassword
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -858,138 +858,139 @@ var file_controller_api_services_v1_account_service_proto_rawDesc = []byte{
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65,
|
||||
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65,
|
||||
0x6d, 0x22, 0x89, 0x01, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73,
|
||||
0x6d, 0x22, 0x91, 0x01, 0x0a, 0x15, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73,
|
||||
0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65,
|
||||
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x73,
|
||||
0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x6c, 0x64,
|
||||
0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x65, 0x77,
|
||||
0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0c, 0x6e, 0x65, 0x77, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x5b, 0x0a,
|
||||
0x16, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
|
||||
0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73,
|
||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x32, 0xfc, 0x0d, 0x0a, 0x0e, 0x41,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xd9, 0x01,
|
||||
0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6c, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x4c, 0x12, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x5a, 0x31, 0x12, 0x29, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63,
|
||||
0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68,
|
||||
0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b,
|
||||
0x69, 0x64, 0x7d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92,
|
||||
0x41, 0x17, 0x12, 0x15, 0x47, 0x65, 0x74, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c,
|
||||
0x65, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0xf0, 0x01, 0x0a, 0x0c, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x7d, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x45, 0x12, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x73, 0x5a, 0x35, 0x12, 0x33, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65,
|
||||
0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73,
|
||||
0x2f, 0x7b, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64,
|
||||
0x7d, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x92, 0x41, 0x2f, 0x12, 0x2d, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x73, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x20,
|
||||
0x61, 0x75, 0x74, 0x68, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x12, 0x99, 0x02, 0x0a,
|
||||
0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30,
|
||||
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61,
|
||||
0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70,
|
||||
0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72,
|
||||
0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x22, 0xa2, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x62, 0x22, 0x0c, 0x2f, 0x76,
|
||||
0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d,
|
||||
0x5a, 0x46, 0x22, 0x38, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a,
|
||||
0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69,
|
||||
0x74, 0x65, 0x6d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f,
|
||||
0x69, 0x64, 0x7d, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x04, 0x69, 0x74,
|
||||
0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41,
|
||||
0x37, 0x12, 0x35, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e,
|
||||
0x67, 0x6c, 0x65, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20, 0x61, 0x75, 0x74, 0x68,
|
||||
0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x12, 0xec, 0x01, 0x0a, 0x0d, 0x55, 0x70, 0x64,
|
||||
0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
|
||||
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||
0x76, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x58, 0x32, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d,
|
||||
0x5a, 0x37, 0x32, 0x29, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a,
|
||||
0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f,
|
||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x69,
|
||||
0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92,
|
||||
0x41, 0x15, 0x12, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x12, 0xd4, 0x01, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65,
|
||||
0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69,
|
||||
0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5e,
|
||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x40, 0x2a, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x5a, 0x2b, 0x2a, 0x29, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d,
|
||||
0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x92, 0x41, 0x15, 0x12, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74,
|
||||
0x65, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x12, 0x93,
|
||||
0x02, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x2e,
|
||||
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50,
|
||||
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f,
|
||||
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50,
|
||||
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||
0xa2, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x6c, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x73, 0x65, 0x74, 0x2d,
|
||||
0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x3a, 0x01, 0x2a, 0x5a, 0x41, 0x22, 0x36, 0x2f,
|
||||
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x10, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
|
||||
0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x65, 0x77, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
|
||||
0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x5f, 0x70, 0x61, 0x73,
|
||||
0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x5b, 0x0a, 0x16, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50,
|
||||
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x41, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72,
|
||||
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x04, 0x69, 0x74,
|
||||
0x65, 0x6d, 0x32, 0xfc, 0x0d, 0x0a, 0x0e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xd9, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65,
|
||||
0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x22, 0x6c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x4c, 0x12, 0x11, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x5a, 0x31,
|
||||
0x12, 0x29, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61,
|
||||
0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x62, 0x04, 0x69, 0x74, 0x65,
|
||||
0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x17, 0x12, 0x15, 0x47, 0x65, 0x74, 0x73,
|
||||
0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0xf0, 0x01, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x73, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x7d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x45, 0x12, 0x0c, 0x2f,
|
||||
0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5a, 0x35, 0x12, 0x33, 0x2f,
|
||||
0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68,
|
||||
0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x73, 0x65, 0x74, 0x2d, 0x70, 0x61, 0x73,
|
||||
0x73, 0x77, 0x6f, 0x72, 0x64, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04,
|
||||
0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x2d, 0x12, 0x2b, 0x53, 0x65, 0x74, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x2e, 0x12, 0xa2, 0x02, 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50,
|
||||
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
|
||||
0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77,
|
||||
0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61,
|
||||
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa8,
|
||||
0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x72, 0x22, 0x21, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x63, 0x68, 0x61, 0x6e, 0x67,
|
||||
0x65, 0x2d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x3a, 0x01, 0x2a, 0x5a, 0x44, 0x22,
|
||||
0x39, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75,
|
||||
0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x63, 0x68, 0x61, 0x6e, 0x67,
|
||||
0x65, 0x2d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69,
|
||||
0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x2d, 0x12, 0x2b, 0x53, 0x65,
|
||||
0x74, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x20,
|
||||
0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64,
|
||||
0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74,
|
||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72,
|
||||
0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
|
||||
0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d,
|
||||
0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x73, 0x92, 0x41, 0x2f, 0x12, 0x2d, 0x4c, 0x69, 0x73, 0x74, 0x73, 0x20, 0x61, 0x6c, 0x6c,
|
||||
0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x73,
|
||||
0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x20, 0x61, 0x75, 0x74, 0x68, 0x20, 0x6d, 0x65, 0x74,
|
||||
0x68, 0x6f, 0x64, 0x2e, 0x12, 0x99, 0x02, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72,
|
||||
0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa2, 0x01, 0x82, 0xd3,
|
||||
0xe4, 0x93, 0x02, 0x62, 0x22, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x73, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x5a, 0x46, 0x22, 0x38, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65,
|
||||
0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x69, 0x74, 0x65, 0x6d, 0x2e, 0x61, 0x75, 0x74, 0x68,
|
||||
0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x61, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x73, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d,
|
||||
0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x37, 0x12, 0x35, 0x43, 0x72, 0x65, 0x61, 0x74,
|
||||
0x65, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x61, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69,
|
||||
0x64, 0x65, 0x64, 0x20, 0x61, 0x75, 0x74, 0x68, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e,
|
||||
0x12, 0xec, 0x01, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65,
|
||||
0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x76, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x58, 0x32,
|
||||
0x11, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69,
|
||||
0x64, 0x7d, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x5a, 0x37, 0x32, 0x29, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65,
|
||||
0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73,
|
||||
0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65,
|
||||
0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x15, 0x12, 0x13, 0x55, 0x70, 0x64, 0x61,
|
||||
0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x12,
|
||||
0xd4, 0x01, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61,
|
||||
0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44,
|
||||
0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
|
||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31,
|
||||
0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x40, 0x2a, 0x11,
|
||||
0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64,
|
||||
0x7d, 0x5a, 0x2b, 0x2a, 0x29, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f,
|
||||
0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x2a,
|
||||
0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x92, 0x41,
|
||||
0x15, 0x12, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x12, 0x93, 0x02, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x50, 0x61,
|
||||
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa2, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x6c,
|
||||
0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b,
|
||||
0x69, 0x64, 0x7d, 0x3a, 0x73, 0x65, 0x74, 0x2d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
|
||||
0x3a, 0x01, 0x2a, 0x5a, 0x41, 0x22, 0x36, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65,
|
||||
0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73,
|
||||
0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d,
|
||||
0x3a, 0x73, 0x65, 0x74, 0x2d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x3a, 0x01, 0x2a,
|
||||
0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x2d, 0x12,
|
||||
0x2b, 0x53, 0x65, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f,
|
||||
0x72, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69,
|
||||
0x64, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x12, 0xa2, 0x02, 0x0a,
|
||||
0x0e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12,
|
||||
0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69,
|
||||
0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61,
|
||||
0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa8, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x72, 0x22,
|
||||
0x21, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69,
|
||||
0x64, 0x7d, 0x3a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f,
|
||||
0x72, 0x64, 0x3a, 0x01, 0x2a, 0x5a, 0x44, 0x22, 0x39, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f,
|
||||
0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f,
|
||||
0x64, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69,
|
||||
0x64, 0x7d, 0x3a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f,
|
||||
0x72, 0x64, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65,
|
||||
0x6d, 0x92, 0x41, 0x2d, 0x12, 0x2b, 0x53, 0x65, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70,
|
||||
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x2e, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
||||
0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61,
|
||||
0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -334,8 +334,8 @@ var file_controller_api_services_v1_authenticate_service_proto_rawDesc = []byte{
|
||||
0x17, 0x0a, 0x15, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
|
||||
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x61, 0x75,
|
||||
0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x32, 0xa0, 0x02, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x86, 0x02, 0x0a,
|
||||
0x73, 0x65, 0x32, 0xdb, 0x02, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xc1, 0x02, 0x0a,
|
||||
0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x2e,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65,
|
||||
@@ -343,21 +343,25 @@ var file_controller_api_services_v1_authenticate_service_proto_rawDesc = []byte{
|
||||
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68,
|
||||
0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x22, 0x92, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x42, 0x22, 0x37, 0x2f, 0x76, 0x31, 0x2f, 0x73,
|
||||
0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74,
|
||||
0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f,
|
||||
0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61,
|
||||
0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x47, 0x12, 0x45,
|
||||
0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x75,
|
||||
0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x6e, 0x20, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x20,
|
||||
0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x61, 0x6e, 0x20,
|
||||
0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f,
|
||||
0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f,
|
||||
0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61,
|
||||
0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x22, 0xcd, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x7d, 0x22, 0x2e, 0x2f, 0x76, 0x31, 0x2f, 0x61,
|
||||
0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74,
|
||||
0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74,
|
||||
0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x5a, 0x42, 0x22, 0x37,
|
||||
0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74,
|
||||
0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74, 0x68, 0x5f,
|
||||
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74, 0x68, 0x65,
|
||||
0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d,
|
||||
0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x47, 0x12, 0x45, 0x41, 0x75, 0x74, 0x68, 0x65,
|
||||
0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x74,
|
||||
0x6f, 0x20, 0x61, 0x6e, 0x20, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72,
|
||||
0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x75, 0x74, 0x68, 0x65,
|
||||
0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e,
|
||||
0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68,
|
||||
0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72,
|
||||
0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -97,6 +97,74 @@ func local_request_AuthenticationService_Authenticate_0(ctx context.Context, mar
|
||||
|
||||
}
|
||||
|
||||
func request_AuthenticationService_Authenticate_1(ctx context.Context, marshaler runtime.Marshaler, client AuthenticationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuthenticateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["auth_method_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auth_method_id")
|
||||
}
|
||||
|
||||
protoReq.AuthMethodId, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err)
|
||||
}
|
||||
|
||||
msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_AuthenticationService_Authenticate_1(ctx context.Context, marshaler runtime.Marshaler, server AuthenticationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq AuthenticateRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["auth_method_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "auth_method_id")
|
||||
}
|
||||
|
||||
protoReq.AuthMethodId, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "auth_method_id", err)
|
||||
}
|
||||
|
||||
msg, err := server.Authenticate(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterAuthenticationServiceHandlerServer registers the http handlers for service AuthenticationService to "mux".
|
||||
// UnaryRPC :call AuthenticationServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
@@ -123,6 +191,26 @@ func RegisterAuthenticationServiceHandlerServer(ctx context.Context, mux *runtim
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_AuthenticationService_Authenticate_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.AuthenticationService/Authenticate")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AuthenticationService_Authenticate_1(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_AuthenticationService_Authenticate_1(ctx, mux, outboundMarshaler, w, req, response_AuthenticationService_Authenticate_1{resp}, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -184,6 +272,26 @@ func RegisterAuthenticationServiceHandlerClient(ctx context.Context, mux *runtim
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_AuthenticationService_Authenticate_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.AuthenticationService/Authenticate")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AuthenticationService_Authenticate_1(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_AuthenticationService_Authenticate_1(ctx, mux, outboundMarshaler, w, req, response_AuthenticationService_Authenticate_1{resp}, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -196,10 +304,23 @@ func (m response_AuthenticationService_Authenticate_0) XXX_ResponseBody() interf
|
||||
return response.Item
|
||||
}
|
||||
|
||||
type response_AuthenticationService_Authenticate_1 struct {
|
||||
proto.Message
|
||||
}
|
||||
|
||||
func (m response_AuthenticationService_Authenticate_1) XXX_ResponseBody() interface{} {
|
||||
response := m.Message.(*AuthenticateResponse)
|
||||
return response.Item
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_AuthenticationService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "scopes", "auth-methods", "auth_method_id"}, "authenticate"))
|
||||
pattern_AuthenticationService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "auth-methods", "auth_method_id"}, "authenticate"))
|
||||
|
||||
pattern_AuthenticationService_Authenticate_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "scopes", "auth-methods", "auth_method_id"}, "authenticate"))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_AuthenticationService_Authenticate_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_AuthenticationService_Authenticate_1 = runtime.ForwardResponseMessage
|
||||
)
|
||||
@@ -178,16 +178,16 @@ func TestRepository_AddSetMembers_Combinations(t *testing.T) {
|
||||
|
||||
// second call - add new set of hosts - should succeed
|
||||
set.Version = set.Version + 1
|
||||
hosts2 := TestHosts(t, conn, c.PublicId, 5)
|
||||
Hosts := TestHosts(t, conn, c.PublicId, 5)
|
||||
var hostIds2 []string
|
||||
for _, h := range hosts2 {
|
||||
for _, h := range Hosts {
|
||||
hostIds2 = append(hostIds2, h.PublicId)
|
||||
}
|
||||
got2, err2 := repo.AddSetMembers(context.Background(), prj.PublicId, set.PublicId, set.Version, hostIds2)
|
||||
require.NoError(err2)
|
||||
require.NotNil(got2)
|
||||
|
||||
hosts = append(hosts, hosts2...)
|
||||
hosts = append(hosts, Hosts...)
|
||||
assert.Len(got2, len(hosts))
|
||||
assert.Empty(cmp.Diff(hosts, got2, opts...))
|
||||
assert.NoError(db.TestVerifyOplog(t, rw, set.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_CREATE), db.WithCreateNotBefore(10*time.Second)))
|
||||
@@ -391,9 +391,9 @@ func TestRepository_DeleteSetMembers_Combinations(t *testing.T) {
|
||||
assert.NoError(db.TestVerifyOplog(t, rw, set.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_DELETE), db.WithCreateNotBefore(10*time.Second)))
|
||||
|
||||
// verify no members remain
|
||||
members2, err := getHosts(context.Background(), repo.reader, set.PublicId, unlimited)
|
||||
Members, err := getHosts(context.Background(), repo.reader, set.PublicId, unlimited)
|
||||
require.NoError(err)
|
||||
require.Empty(members2)
|
||||
require.Empty(Members)
|
||||
}
|
||||
|
||||
func TestRepository_SetSetMembers_Parameters(t *testing.T) {
|
||||
|
||||
@@ -539,14 +539,14 @@ func TestRepository_UpdateSet(t *testing.T) {
|
||||
assert.Empty(gotHosts1)
|
||||
|
||||
sB.Name = name
|
||||
got2, gotHosts2, gotCount2, err := repo.UpdateSet(context.Background(), prj.GetPublicId(), sB, 1, []string{"name"})
|
||||
got2, gotHosts, gotCount2, err := repo.UpdateSet(context.Background(), prj.GetPublicId(), sB, 1, []string{"name"})
|
||||
assert.Truef(errors.Is(err, db.ErrNotUnique), "want err: %v got: %v", db.ErrNotUnique, err)
|
||||
assert.Nil(got2)
|
||||
assert.Equal(db.NoRowsAffected, gotCount2, "row count")
|
||||
err = db.TestVerifyOplog(t, rw, sB.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_UPDATE), db.WithCreateNotBefore(10*time.Second))
|
||||
assert.Error(err)
|
||||
assert.True(errors.Is(db.ErrRecordNotFound, err))
|
||||
assert.Empty(gotHosts2)
|
||||
assert.Empty(gotHosts)
|
||||
})
|
||||
|
||||
t.Run("valid-duplicate-names-diff-Catalogs", func(t *testing.T) {
|
||||
|
||||
@@ -46,16 +46,16 @@ func TestScopes(t *testing.T, repo *Repository, opt ...Option) (org *Scope, prj
|
||||
|
||||
opts := getOpts(opt...)
|
||||
|
||||
org, err := NewOrg()
|
||||
org, err := NewOrg(opt...)
|
||||
require.NoError(err)
|
||||
org, err = repo.CreateScope(context.Background(), org, opts.withUserId)
|
||||
org, err = repo.CreateScope(context.Background(), org, opts.withUserId, opt...)
|
||||
require.NoError(err)
|
||||
require.NotNil(org)
|
||||
require.NotEmpty(org.GetPublicId())
|
||||
|
||||
prj, err = NewProject(org.GetPublicId())
|
||||
prj, err = NewProject(org.GetPublicId(), opt...)
|
||||
require.NoError(err)
|
||||
prj, err = repo.CreateScope(context.Background(), prj, opts.withUserId)
|
||||
prj, err = repo.CreateScope(context.Background(), prj, opts.withUserId, opt...)
|
||||
require.NoError(err)
|
||||
require.NotNil(prj)
|
||||
require.NotEmpty(prj.GetPublicId())
|
||||
|
||||
@@ -205,7 +205,7 @@ message SetPasswordResponse {
|
||||
message ChangePasswordRequest {
|
||||
string id = 1;
|
||||
uint32 version = 2;
|
||||
string old_password = 3 [json_name="old_password"];
|
||||
string current_password = 3 [json_name="current_password"];
|
||||
string new_password = 4 [json_name="new_password"];
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,14 @@ service AuthenticationService {
|
||||
// Authenticate validates credentials provided and returns an auth token.
|
||||
rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/scopes/*/auth-methods/{auth_method_id}:authenticate"
|
||||
post: "/v1/auth-methods/{auth_method_id}:authenticate"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
additional_bindings: {
|
||||
post: "/v1/scopes/*/auth-methods/{auth_method_id}:authenticate"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
}
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||
summary: "Authenticate a user to an scope and retrieve an authentication token."
|
||||
|
||||
@@ -141,7 +141,7 @@ func (s Service) ChangePassword(ctx context.Context, req *pbs.ChangePasswordRequ
|
||||
if authResults.Error != nil {
|
||||
return nil, authResults.Error
|
||||
}
|
||||
u, err := s.changePasswordInRepo(ctx, authResults.Scope.GetId(), req.GetId(), req.GetVersion(), req.GetOldPassword(), req.GetNewPassword())
|
||||
u, err := s.changePasswordInRepo(ctx, authResults.Scope.GetId(), req.GetId(), req.GetVersion(), req.GetCurrentPassword(), req.GetNewPassword())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -295,12 +295,12 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]*pb.A
|
||||
return outUl, nil
|
||||
}
|
||||
|
||||
func (s Service) changePasswordInRepo(ctx context.Context, scopeId, id string, version uint32, oldPassword, newPassword string) (*pb.Account, error) {
|
||||
func (s Service) changePasswordInRepo(ctx context.Context, scopeId, id string, version uint32, currentPassword, newPassword string) (*pb.Account, error) {
|
||||
repo, err := s.repoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := repo.ChangePassword(ctx, scopeId, id, oldPassword, newPassword, version)
|
||||
out, err := repo.ChangePassword(ctx, scopeId, id, currentPassword, newPassword, version)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Unable to change password: %v.", err)
|
||||
}
|
||||
@@ -448,8 +448,8 @@ func validateChangePasswordRequest(req *pbs.ChangePasswordRequest) error {
|
||||
if req.GetNewPassword() == "" {
|
||||
badFields["new_password"] = "This is a required field."
|
||||
}
|
||||
if req.GetOldPassword() == "" {
|
||||
badFields["old_password"] = "This is a required field."
|
||||
if req.GetCurrentPassword() == "" {
|
||||
badFields["current_password"] = "This is a required field."
|
||||
}
|
||||
if len(badFields) > 0 {
|
||||
return handlers.InvalidArgumentErrorf("Improperly formatted identifier.", badFields)
|
||||
|
||||
@@ -950,10 +950,10 @@ func TestChangePassword(t *testing.T) {
|
||||
acct := createAccount(t, "originalpassword")
|
||||
|
||||
changeResp, err := tested.ChangePassword(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), &pbs.ChangePasswordRequest{
|
||||
Id: acct.GetId(),
|
||||
Version: acct.GetVersion(),
|
||||
OldPassword: "originalpassword",
|
||||
NewPassword: "a different password",
|
||||
Id: acct.GetId(),
|
||||
Version: acct.GetVersion(),
|
||||
CurrentPassword: "originalpassword",
|
||||
NewPassword: "a different password",
|
||||
})
|
||||
require.NoError(err)
|
||||
assert.Equal(acct.GetVersion()+1, changeResp.GetItem().GetVersion())
|
||||
@@ -969,10 +969,10 @@ func TestChangePassword(t *testing.T) {
|
||||
acct := createAccount(t, "originalpassword")
|
||||
|
||||
changeResp, err := tested.ChangePassword(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), &pbs.ChangePasswordRequest{
|
||||
Id: acct.GetId(),
|
||||
Version: acct.GetVersion(),
|
||||
OldPassword: "thewrongpassword",
|
||||
NewPassword: "a different password",
|
||||
Id: acct.GetId(),
|
||||
Version: acct.GetVersion(),
|
||||
CurrentPassword: "thewrongpassword",
|
||||
NewPassword: "a different password",
|
||||
})
|
||||
assert.Error(err)
|
||||
assert.Nil(changeResp)
|
||||
@@ -1042,10 +1042,10 @@ func TestChangePassword(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
changeResp, err := tested.ChangePassword(auth.DisabledAuthTestContext(auth.WithScopeId(o.GetPublicId())), &pbs.ChangePasswordRequest{
|
||||
Id: tt.accountId,
|
||||
Version: tt.version,
|
||||
OldPassword: tt.oldPW,
|
||||
NewPassword: tt.newPW,
|
||||
Id: tt.accountId,
|
||||
Version: tt.version,
|
||||
CurrentPassword: tt.oldPW,
|
||||
NewPassword: tt.newPW,
|
||||
})
|
||||
assert.Error(err)
|
||||
assert.Nil(changeResp)
|
||||
|
||||
@@ -199,7 +199,7 @@ func validateAuthenticateRequest(req *pbs.AuthenticateRequest) error {
|
||||
}
|
||||
tType := strings.ToLower(strings.TrimSpace(req.GetTokenType()))
|
||||
if tType != "" && tType != "token" && tType != "cookie" {
|
||||
badFields["token_type"] = "The only accepted type is 'token'."
|
||||
badFields["token_type"] = `The only accepted types are "token" and "cookie".`
|
||||
}
|
||||
if len(badFields) > 0 {
|
||||
return handlers.InvalidArgumentErrorf("Invalid fields provided in request.", badFields)
|
||||
|
||||
@@ -36,14 +36,14 @@ func TestAuthenticationMulti(t *testing.T) {
|
||||
defer c2.Shutdown()
|
||||
|
||||
auth := authmethods.NewClient(c1.Client())
|
||||
token1, apiErr, err := auth.Authenticate(c1.Context(), amId, user, password)
|
||||
token1, apiErr, err := auth.Authenticate(c1.Context(), amId, map[string]interface{}{"login_name": user, "password": password})
|
||||
require.Nil(err)
|
||||
require.Nil(apiErr)
|
||||
require.NotNil(token1)
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
auth = authmethods.NewClient(c2.Client())
|
||||
token2, apiErr, err := auth.Authenticate(c2.Context(), amId, user, password)
|
||||
token2, apiErr, err := auth.Authenticate(c2.Context(), amId, map[string]interface{}{"login_name": user, "password": password})
|
||||
require.Nil(err)
|
||||
require.Nil(apiErr)
|
||||
require.NotNil(token2)
|
||||
@@ -51,9 +51,7 @@ func TestAuthenticationMulti(t *testing.T) {
|
||||
assert.NotEqual(token1.Token, token2.Token)
|
||||
|
||||
c1.Client().SetToken(token1.Token)
|
||||
c1.Client().SetScopeId(scope.Global.String())
|
||||
c2.Client().SetToken(token1.Token) // Same token, as it should work on both
|
||||
c2.Client().SetScopeId(scope.Global.String())
|
||||
|
||||
// Create a project, read from the other
|
||||
org, apiErr, err := scopes.NewClient(c1.Client()).Create(c1.Context(), scope.Global.String())
|
||||
|
||||
@@ -103,8 +103,10 @@ func (tc *TestController) Token() *authtokens.AuthToken {
|
||||
token, apiErr, err := authmethods.NewClient(tc.Client()).Authenticate(
|
||||
tc.Context(),
|
||||
tc.b.DevAuthMethodId,
|
||||
tc.b.DevLoginName,
|
||||
tc.b.DevPassword,
|
||||
map[string]interface{}{
|
||||
"login_name": tc.b.DevLoginName,
|
||||
"password": tc.b.DevPassword,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
tc.t.Error(fmt.Errorf("error logging in: %w", err))
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/recovery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -40,7 +41,7 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
// Token 1, try 1
|
||||
client.SetToken(token1)
|
||||
roleClient := roles.NewClient(client)
|
||||
_, apiErr, err := roleClient.Create(tc.Context())
|
||||
_, apiErr, err := roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.NoError(err)
|
||||
assert.Nil(apiErr)
|
||||
nonces, err := repo.ListNonces(tc.Context())
|
||||
@@ -48,7 +49,7 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
assert.Len(nonces, 1)
|
||||
|
||||
// Token 1, try 2
|
||||
_, apiErr, err = roleClient.Create(tc.Context())
|
||||
_, apiErr, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.NoError(err)
|
||||
assert.NotNil(apiErr)
|
||||
nonces, err = repo.ListNonces(tc.Context())
|
||||
@@ -56,8 +57,8 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
assert.Len(nonces, 1)
|
||||
|
||||
// Token 2
|
||||
client.SetToken(token2)
|
||||
_, apiErr, err = roleClient.Create(tc.Context())
|
||||
roleClient.ApiClient().SetToken(token2)
|
||||
_, apiErr, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.NoError(err)
|
||||
assert.Nil(apiErr)
|
||||
nonces, err = repo.ListNonces(tc.Context())
|
||||
@@ -72,8 +73,8 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
|
||||
// And finally, make sure they still can't be used
|
||||
for _, token := range []string{token1, token2} {
|
||||
client.SetToken(token)
|
||||
_, apiErr, err = roleClient.Create(tc.Context())
|
||||
roleClient.ApiClient().SetToken(token)
|
||||
_, apiErr, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.NoError(err)
|
||||
assert.NotNil(apiErr)
|
||||
nonces, err = repo.ListNonces(tc.Context())
|
||||
|
||||
Reference in new issue
Block a user