Subtype Id registration moved to its own package (#1416)
* Allow repo packages to register subtypes and id prefixes. * Refactor out request authentication logic to a new package as a sibling to handler.
This commit is contained in:
1 parent
ab6f3eaeb4
commit
10e8aeae4b
62 files changed
+603
-597
No files matched your search
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
requestauth "github.com/hashicorp/boundary/internal/servers/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/common/scopeids"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
"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/internal/types/subtypes"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -49,7 +51,7 @@ const (
|
||||
var (
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = make(map[auth.Subtype]action.ActionSet)
|
||||
IdActions = make(map[subtypes.Subtype]action.ActionSet)
|
||||
|
||||
// CollectionActions contains the set of actions that can be performed on
|
||||
// this collection
|
||||
@@ -151,7 +153,7 @@ func (s Service) ListAuthMethods(ctx context.Context, req *pbs.ListAuthMethodsRe
|
||||
for _, am := range ul {
|
||||
res.Id = am.GetPublicId()
|
||||
res.ScopeId = am.GetScopeId()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[auth.SubtypeFromId(am.GetPublicId())], auth.WithResource(&res)).Strings()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[auth.SubtypeFromId(am.GetPublicId())], requestauth.WithResource(&res)).Strings()
|
||||
if len(authorizedActions) == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -166,7 +168,7 @@ func (s Service) ListAuthMethods(ctx context.Context, req *pbs.ListAuthMethodsRe
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authorizedActions))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -215,7 +217,7 @@ func (s Service) GetAuthMethod(ctx context.Context, req *pbs.GetAuthMethodReques
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[auth.SubtypeFromId(am.GetPublicId())]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -260,7 +262,7 @@ func (s Service) CreateAuthMethod(ctx context.Context, req *pbs.CreateAuthMethod
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[auth.SubtypeFromId(am.GetPublicId())]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -310,7 +312,7 @@ func (s Service) UpdateAuthMethod(ctx context.Context, req *pbs.UpdateAuthMethod
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[auth.SubtypeFromId(am.GetPublicId())]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -364,7 +366,7 @@ func (s Service) ChangeState(ctx context.Context, req *pbs.ChangeStateRequest) (
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[auth.SubtypeFromId(am.GetPublicId())]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -403,11 +405,11 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
}
|
||||
|
||||
switch auth.SubtypeFromId(req.GetAuthMethodId()) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
if err := validateAuthenticatePasswordRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
if err := validateAuthenticateOidcRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -419,10 +421,10 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
}
|
||||
|
||||
switch auth.SubtypeFromId(req.GetAuthMethodId()) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
return s.authenticatePassword(ctx, req, &authResults)
|
||||
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
return s.authenticateOidc(ctx, req, &authResults)
|
||||
}
|
||||
return nil, errors.New(errors.Internal, op, "Invalid auth method subtype not caught in validation function.")
|
||||
@@ -446,7 +448,7 @@ func (s Service) AuthenticateLogin(ctx context.Context, req *pbs.AuthenticateLog
|
||||
ScopeId: authResults.Scope.Id,
|
||||
Type: resource.AuthToken,
|
||||
}
|
||||
tok.AuthorizedActions = authResults.FetchActionSetForId(ctx, tok.Id, authtokens.IdActions, auth.WithResource(res)).Strings()
|
||||
tok.AuthorizedActions = authResults.FetchActionSetForId(ctx, tok.Id, authtokens.IdActions, requestauth.WithResource(res)).Strings()
|
||||
return &pbs.AuthenticateLoginResponse{Item: tok, TokenType: req.GetTokenType()}, nil
|
||||
}
|
||||
|
||||
@@ -454,14 +456,14 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.AuthMethod, e
|
||||
var lookupErr error
|
||||
var am auth.AuthMethod
|
||||
switch auth.SubtypeFromId(id) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
am, lookupErr = repo.LookupAuthMethod(ctx, id)
|
||||
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -485,7 +487,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.AuthMethod, e
|
||||
return am, nil
|
||||
}
|
||||
|
||||
func (s Service) listFromRepo(ctx context.Context, scopeIds []string, authResults auth.VerifyResults) ([]auth.AuthMethod, error) {
|
||||
func (s Service) listFromRepo(ctx context.Context, scopeIds []string, authResults requestauth.VerifyResults) ([]auth.AuthMethod, error) {
|
||||
const op = "authmethods.(Service).listFromRepo"
|
||||
reqCtx, ok := requests.RequestContextFromCtx(ctx)
|
||||
if !ok {
|
||||
@@ -498,7 +500,7 @@ func (s Service) listFromRepo(ctx context.Context, scopeIds []string, authResult
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
}
|
||||
ol, err := oidcRepo.ListAuthMethods(ctx, scopeIds, oidc.WithUnauthenticatedUser(reqCtx.UserId == auth.AnonymousUserId))
|
||||
ol, err := oidcRepo.ListAuthMethods(ctx, scopeIds, oidc.WithUnauthenticatedUser(reqCtx.UserId == requestauth.AnonymousUserId))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
}
|
||||
@@ -524,7 +526,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
const op = "authmethods.(Service).createInRepo"
|
||||
var out auth.AuthMethod
|
||||
switch auth.SubtypeFromType(item.GetType()) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
am, err := s.createPwInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
@@ -533,7 +535,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create auth method but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := s.createOidcInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
@@ -553,7 +555,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
var dryRun bool
|
||||
|
||||
switch auth.SubtypeFromId(req.GetId()) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
pam, err := s.updatePwInRepo(ctx, scopeId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrap(err, op)
|
||||
@@ -563,7 +565,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
}
|
||||
am = pam
|
||||
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
oam, dr, err := s.updateOidcInRepo(ctx, scopeId, req)
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrap(err, op)
|
||||
@@ -583,14 +585,14 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
var rows int
|
||||
var dErr error
|
||||
switch auth.SubtypeFromId(id) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, op)
|
||||
}
|
||||
rows, dErr = repo.DeleteAuthMethod(ctx, scopeId, id)
|
||||
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, op)
|
||||
@@ -612,7 +614,7 @@ func (s Service) changeStateInRepo(ctx context.Context, req *pbs.ChangeStateRequ
|
||||
const op = "authmethod_service.(Service).changeStateInRepo"
|
||||
|
||||
switch auth.SubtypeFromId(req.GetId()) {
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -649,12 +651,12 @@ func (s Service) changeStateInRepo(ctx context.Context, req *pbs.ChangeStateRequ
|
||||
return nil, errors.New(errors.InvalidParameter, op, "Given auth method type does not support changing state")
|
||||
}
|
||||
|
||||
func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.VerifyResults {
|
||||
func (s Service) authResult(ctx context.Context, id string, a action.Type) requestauth.VerifyResults {
|
||||
const op = "authmethods.(Service).authResult"
|
||||
res := auth.VerifyResults{}
|
||||
res := requestauth.VerifyResults{}
|
||||
|
||||
var parentId string
|
||||
opts := []auth.Option{auth.WithType(resource.AuthMethod), auth.WithAction(a)}
|
||||
opts := []requestauth.Option{requestauth.WithType(resource.AuthMethod), requestauth.WithAction(a)}
|
||||
switch a {
|
||||
case action.List, action.Create:
|
||||
parentId = id
|
||||
@@ -675,7 +677,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
default:
|
||||
var authMeth auth.AuthMethod
|
||||
switch auth.SubtypeFromId(id) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -691,7 +693,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
return res
|
||||
}
|
||||
authMeth = am
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -712,10 +714,10 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
return res
|
||||
}
|
||||
parentId = authMeth.GetScopeId()
|
||||
opts = append(opts, auth.WithId(id))
|
||||
opts = append(opts, requestauth.WithId(id))
|
||||
}
|
||||
opts = append(opts, auth.WithScopeId(parentId))
|
||||
return auth.Verify(ctx, opts...)
|
||||
opts = append(opts, requestauth.WithScopeId(parentId))
|
||||
return requestauth.Verify(ctx, opts...)
|
||||
}
|
||||
|
||||
func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.Option) (*pb.AuthMethod, error) {
|
||||
@@ -762,7 +764,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
switch i := in.(type) {
|
||||
case *password.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = auth.PasswordSubtype.String()
|
||||
out.Type = password.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -777,7 +779,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
out.Attributes = st
|
||||
case *oidc.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = auth.OidcSubtype.String()
|
||||
out.Type = oidc.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -861,12 +863,12 @@ func validateCreateRequest(req *pbs.CreateAuthMethodRequest) error {
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch auth.SubtypeFromType(req.GetItem().GetType()) {
|
||||
case auth.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
attrs := &pb.PasswordAuthMethodAttributes{}
|
||||
if err := handlers.StructToProto(req.GetItem().GetAttributes(), attrs); err != nil {
|
||||
badFields[attributesField] = "Attribute fields do not match the expected format."
|
||||
}
|
||||
case auth.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
attrs := &pb.OidcAuthMethodAttributes{}
|
||||
if err := handlers.StructToProto(req.GetItem().GetAttributes(), attrs); err != nil {
|
||||
badFields[attributesField] = "Attribute fields do not match the expected format."
|
||||
@@ -942,7 +944,7 @@ func validateCreateRequest(req *pbs.CreateAuthMethodRequest) error {
|
||||
}
|
||||
}
|
||||
default:
|
||||
badFields[typeField] = fmt.Sprintf("This is a required field and must be %q.", auth.PasswordSubtype.String())
|
||||
badFields[typeField] = fmt.Sprintf("This is a required field and must be %q.", password.Subtype.String())
|
||||
}
|
||||
return badFields
|
||||
})
|
||||
@@ -959,16 +961,16 @@ func validateUpdateRequest(req *pbs.UpdateAuthMethodRequest) error {
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch auth.SubtypeFromId(req.GetId()) {
|
||||
case auth.PasswordSubtype:
|
||||
if req.GetItem().GetType() != "" && auth.SubtypeFromType(req.GetItem().GetType()) != auth.PasswordSubtype {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && auth.SubtypeFromType(req.GetItem().GetType()) != password.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := &pb.PasswordAuthMethodAttributes{}
|
||||
if err := handlers.StructToProto(req.GetItem().GetAttributes(), attrs); err != nil {
|
||||
badFields[attributesField] = "Attribute fields do not match the expected format."
|
||||
}
|
||||
case auth.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && auth.SubtypeFromType(req.GetItem().GetType()) != auth.OidcSubtype {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && auth.SubtypeFromType(req.GetItem().GetType()) != oidc.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := &pb.OidcAuthMethodAttributes{}
|
||||
@@ -1111,8 +1113,8 @@ func validateChangeStateRequest(req *pbs.ChangeStateRequest) error {
|
||||
if req == nil {
|
||||
return errors.New(errors.InvalidParameter, op, "Missing request")
|
||||
}
|
||||
if st := auth.SubtypeFromId(req.GetId()); st != auth.OidcSubtype {
|
||||
return handlers.NotFoundErrorf("This endpoint is only available for the %q Auth Method type.", auth.OidcSubtype.String())
|
||||
if st := auth.SubtypeFromId(req.GetId()); st != oidc.Subtype {
|
||||
return handlers.NotFoundErrorf("This endpoint is only available for the %q Auth Method type.", oidc.Subtype.String())
|
||||
}
|
||||
badFields := make(map[string]string)
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1147,7 +1149,7 @@ func validateAuthenticateRequest(req *pbs.AuthenticateRequest) error {
|
||||
} else {
|
||||
st := auth.SubtypeFromId(req.GetAuthMethodId())
|
||||
switch st {
|
||||
case auth.PasswordSubtype, auth.OidcSubtype:
|
||||
case password.Subtype, oidc.Subtype:
|
||||
default:
|
||||
badFields[authMethodIdField] = "Unknown auth method type."
|
||||
}
|
||||
@@ -1234,7 +1236,7 @@ func (s Service) ConvertInternalAuthTokenToApiAuthToken(ctx context.Context, tok
|
||||
return prot, nil
|
||||
}
|
||||
|
||||
func (s Service) convertToAuthenticateResponse(ctx context.Context, req *pbs.AuthenticateRequest, authResults *auth.VerifyResults, tok *pba.AuthToken) (*pbs.AuthenticateResponse, error) {
|
||||
func (s Service) convertToAuthenticateResponse(ctx context.Context, req *pbs.AuthenticateRequest, authResults *requestauth.VerifyResults, tok *pba.AuthToken) (*pbs.AuthenticateResponse, error) {
|
||||
const op = "authmethod.convertToAuthenticateResponse"
|
||||
if req == nil {
|
||||
return nil, errors.New(errors.InvalidParameter, op, "Missing request.")
|
||||
@@ -1255,7 +1257,7 @@ func (s Service) convertToAuthenticateResponse(ctx context.Context, req *pbs.Aut
|
||||
ScopeId: authResults.Scope.Id,
|
||||
Type: resource.AuthToken,
|
||||
}
|
||||
tok.AuthorizedActions = authResults.FetchActionSetForId(ctx, tok.Id, authtokens.IdActions, auth.WithResource(res)).Strings()
|
||||
tok.AuthorizedActions = authResults.FetchActionSetForId(ctx, tok.Id, authtokens.IdActions, requestauth.WithResource(res)).Strings()
|
||||
retAttrs, err := handlers.ProtoToStruct(tok)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/internal/auth"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
@@ -20,6 +19,7 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
requestauth "github.com/hashicorp/boundary/internal/servers/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers/authmethods"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
@@ -120,7 +120,7 @@ func TestGet(t *testing.T) {
|
||||
ScopeId: oidcam.GetScopeId(),
|
||||
CreatedTime: oidcam.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: oidcam.UpdateTime.GetTimestamp(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://alice.com"),
|
||||
"client_id": structpb.NewStringValue("alice_rp"),
|
||||
@@ -187,7 +187,7 @@ func TestGet(t *testing.T) {
|
||||
s, err := authmethods.NewService(kmsCache, pwRepoFn, oidcRepoFn, iamRepoFn, atRepoFn)
|
||||
require.NoError(err, "Couldn't create new auth_method service.")
|
||||
|
||||
got, gErr := s.GetAuthMethod(auth.DisabledAuthTestContext(iamRepoFn, tc.scopeId), tc.req)
|
||||
got, gErr := s.GetAuthMethod(requestauth.DisabledAuthTestContext(iamRepoFn, tc.scopeId), tc.req)
|
||||
if tc.err != nil {
|
||||
require.Error(gErr)
|
||||
assert.True(errors.Is(gErr, tc.err), "GetAuthMethod(%+v) got error %v, wanted %v", tc.req, gErr, tc.err)
|
||||
@@ -240,7 +240,7 @@ func TestList(t *testing.T) {
|
||||
UpdatedTime: oidcam.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: oWithAuthMethods.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 2,
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://alice.com"),
|
||||
"client_id": structpb.NewStringValue("alice_rp"),
|
||||
@@ -354,7 +354,7 @@ func TestList(t *testing.T) {
|
||||
require.NoError(err, "Couldn't create new auth_method service.")
|
||||
|
||||
// First check with non-anonymous user
|
||||
got, gErr := s.ListAuthMethods(auth.DisabledAuthTestContext(iamRepoFn, tc.req.GetScopeId()), tc.req)
|
||||
got, gErr := s.ListAuthMethods(requestauth.DisabledAuthTestContext(iamRepoFn, tc.req.GetScopeId()), tc.req)
|
||||
if tc.err != nil {
|
||||
require.Error(gErr)
|
||||
assert.True(errors.Is(gErr, tc.err), "ListAuthMethods() for scope %q got error %v, wanted %v", tc.req.GetScopeId(), gErr, tc.err)
|
||||
@@ -371,7 +371,7 @@ func TestList(t *testing.T) {
|
||||
assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform()), "ListAuthMethods() for scope %q got response %q, wanted %q", tc.req.GetScopeId(), got, tc.res)
|
||||
|
||||
// Now check with anonymous user
|
||||
got, gErr = s.ListAuthMethods(auth.DisabledAuthTestContext(iamRepoFn, tc.req.GetScopeId(), auth.WithUserId(auth.AnonymousUserId)), tc.req)
|
||||
got, gErr = s.ListAuthMethods(requestauth.DisabledAuthTestContext(iamRepoFn, tc.req.GetScopeId(), requestauth.WithUserId(requestauth.AnonymousUserId)), tc.req)
|
||||
require.NoError(gErr)
|
||||
assert.Len(got.Items, len(tc.res.Items))
|
||||
for _, g := range got.GetItems() {
|
||||
@@ -450,7 +450,7 @@ func TestDelete(t *testing.T) {
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
got, gErr := s.DeleteAuthMethod(auth.DisabledAuthTestContext(iamRepoFn, o.GetPublicId()), tc.req)
|
||||
got, gErr := s.DeleteAuthMethod(requestauth.DisabledAuthTestContext(iamRepoFn, o.GetPublicId()), tc.req)
|
||||
if tc.err != nil {
|
||||
require.Error(gErr)
|
||||
assert.True(errors.Is(gErr, tc.err), "DeleteAuthMethod(%+v) got error %v, wanted %v", tc.req, gErr, tc.err)
|
||||
@@ -489,9 +489,9 @@ func TestDelete_twice(t *testing.T) {
|
||||
req := &pbs.DeleteAuthMethodRequest{
|
||||
Id: am.GetPublicId(),
|
||||
}
|
||||
_, gErr := s.DeleteAuthMethod(auth.DisabledAuthTestContext(iamRepoFn, o.GetPublicId()), req)
|
||||
_, gErr := s.DeleteAuthMethod(requestauth.DisabledAuthTestContext(iamRepoFn, o.GetPublicId()), req)
|
||||
assert.NoError(gErr, "First attempt")
|
||||
_, gErr = s.DeleteAuthMethod(auth.DisabledAuthTestContext(iamRepoFn, o.GetPublicId()), req)
|
||||
_, gErr = s.DeleteAuthMethod(requestauth.DisabledAuthTestContext(iamRepoFn, o.GetPublicId()), req)
|
||||
assert.Error(gErr, "Second attempt")
|
||||
assert.True(errors.Is(gErr, handlers.ApiErrorWithCode(codes.NotFound)), "Expected permission denied for the second delete.")
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid OIDC AuthMethod",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
@@ -590,7 +590,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: o.GetType(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/"),
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
@@ -650,7 +650,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a global OIDC AuthMethod",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: scope.Global.String(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url"),
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
@@ -668,7 +668,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: scope.Global.String(), Type: scope.Global.String(), Name: scope.Global.String(), Description: "Global Scope"},
|
||||
Version: 1,
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url"),
|
||||
@@ -696,7 +696,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: auth.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -706,7 +706,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: auth.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -715,7 +715,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify IsPrimary",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
IsPrimary: true,
|
||||
}},
|
||||
res: nil,
|
||||
@@ -726,7 +726,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: auth.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -747,7 +747,7 @@ func TestCreate(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "Attributes must be valid for type"},
|
||||
Description: &wrapperspb.StringValue{Value: "Attributes must be valid for type"},
|
||||
Type: auth.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"invalid_field": structpb.NewStringValue("invalid_value"),
|
||||
"min_login_name_length": structpb.NewNumberValue(3),
|
||||
@@ -762,7 +762,7 @@ func TestCreate(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "Attributes must be valid for type"},
|
||||
Description: &wrapperspb.StringValue{Value: "Attributes must be valid for type"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"login-name": structpb.NewStringValue("invalid_value"),
|
||||
"password": structpb.NewNumberValue(3),
|
||||
@@ -775,7 +775,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Doesn't Require Issuer",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
@@ -791,7 +791,7 @@ func TestCreate(t *testing.T) {
|
||||
UpdatedTime: defaultAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: o.GetType(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
@@ -807,7 +807,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires ApiUrl",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
"client_secret": structpb.NewStringValue("secret"),
|
||||
@@ -819,7 +819,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires Client Id",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -832,7 +832,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires Client Secret",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -845,7 +845,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify client secret hmac",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -860,7 +860,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify state",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -875,7 +875,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Must Match Standard Alg Names",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example2.discovery.url:4821"),
|
||||
@@ -893,7 +893,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod API Urls Prefix Format",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://example2.discovery.url:4821"),
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
@@ -907,7 +907,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Callback Url Read Only",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue("https://example2.discovery.url:4821"),
|
||||
"client_id": structpb.NewStringValue("someclientid"),
|
||||
@@ -921,7 +921,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod unparseable certificates",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example2.discovery.url:4821"),
|
||||
@@ -939,7 +939,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify default claims scopes of openid",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"api_url_prefix": structpb.NewStringValue("https://api.com"),
|
||||
"issuer": structpb.NewStringValue("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -961,7 +961,7 @@ func TestCreate(t *testing.T) {
|
||||
s, err := authmethods.NewService(kms, pwRepoFn, oidcRepoFn, iamRepoFn, atRepoFn)
|
||||
require.NoError(err, "Error when getting new auth_method service.")
|
||||
|
||||
got, gErr := s.CreateAuthMethod(auth.DisabledAuthTestContext(iamRepoFn, tc.req.GetItem().GetScopeId()), tc.req)
|
||||
got, gErr := s.CreateAuthMethod(requestauth.DisabledAuthTestContext(iamRepoFn, tc.req.GetItem().GetScopeId()), tc.req)
|
||||
if tc.err != nil {
|
||||
require.Error(gErr)
|
||||
assert.True(errors.Is(gErr, tc.err), "CreateAuthMethod(%+v) got error %v, wanted %v", tc.req, gErr, tc.err)
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/auth"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
oidcstore "github.com/hashicorp/boundary/internal/auth/oidc/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -53,7 +53,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[auth.OidcSubtype] = action.ActionSet{
|
||||
IdActions[oidc.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/internal/auth"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
@@ -26,6 +25,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers/authmethods"
|
||||
@@ -305,7 +305,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: wrapperspb.String("default"),
|
||||
Description: wrapperspb.String("default"),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultAttributeFields(),
|
||||
},
|
||||
@@ -345,7 +345,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -353,7 +353,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultReadAttributeFields(),
|
||||
},
|
||||
@@ -372,7 +372,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -380,7 +380,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultReadAttributeFields(),
|
||||
},
|
||||
@@ -412,7 +412,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -484,7 +484,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"name", "type"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Type: auth.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -513,7 +513,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultReadAttributeFields(),
|
||||
},
|
||||
@@ -537,7 +537,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultReadAttributeFields(),
|
||||
},
|
||||
@@ -563,7 +563,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultReadAttributeFields(),
|
||||
},
|
||||
@@ -589,7 +589,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: defaultReadAttributeFields(),
|
||||
},
|
||||
@@ -661,7 +661,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Paths: []string{"type"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: nil,
|
||||
@@ -716,7 +716,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -749,7 +749,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -782,7 +782,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -830,7 +830,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -867,7 +867,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -906,7 +906,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -945,7 +945,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -1037,7 +1037,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{
|
||||
Fields: func() map[string]*structpb.Value {
|
||||
f := defaultReadAttributeFields()
|
||||
@@ -1172,7 +1172,7 @@ func TestUpdate_OIDCDryRun(t *testing.T) {
|
||||
CreatedTime: am.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: am.GetUpdateTime().GetTimestamp(),
|
||||
Version: am.GetVersion(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions,
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
@@ -1353,7 +1353,7 @@ func TestChangeState_OIDC(t *testing.T) {
|
||||
ScopeId: oidcam.GetScopeId(),
|
||||
CreatedTime: oidcam.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: oidcam.UpdateTime.GetTimestamp(),
|
||||
Type: auth.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
|
||||
"issuer": structpb.NewStringValue(oidcam.GetIssuer()),
|
||||
"client_id": structpb.NewStringValue(tpClientId),
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/auth"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pwstore "github.com/hashicorp/boundary/internal/auth/password/store"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
|
||||
pba "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -32,7 +32,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[auth.PasswordSubtype] = action.ActionSet{
|
||||
IdActions[password.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/internal/auth"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
@@ -18,6 +17,7 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/servers/controller/handlers/authmethods"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
|
||||
Reference in new issue
Block a user