Revert 0bf60996c5 (#3990)
Post-merge some issues were discovered with the ways typing is used for proto reflection. This will be reworked without moving the subtypes around.
This commit is contained in:
1 parent
4239f6d4a9
commit
a9e372930d
84 files changed
+1900
-1557
No files matched your search
@@ -64,7 +64,7 @@ const (
|
||||
var (
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = make(map[globals.Subtype]action.ActionSet)
|
||||
IdActions = make(map[subtypes.Subtype]action.ActionSet)
|
||||
|
||||
// CollectionActions contains the set of actions that can be performed on
|
||||
// this collection
|
||||
@@ -425,15 +425,15 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
if err := validateAuthenticatePasswordRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
if err := validateAuthenticateOidcRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
if err := validateAuthenticateLdapRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -445,12 +445,12 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
return s.authenticatePassword(ctx, req, &authResults)
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
return s.authenticateOidc(ctx, req, &authResults)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
return s.authenticateLdap(ctx, req, &authResults)
|
||||
}
|
||||
return nil, errors.New(ctx, errors.Internal, op, "Invalid auth method subtype not caught in validation function.")
|
||||
@@ -460,21 +460,21 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.AuthMethod, e
|
||||
var lookupErr error
|
||||
var am auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
am, lookupErr = repo.LookupAuthMethod(ctx, id)
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
am, lookupErr = repo.LookupAuthMethod(ctx, id)
|
||||
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -550,7 +550,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
const op = "authmethods.(Service).createInRepo"
|
||||
var out auth.AuthMethod
|
||||
switch subtypes.SubtypeFromType(domain, item.GetType()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
am, err := s.createPwInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -559,7 +559,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 globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
am, err := s.createOidcInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -568,7 +568,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 globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
am, err := s.createLdapInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -588,7 +588,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
var dryRun bool
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.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(ctx, err, op)
|
||||
@@ -598,7 +598,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
}
|
||||
am = pam
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
oam, dr, err := s.updateOidcInRepo(ctx, scopeId, req)
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrap(ctx, err, op)
|
||||
@@ -609,7 +609,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
am = oam
|
||||
dryRun = dr
|
||||
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
lam, err := s.updateLdapInRepo(ctx, scopeId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
_, apiErr := err.(*handlers.ApiError)
|
||||
@@ -636,20 +636,20 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
var rows int
|
||||
var dErr error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
rows, dErr = repo.DeleteAuthMethod(ctx, scopeId, id)
|
||||
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
rows, dErr = repo.DeleteAuthMethod(ctx, id)
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
@@ -673,7 +673,7 @@ func (s Service) changeStateInRepo(ctx context.Context, req *pbs.ChangeStateRequ
|
||||
const op = "authmethod_service.(Service).changeStateInRepo"
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -732,7 +732,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
default:
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -748,7 +748,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
return res
|
||||
}
|
||||
authMeth = am
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -764,7 +764,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
return res
|
||||
}
|
||||
authMeth = am
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
repo, err := s.ldapRepoFn()
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
@@ -835,7 +835,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 = globals.PasswordSubtype.String()
|
||||
out.Type = password.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -848,7 +848,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
}
|
||||
case *oidc.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.OidcSubtype.String()
|
||||
out.Type = oidc.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -886,7 +886,7 @@ func toAuthMethodProto(ctx context.Context, in auth.AuthMethod, opt ...handlers.
|
||||
}
|
||||
case *ldap.AuthMethod:
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = globals.LdapSubtype.String()
|
||||
out.Type = ldap.Subtype.String()
|
||||
}
|
||||
if !outputFields.Has(globals.AttributesField) {
|
||||
break
|
||||
@@ -988,9 +988,9 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
// Password attributes are not required when creating a password auth method.
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
attrs := req.GetItem().GetOidcAuthMethodsAttributes()
|
||||
if attrs == nil {
|
||||
// OIDC attributes are required when creating an OIDC auth method.
|
||||
@@ -1066,13 +1066,13 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
if len(req.GetItem().GetLdapAuthMethodsAttributes().GetUrls()) == 0 {
|
||||
badFields[urlsField] = "At least one URL is required"
|
||||
}
|
||||
validateLdapAttributes(ctx, req.GetItem().GetLdapAuthMethodsAttributes(), badFields)
|
||||
default:
|
||||
badFields[typeField] = fmt.Sprintf("This is a required field and must be %q.", globals.PasswordSubtype.String())
|
||||
badFields[typeField] = fmt.Sprintf("This is a required field and must be %q.", password.Subtype.String())
|
||||
}
|
||||
return badFields
|
||||
})
|
||||
@@ -1089,12 +1089,12 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case globals.PasswordSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.PasswordSubtype {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != password.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.OidcSubtype {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != oidc.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetOidcAuthMethodsAttributes()
|
||||
@@ -1197,8 +1197,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != globals.LdapSubtype {
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != ldap.Subtype {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
validateLdapAttributes(ctx, req.GetItem().GetLdapAuthMethodsAttributes(), badFields)
|
||||
@@ -1241,8 +1241,8 @@ func validateChangeStateRequest(ctx context.Context, req *pbs.ChangeStateRequest
|
||||
if req == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "Missing request")
|
||||
}
|
||||
if st := subtypes.SubtypeFromId(domain, req.GetId()); st != globals.OidcSubtype {
|
||||
return handlers.NotFoundErrorf("This endpoint is only available for the %q Auth Method type.", globals.OidcSubtype.String())
|
||||
if st := subtypes.SubtypeFromId(domain, 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 {
|
||||
@@ -1278,7 +1278,7 @@ func validateAuthenticateRequest(ctx context.Context, req *pbs.AuthenticateReque
|
||||
} else {
|
||||
st := subtypes.SubtypeFromId(domain, req.GetAuthMethodId())
|
||||
switch st {
|
||||
case globals.PasswordSubtype, globals.OidcSubtype, globals.LdapSubtype:
|
||||
case password.Subtype, oidc.Subtype, ldap.Subtype:
|
||||
default:
|
||||
badFields[authMethodIdField] = "Unknown auth method type."
|
||||
}
|
||||
@@ -1381,7 +1381,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
return nil
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, authRequest.GetAuthMethodId()) {
|
||||
case globals.PasswordSubtype:
|
||||
case password.Subtype:
|
||||
newAttrs := &pbs.PasswordLoginAttributes{}
|
||||
if err := handlers.StructToProto(attrs, newAttrs); err != nil {
|
||||
return err
|
||||
@@ -1389,7 +1389,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
authRequest.Attrs = &pbs.AuthenticateRequest_PasswordLoginAttributes{
|
||||
PasswordLoginAttributes: newAttrs,
|
||||
}
|
||||
case globals.OidcSubtype:
|
||||
case oidc.Subtype:
|
||||
switch authRequest.GetCommand() {
|
||||
case startCommand:
|
||||
newAttrs := &pbs.OidcStartAttributes{}
|
||||
@@ -1418,7 +1418,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
default:
|
||||
return fmt.Errorf("%s: unknown command %q", op, authRequest.GetCommand())
|
||||
}
|
||||
case globals.LdapSubtype:
|
||||
case ldap.Subtype:
|
||||
newAttrs := &pbs.LdapLoginAttributes{}
|
||||
if err := handlers.StructToProto(attrs, newAttrs); err != nil {
|
||||
return err
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestGet(t *testing.T) {
|
||||
ScopeId: oidcam.GetScopeId(),
|
||||
CreatedTime: oidcam.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: oidcam.UpdateTime.GetTimestamp(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://alice.com"),
|
||||
@@ -183,7 +183,7 @@ func TestGet(t *testing.T) {
|
||||
ScopeId: ldapAm.GetScopeId(),
|
||||
CreatedTime: ldapAm.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: ldapAm.UpdateTime.GetTimestamp(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.InactiveState),
|
||||
@@ -313,7 +313,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: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://alice.com"),
|
||||
@@ -376,7 +376,7 @@ func TestList(t *testing.T) {
|
||||
UpdatedTime: ldapAm.GetUpdateTime().GetTimestamp(),
|
||||
Scope: &scopepb.ScopeInfo{Id: oWithAuthMethods.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
Version: 1,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.ActivePublicState),
|
||||
@@ -713,7 +713,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a valid OIDC AuthMethod",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example.discovery.url:4821/.well-known/openid-configuration/"),
|
||||
@@ -736,7 +736,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: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example.discovery.url:4821/"),
|
||||
@@ -759,7 +759,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "create-a-valid-ldap-auth-method",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
StartTls: true,
|
||||
@@ -796,7 +796,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: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.InactiveState),
|
||||
@@ -863,7 +863,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Create a global OIDC AuthMethod",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: scope.Global.String(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example.discovery.url"),
|
||||
@@ -883,7 +883,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: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -902,7 +902,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "create-a-global-ldap-auth-method",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: scope.Global.String(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1", "ldaps://ldap1"},
|
||||
@@ -920,7 +920,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: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
State: string(ldap.InactiveState),
|
||||
@@ -949,7 +949,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
CreatedTime: timestamppb.Now(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -959,7 +959,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -968,7 +968,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify IsPrimary",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
IsPrimary: true,
|
||||
}},
|
||||
res: nil,
|
||||
@@ -979,7 +979,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
UpdatedTime: timestamppb.Now(),
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -998,7 +998,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Doesn't Require Issuer",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1016,7 +1016,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: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1034,7 +1034,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires ApiUrl",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ClientId: wrapperspb.String("someclientid"),
|
||||
@@ -1048,7 +1048,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires Client Id",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1063,7 +1063,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Requires Client Secret",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1078,7 +1078,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify client secret hmac",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1095,7 +1095,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod cant specify state",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1112,7 +1112,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Must Match Standard Alg Names",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1129,7 +1129,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod API Urls Prefix Format",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example2.discovery.url:4821"),
|
||||
@@ -1145,7 +1145,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod Callback Url Read Only",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String("https://example2.discovery.url:4821"),
|
||||
@@ -1161,7 +1161,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "OIDC AuthMethod unparseable certificates",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1178,7 +1178,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: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
ApiUrlPrefix: wrapperspb.String("https://api.com"),
|
||||
@@ -1195,7 +1195,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-requires-urls",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{},
|
||||
},
|
||||
@@ -1207,7 +1207,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-urls",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1", "not-ldap-scheme://ldap2"},
|
||||
@@ -1221,7 +1221,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-deref-aliases",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1236,7 +1236,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-cert",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1251,7 +1251,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-bind-dn",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1265,7 +1265,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-bind-password",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1279,7 +1279,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-client-cert",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1295,7 +1295,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-client-cert-key",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1311,7 +1311,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-client-cert-key-not-a-key",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1327,7 +1327,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-client-cert-key",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1342,7 +1342,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-missing-client-cert",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
@@ -1357,7 +1357,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "ldap-auth-method-invalid-attribute-map",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldap://ldap1"},
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/ldap"
|
||||
ldapstore "github.com/hashicorp/boundary/internal/auth/ldap/store"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
@@ -37,7 +36,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[globals.LdapSubtype] = action.ActionSet{
|
||||
IdActions[ldap.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
@@ -96,7 +96,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: wrapperspb.String("default"),
|
||||
Description: wrapperspb.String("default"),
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: attrs,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
@@ -129,7 +129,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -138,7 +138,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Version: 2,
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -155,7 +155,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -164,7 +164,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -213,7 +213,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"name", "type"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Type: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -245,7 +245,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Version: 2,
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -268,7 +268,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -296,7 +296,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -326,7 +326,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -351,7 +351,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: ldapAuthorizedActions,
|
||||
@@ -387,7 +387,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -448,7 +448,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -547,7 +547,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Paths: []string{"type"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: nil,
|
||||
@@ -609,7 +609,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -643,7 +643,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap2", "ldaps://ldap3"},
|
||||
@@ -696,7 +696,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -733,7 +733,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
@@ -788,7 +788,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
Version: 2,
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.LdapSubtype.String(),
|
||||
Type: ldap.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_LdapAuthMethodsAttributes{
|
||||
LdapAuthMethodsAttributes: &pb.LdapAuthMethodAttributes{
|
||||
Urls: []string{"ldaps://ldap1"},
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
oidcstore "github.com/hashicorp/boundary/internal/auth/oidc/store"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
@@ -57,7 +56,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[globals.OidcSubtype] = action.ActionSet{
|
||||
IdActions[oidc.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
@@ -311,7 +311,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: wrapperspb.String("default"),
|
||||
Description: wrapperspb.String("default"),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultAttributes,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
@@ -351,7 +351,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -359,7 +359,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -376,7 +376,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: &pbs.UpdateAuthMethodResponse{
|
||||
@@ -384,7 +384,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -412,7 +412,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.Issuer = wrapperspb.String("http://localhost:72759/somepath/")
|
||||
@@ -481,7 +481,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: globals.PasswordSubtype.String(),
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -510,7 +510,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -532,7 +532,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -556,7 +556,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "updated"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -580,7 +580,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "notignored"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: defaultReadAttributes,
|
||||
Scope: defaultScopeInfo,
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
@@ -650,7 +650,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Paths: []string{"type"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
},
|
||||
res: nil,
|
||||
@@ -705,7 +705,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.MaxAge = wrapperspb.UInt32(0)
|
||||
@@ -736,7 +736,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.MaxAge = wrapperspb.UInt32(4)
|
||||
@@ -767,7 +767,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.ClientId = wrapperspb.String("new id")
|
||||
@@ -814,7 +814,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.ApiUrlPrefix = wrapperspb.String("https://callback.prefix:9281/path")
|
||||
@@ -846,7 +846,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.AllowedAudiences = []string{"bar", "foo"}
|
||||
@@ -877,7 +877,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.ClaimsScopes = []string{"email", "profile"}
|
||||
@@ -908,7 +908,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.AccountClaimMaps = []string{"display_name=name"}
|
||||
@@ -982,7 +982,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
ScopeId: o.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "default"},
|
||||
Description: &wrapperspb.StringValue{Value: "default"},
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: func() *pb.AuthMethod_OidcAuthMethodsAttributes {
|
||||
f := proto.Clone(defaultReadAttributes.OidcAuthMethodsAttributes).(*pb.OidcAuthMethodAttributes)
|
||||
f.SigningAlgorithms = []string{string(oidc.EdDSA)}
|
||||
@@ -1115,7 +1115,7 @@ func TestUpdate_OIDCDryRun(t *testing.T) {
|
||||
CreatedTime: am.GetCreateTime().GetTimestamp(),
|
||||
UpdatedTime: am.GetUpdateTime().GetTimestamp(),
|
||||
Version: am.GetVersion(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthorizedActions: oidcAuthorizedActions,
|
||||
AuthorizedCollectionActions: authorizedCollectionActions,
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
@@ -1289,7 +1289,7 @@ func TestChangeState_OIDC(t *testing.T) {
|
||||
ScopeId: oidcam.GetScopeId(),
|
||||
CreatedTime: oidcam.CreateTime.GetTimestamp(),
|
||||
UpdatedTime: oidcam.UpdateTime.GetTimestamp(),
|
||||
Type: globals.OidcSubtype.String(),
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.AuthMethod_OidcAuthMethodsAttributes{
|
||||
OidcAuthMethodsAttributes: &pb.OidcAuthMethodAttributes{
|
||||
Issuer: wrapperspb.String(oidcam.GetIssuer()),
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pwstore "github.com/hashicorp/boundary/internal/auth/password/store"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
@@ -37,7 +36,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
IdActions[globals.PasswordSubtype] = action.ActionSet{
|
||||
IdActions[password.Subtype] = action.ActionSet{
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
action.Update,
|
||||
|
||||
Reference in new issue
Block a user