Migrate user name to login name (#255)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-11 17:25:00 -04:00
1 parent 6f886976e4
commit 4cfab04307
50 files changed
+528 -527

No files matched your search

+5 -5
View File
@@ -112,7 +112,7 @@ Start the server binary with:
This will start a Controller service listening on `http://127.0.0.1:9200` for
incoming API requests and a Worker service listening on the same address/port for
incoming session requests. It will also create various default Catalogs and Sets,
and display various bits of information, such as a username and password that can
and display various bits of information, such as a login name and password that can
be used to log in.
### Configuring Resources
@@ -132,9 +132,9 @@ you suitable for local testing:
* A Host Catalog with a default Host Set containing the local machine
(`127.0.0.1`) and defining an SSH service on port 22
* A User Catalog with a default User Set containing a user with the given
username and associated password. This can be used to log in to the web UI
and the desktop client.
* A Password User Method with a default User Set containing a user with the
given login name and associated password. This can be used to log in to the
web UI and the desktop client.
* A Permissions Set mapping the given User Set to a set of permissions, in this
case granting access to make connections to resources
* A Credentials Catalog with a default Credential Set that is empty (meaning
@@ -161,7 +161,7 @@ input/knowledge.
Next, let's actually make a connection to your local SSH daemon via Boundary:
3. Start the desktop client and point it at the local Boundary `dev` session.
Log in with the generated username and password.
Log in with the generated login name and password.
4. You can now select the Target that grants access to the local machine and
hit "Request Session". Doing so will cause Boundary to check whether this
action is allowed, and if so, send session information back to the client,
+2 -2
View File
@@ -19,8 +19,8 @@ func (c *authmethodsClient) Authenticate(ctx context.Context, authMethodId, name
reqBody := map[string]interface{}{
"credentials": map[string]string{
"name": name,
"password": password,
"login_name": name,
"password": password,
},
}
+3 -2
View File
@@ -6,6 +6,7 @@ import (
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -16,7 +17,7 @@ func TestAuthenticate(t *testing.T) {
tc := controller.NewTestController(t, &controller.TestControllerOpts{
DisableAuthorizationFailures: true,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -26,7 +27,7 @@ func TestAuthenticate(t *testing.T) {
tok, apiErr, err := methods.Authenticate(tc.Context(), amId, "user", "passpass")
require.NoError(err)
assert.Nil(apiErr)
assert.Nil(apiErr, pretty.Sprint(apiErr))
assert.NotNil(tok)
_, apiErr, err = methods.Authenticate(tc.Context(), amId, "user", "wrong")
+48 -48
View File
@@ -89,6 +89,54 @@ func DefaultDisabled() Option {
}
}
func WithPasswordAccountLoginName(inLoginName string) Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["login_name"] = inLoginName
o.valueMap["attributes"] = val
}
}
func DefaultPasswordAccountLoginName() Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["login_name"] = nil
o.valueMap["attributes"] = val
}
}
func WithPasswordAuthMethodMinLoginNameLength(inMinLoginNameLength uint32) Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["min_login_name_length"] = inMinLoginNameLength
o.valueMap["attributes"] = val
}
}
func DefaultPasswordAuthMethodMinLoginNameLength() Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["min_login_name_length"] = nil
o.valueMap["attributes"] = val
}
}
func WithPasswordAuthMethodMinPasswordLength(inMinPasswordLength uint32) Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
@@ -113,30 +161,6 @@ func DefaultPasswordAuthMethodMinPasswordLength() Option {
}
}
func WithPasswordAuthMethodMinUserNameLength(inMinUserNameLength uint32) Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["min_user_name_length"] = inMinUserNameLength
o.valueMap["attributes"] = val
}
}
func DefaultPasswordAuthMethodMinUserNameLength() Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["min_user_name_length"] = nil
o.valueMap["attributes"] = val
}
}
func WithName(inName string) Option {
return func(o *options) {
o.valueMap["name"] = inName
@@ -184,27 +208,3 @@ func DefaultType() Option {
o.valueMap["type"] = nil
}
}
func WithPasswordAccountUsername(inUsername string) Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["username"] = inUsername
o.valueMap["attributes"] = val
}
}
func DefaultPasswordAccountUsername() Option {
return func(o *options) {
raw, ok := o.valueMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["username"] = nil
o.valueMap["attributes"] = val
}
}
@@ -2,6 +2,6 @@
package authmethods
type PasswordAccountAttributes struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
LoginName string `json:"login_name,omitempty"`
Password string `json:"password,omitempty"`
}
@@ -2,6 +2,6 @@
package authmethods
type PasswordAuthMethodAttributes struct {
MinUserNameLength uint32 `json:"min_user_name_length,omitempty"`
MinPasswordLength uint32 `json:"min_password_length,omitempty"`
MinLoginNameLength uint32 `json:"min_login_name_length,omitempty"`
MinPasswordLength uint32 `json:"min_password_length,omitempty"`
}
+3 -3
View File
@@ -19,7 +19,7 @@ func TestAuthTokens_List(t *testing.T) {
tc := controller.NewTestController(t, &controller.TestControllerOpts{
DisableAuthorizationFailures: true,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -86,7 +86,7 @@ func TestAuthToken_Crud(t *testing.T) {
tc := controller.NewTestController(t, &controller.TestControllerOpts{
DisableAuthorizationFailures: true,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -121,7 +121,7 @@ func TestAuthToken_Errors(t *testing.T) {
tc := controller.NewTestController(t, &controller.TestControllerOpts{
DisableAuthorizationFailures: true,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
+3 -3
View File
@@ -23,7 +23,7 @@ func TestGroup_List(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -99,7 +99,7 @@ func TestGroup_Crud(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -196,7 +196,7 @@ func TestGroup_Errors(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
+2 -2
View File
@@ -21,7 +21,7 @@ func TestCatalogs_Crud(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -81,7 +81,7 @@ func TestCatalogs_Errors(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
+2 -2
View File
@@ -36,8 +36,8 @@ type structInfo struct {
// Subtype name for types implementing an abstract resource type. This is
// used as text to insert into With/Default function calls to separate out
// implementations of the same abstract type. This way e.g. a WithUsername
// option turns into WithPasswordAccountUsername which is wordy but
// implementations of the same abstract type. This way e.g. a WithLoginName
// option turns into WithPasswordAccountLoginName which is wordy but
// unambiguous. It also switches the behavior of the functions to work on
// the attributes map.
subtypeName string
+4 -4
View File
@@ -26,7 +26,7 @@ func TestCustom(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -144,7 +144,7 @@ func TestRole_List(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -249,7 +249,7 @@ func TestRole_Crud(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -327,7 +327,7 @@ func TestRole_Errors(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
+3 -3
View File
@@ -20,7 +20,7 @@ func TestProjects_List(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -69,7 +69,7 @@ func TestProjects_Crud(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -121,7 +121,7 @@ func TestProject_Errors(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
+3 -3
View File
@@ -21,7 +21,7 @@ func TestUsers_List(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -83,7 +83,7 @@ func TestUser_Crud(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
@@ -136,7 +136,7 @@ func TestUser_Errors(t *testing.T) {
DisableAuthorizationFailures: true,
DefaultOrgId: orgId,
DefaultAuthMethodId: amId,
DefaultUsername: "user",
DefaultLoginName: "user",
DefaultPassword: "passpass",
})
defer tc.Shutdown()
+4 -4
View File
@@ -25,16 +25,16 @@ func allocAccount() Account {
}
}
// NewAccount creates a new in memory Account with userName assigned to
// NewAccount creates a new in memory Account with loginName assigned to
// authMethodId. Name and description are the only valid options. All other
// options are ignored.
func NewAccount(authMethodId string, userName string, opt ...Option) (*Account, error) {
func NewAccount(authMethodId string, loginName string, opt ...Option) (*Account, error) {
// NOTE(mgaffney): The scopeId in the embedded *store.Account is
// populated by a trigger in the database.
if authMethodId == "" {
return nil, fmt.Errorf("new: password account: no auth method id: %w", db.ErrInvalidParameter)
}
if userName == "" {
if loginName == "" {
return nil, fmt.Errorf("new: password account: no user name: %w", db.ErrInvalidParameter)
}
@@ -42,7 +42,7 @@ func NewAccount(authMethodId string, userName string, opt ...Option) (*Account,
a := &Account{
Account: &store.Account{
AuthMethodId: authMethodId,
UserName: userName,
LoginName: loginName,
Name: opts.withName,
Description: opts.withDescription,
},
+8 -8
View File
@@ -21,7 +21,7 @@ func TestAccount_New(t *testing.T) {
type args struct {
authMethodId string
userName string
loginName string
opts []Option
}
@@ -43,12 +43,12 @@ func TestAccount_New(t *testing.T) {
name: "valid-no-options",
args: args{
authMethodId: aut.GetPublicId(),
userName: "kazmierczak",
loginName: "kazmierczak",
},
want: &Account{
Account: &store.Account{
AuthMethodId: aut.GetPublicId(),
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
},
@@ -56,7 +56,7 @@ func TestAccount_New(t *testing.T) {
name: "valid-with-name",
args: args{
authMethodId: aut.GetPublicId(),
userName: "kazmierczak1",
loginName: "kazmierczak1",
opts: []Option{
WithName("test-name"),
},
@@ -64,7 +64,7 @@ func TestAccount_New(t *testing.T) {
want: &Account{
Account: &store.Account{
AuthMethodId: aut.GetPublicId(),
UserName: "kazmierczak1",
LoginName: "kazmierczak1",
Name: "test-name",
},
},
@@ -73,7 +73,7 @@ func TestAccount_New(t *testing.T) {
name: "valid-with-description",
args: args{
authMethodId: aut.GetPublicId(),
userName: "kazmierczak2",
loginName: "kazmierczak2",
opts: []Option{
WithDescription("test-description"),
},
@@ -81,7 +81,7 @@ func TestAccount_New(t *testing.T) {
want: &Account{
Account: &store.Account{
AuthMethodId: aut.GetPublicId(),
UserName: "kazmierczak2",
LoginName: "kazmierczak2",
Description: "test-description",
},
},
@@ -92,7 +92,7 @@ func TestAccount_New(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
got, err := NewAccount(tt.args.authMethodId, tt.args.userName, tt.args.opts...)
got, err := NewAccount(tt.args.authMethodId, tt.args.loginName, tt.args.opts...)
if tt.wantErr {
assert.Error(err)
require.Nil(got)
+6 -6
View File
@@ -24,7 +24,7 @@ func allocAuthMethod() AuthMethod {
// NewAuthMethod creates a new in memory AuthMethod assigned to scopeId.
// Name and description are the only valid options. All other options are
// ignored. MinUserNameLength and MinPasswordLength are pre-set to the
// ignored. MinLoginNameLength and MinPasswordLength are pre-set to the
// default values of 5 and 8 respectively.
func NewAuthMethod(scopeId string, opt ...Option) (*AuthMethod, error) {
if scopeId == "" {
@@ -34,11 +34,11 @@ func NewAuthMethod(scopeId string, opt ...Option) (*AuthMethod, error) {
opts := getOpts(opt...)
a := &AuthMethod{
AuthMethod: &store.AuthMethod{
ScopeId: scopeId,
Name: opts.withName,
Description: opts.withDescription,
MinUserNameLength: 3,
MinPasswordLength: 8,
ScopeId: scopeId,
Name: opts.withName,
Description: opts.withDescription,
MinLoginNameLength: 3,
MinPasswordLength: 8,
},
}
return a, nil
+8 -8
View File
@@ -32,8 +32,8 @@ func TestAuthMethod_New(t *testing.T) {
args: args{},
want: &AuthMethod{
AuthMethod: &store.AuthMethod{
MinUserNameLength: 3,
MinPasswordLength: 8,
MinLoginNameLength: 3,
MinPasswordLength: 8,
},
},
},
@@ -46,9 +46,9 @@ func TestAuthMethod_New(t *testing.T) {
},
want: &AuthMethod{
AuthMethod: &store.AuthMethod{
Name: "test-name",
MinUserNameLength: 3,
MinPasswordLength: 8,
Name: "test-name",
MinLoginNameLength: 3,
MinPasswordLength: 8,
},
},
},
@@ -61,9 +61,9 @@ func TestAuthMethod_New(t *testing.T) {
},
want: &AuthMethod{
AuthMethod: &store.AuthMethod{
Description: "test-description",
MinUserNameLength: 3,
MinPasswordLength: 8,
Description: "test-description",
MinLoginNameLength: 3,
MinPasswordLength: 8,
},
},
},
+2 -2
View File
@@ -4,7 +4,7 @@ const (
authenticateQuery = `
select acct.name, -- Account.Name
acct.description, -- Account.Description
acct.user_name, -- Account.UserName
acct.login_name, -- Account.LoginName
acct.public_id, -- Account.PublicId
acct.auth_method_id, -- Account.AuthMethodId
acct.scope_id, -- Account.ScopeId
@@ -25,7 +25,7 @@ select acct.name, -- Account.Name
auth_password_account acct,
auth_password_method meth
where acct.auth_method_id = $1
and acct.user_name = $2
and acct.login_name = $2
and cred.password_conf_id = conf.private_id
and cred.password_account_id = acct.public_id
and acct.auth_method_id = meth.public_id ;
+18 -18
View File
@@ -17,7 +17,7 @@ import (
// valid AuthMethodId. a must not contain a PublicId. The PublicId is
// generated and assigned by this method.
//
// a must contain a valid UserName. a.UserName must be unique within
// a must contain a valid LoginName. a.LoginName must be unique within
// a.AuthMethodId.
//
// WithPassword is the only valid option. All other options are ignored.
@@ -37,7 +37,7 @@ func (r *Repository) CreateAccount(ctx context.Context, a *Account, opt ...Optio
if a.PublicId != "" {
return nil, fmt.Errorf("create: password account: public id not empty: %w", db.ErrInvalidParameter)
}
if !validUserName(a.UserName) {
if !validLoginName(a.LoginName) {
return nil, fmt.Errorf("create: password account: invalid user name: %w", db.ErrInvalidParameter)
}
@@ -46,8 +46,8 @@ func (r *Repository) CreateAccount(ctx context.Context, a *Account, opt ...Optio
return nil, fmt.Errorf("create: password account: retrieve current configuration: %w", err)
}
if cc.MinUserNameLength > len(a.UserName) {
return nil, fmt.Errorf("create: password account: user name %q: %w", a.UserName, ErrTooShort)
if cc.MinLoginNameLength > len(a.LoginName) {
return nil, fmt.Errorf("create: password account: user name %q: %w", a.LoginName, ErrTooShort)
}
a = a.clone()
@@ -169,13 +169,13 @@ func (r *Repository) DeleteAccount(ctx context.Context, withPublicId string, opt
return rowsDeleted, nil
}
var reInvalidUserName = regexp.MustCompile("[^a-z0-9.]")
var reInvalidLoginName = regexp.MustCompile("[^a-z0-9.]")
func validUserName(u string) bool {
func validLoginName(u string) bool {
if u == "" {
return false
}
return !reInvalidUserName.Match([]byte(u))
return !reInvalidLoginName.Match([]byte(u))
}
// UpdateAccount updates the repository entry for a.PublicId with the
@@ -184,12 +184,12 @@ func validUserName(u string) bool {
// records updated. a is not changed.
//
// a must contain a valid PublicId. Only a.Name, a.Description and
// a.UserName can be updated. If a.Name is set to a non-empty string, it
// must be unique within a.AuthMethodId. If a.UserName is set to a
// a.LoginName can be updated. If a.Name is set to a non-empty string, it
// must be unique within a.AuthMethodId. If a.LoginName is set to a
// non-empty string, it must be unique within a.AuthMethodId.
//
// An attribute of a will be set to NULL in the database if the attribute
// in a is the zero value and it is included in fieldMaskPaths. a.UserName
// in a is the zero value and it is included in fieldMaskPaths. a.LoginName
// cannot be set to NULL.
func (r *Repository) UpdateAccount(ctx context.Context, a *Account, version uint32, fieldMaskPaths []string, opt ...Option) (*Account, int, error) {
if a == nil {
@@ -205,16 +205,16 @@ func (r *Repository) UpdateAccount(ctx context.Context, a *Account, version uint
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: no version supplied: %w", db.ErrInvalidParameter)
}
var changeUserName bool
var changeLoginName bool
for _, f := range fieldMaskPaths {
switch {
case strings.EqualFold("Name", f):
case strings.EqualFold("Description", f):
case strings.EqualFold("UserName", f):
if !validUserName(a.UserName) {
case strings.EqualFold("LoginName", f):
if !validLoginName(a.LoginName) {
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: invalid user name: %w", db.ErrInvalidParameter)
}
changeUserName = true
changeLoginName = true
default:
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: field: %s: %w", f, db.ErrInvalidFieldMask)
}
@@ -224,7 +224,7 @@ func (r *Repository) UpdateAccount(ctx context.Context, a *Account, version uint
map[string]interface{}{
"Name": a.Name,
"Description": a.Description,
"UserName": a.UserName,
"LoginName": a.LoginName,
},
fieldMaskPaths,
)
@@ -232,13 +232,13 @@ func (r *Repository) UpdateAccount(ctx context.Context, a *Account, version uint
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: %w", db.ErrEmptyFieldMask)
}
if changeUserName {
if changeLoginName {
cc, err := r.currentConfigForAccount(ctx, a.PublicId)
if err != nil {
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: retrieve current configuration: %w", err)
}
if cc.MinUserNameLength > len(a.UserName) {
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: user name %q: %w", a.UserName, ErrTooShort)
if cc.MinLoginNameLength > len(a.LoginName) {
return nil, db.NoRowsAffected, fmt.Errorf("update: password account: user name %q: %w", a.LoginName, ErrTooShort)
}
}
@@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/require"
)
func TestCheckUserName(t *testing.T) {
func TestCheckLoginName(t *testing.T) {
var tests = []struct {
in string
want bool
@@ -25,12 +25,12 @@ func TestCheckUserName(t *testing.T) {
{"trailing-spaces ", false},
{"contains spaces", false},
{"NotLowerCase", false},
{"valid.username", true},
{"valid.loginname", true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.in, func(t *testing.T) {
assert.Equal(t, tt.want, validUserName(tt.in))
assert.Equal(t, tt.want, validLoginName(tt.in))
})
}
}
@@ -78,51 +78,51 @@ func TestRepository_CreateAccount(t *testing.T) {
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-username-uppercase",
name: "invalid-loginname-uppercase",
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "KaZmiErcZak11",
LoginName: "KaZmiErcZak11",
},
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-username-leading-space",
name: "invalid-loginname-leading-space",
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: " kazmierczak12",
LoginName: " kazmierczak12",
},
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-username-trailing-space",
name: "invalid-loginname-trailing-space",
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak13 ",
LoginName: "kazmierczak13 ",
},
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-username-space-in-name",
name: "invalid-loginname-space-in-name",
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmier czak14",
LoginName: "kazmier czak14",
},
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-username-too-short",
name: "invalid-loginname-too-short",
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "ka",
LoginName: "ka",
},
},
wantIsErr: ErrTooShort,
@@ -132,7 +132,7 @@ func TestRepository_CreateAccount(t *testing.T) {
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak123",
LoginName: "kazmierczak123",
},
},
opts: []Option{
@@ -145,13 +145,13 @@ func TestRepository_CreateAccount(t *testing.T) {
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
want: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
},
@@ -161,14 +161,14 @@ func TestRepository_CreateAccount(t *testing.T) {
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
Name: "test-name-repo",
UserName: "kazmierczak1",
LoginName: "kazmierczak1",
},
},
want: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
Name: "test-name-repo",
UserName: "kazmierczak1",
LoginName: "kazmierczak1",
},
},
},
@@ -178,14 +178,14 @@ func TestRepository_CreateAccount(t *testing.T) {
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
Description: ("test-description-repo"),
UserName: "kazmierczak2",
LoginName: "kazmierczak2",
},
},
want: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
Description: ("test-description-repo"),
UserName: "kazmierczak2",
LoginName: "kazmierczak2",
},
},
},
@@ -194,7 +194,7 @@ func TestRepository_CreateAccount(t *testing.T) {
in: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak3",
LoginName: "kazmierczak3",
},
},
opts: []Option{
@@ -203,7 +203,7 @@ func TestRepository_CreateAccount(t *testing.T) {
want: &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak3",
LoginName: "kazmierczak3",
},
},
},
@@ -235,7 +235,7 @@ func TestRepository_CreateAccount(t *testing.T) {
opts := getOpts(tt.opts...)
if opts.withPassword {
authAcct, err := repo.Authenticate(context.Background(), tt.in.AuthMethodId, tt.in.UserName, opts.password)
authAcct, err := repo.Authenticate(context.Background(), tt.in.AuthMethodId, tt.in.LoginName, opts.password)
require.NoError(err)
assert.NoError(db.TestVerifyOplog(t, rw, authAcct.CredentialId, db.WithOperation(oplog.OpType_OP_TYPE_CREATE), db.WithCreateNotBefore(10*time.Second)))
}
@@ -256,7 +256,7 @@ func TestRepository_CreateAccount(t *testing.T) {
Account: &store.Account{
AuthMethodId: authMethod.GetPublicId(),
Name: "test-name-repo",
UserName: "kazmierczak3",
LoginName: "kazmierczak3",
},
}
@@ -285,8 +285,8 @@ func TestRepository_CreateAccount(t *testing.T) {
authMethoda, authMethodb := authMethods[0], authMethods[1]
in := &Account{
Account: &store.Account{
Name: "test-name-repo",
UserName: "kazmierczak4",
Name: "test-name-repo",
LoginName: "kazmierczak4",
},
}
in2 := in.clone()
@@ -543,9 +543,9 @@ func TestRepository_UpdateAccount(t *testing.T) {
rw := db.New(conn)
wrapper := db.TestWrapper(t)
changeUserName := func(s string) func(*Account) *Account {
changeLoginName := func(s string) func(*Account) *Account {
return func(a *Account) *Account {
a.UserName = s
a.LoginName = s
return a
}
}
@@ -799,52 +799,52 @@ func TestRepository_UpdateAccount(t *testing.T) {
wantCount: 1,
},
{
name: "change-user-name",
name: "change-login-name",
orig: &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
chgFn: changeUserName("mothball"),
masks: []string{"UserName"},
chgFn: changeLoginName("mothball"),
masks: []string{"LoginName"},
want: &Account{
Account: &store.Account{
UserName: "mothball",
LoginName: "mothball",
},
},
wantCount: 1,
},
{
name: "change-user-name-mixed-caps",
name: "change-login-name-mixed-caps",
orig: &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
chgFn: changeUserName("KaZmIeRcZaK"),
masks: []string{"UserName"},
chgFn: changeLoginName("KaZmIeRcZaK"),
masks: []string{"LoginName"},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "change-user-name-to-short",
name: "change-login-name-to-short",
orig: &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
chgFn: changeUserName("ka"),
masks: []string{"UserName"},
chgFn: changeLoginName("ka"),
masks: []string{"LoginName"},
wantIsErr: ErrTooShort,
},
{
name: "delete-user-name",
name: "delete-login-name",
orig: &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
},
chgFn: changeUserName(""),
masks: []string{"UserName"},
chgFn: changeLoginName(""),
masks: []string{"LoginName"},
wantIsErr: db.ErrInvalidParameter,
},
}
@@ -861,8 +861,8 @@ func TestRepository_UpdateAccount(t *testing.T) {
am := TestAuthMethods(t, conn, org.PublicId, 1)[0]
tt.orig.AuthMethodId = am.PublicId
if tt.orig.UserName == "" {
tt.orig.UserName = "kazmierczak"
if tt.orig.LoginName == "" {
tt.orig.LoginName = "kazmierczak"
}
orig, err := repo.CreateAccount(context.Background(), tt.orig)
assert.NoError(err)
@@ -959,7 +959,7 @@ func TestRepository_UpdateAccount(t *testing.T) {
in2 := in.clone()
in.AuthMethodId = ama.PublicId
in.UserName = "kazmierczak"
in.LoginName = "kazmierczak"
got, err := repo.CreateAccount(context.Background(), in)
assert.NoError(err)
require.NotNil(got)
@@ -969,7 +969,7 @@ func TestRepository_UpdateAccount(t *testing.T) {
assert.Equal(in.Description, got.Description)
in2.AuthMethodId = amb.PublicId
in2.UserName = "kazmierczak2"
in2.LoginName = "kazmierczak2"
in2.Name = "first-name"
got2, err := repo.CreateAccount(context.Background(), in2)
assert.NoError(err)
@@ -985,13 +985,13 @@ func TestRepository_UpdateAccount(t *testing.T) {
assert.NoError(db.TestVerifyOplog(t, rw, got2.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_UPDATE), db.WithCreateNotBefore(10*time.Second)))
})
t.Run("invalid-duplicate-usernames", func(t *testing.T) {
t.Run("invalid-duplicate-loginnames", func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
repo, err := NewRepository(rw, rw, wrapper)
assert.NoError(err)
require.NotNil(repo)
userName := "kazmierczak12"
loginName := "kazmierczak12"
org, _ := iam.TestScopes(t, conn)
am := TestAuthMethods(t, conn, org.PublicId, 1)[0]
acts := TestAccounts(t, conn, am.PublicId, 2)
@@ -999,16 +999,16 @@ func TestRepository_UpdateAccount(t *testing.T) {
aa := acts[0]
ab := acts[1]
aa.UserName = userName
got1, gotCount1, err := repo.UpdateAccount(context.Background(), aa, 1, []string{"UserName"})
aa.LoginName = loginName
got1, gotCount1, err := repo.UpdateAccount(context.Background(), aa, 1, []string{"LoginName"})
assert.NoError(err)
require.NotNil(got1)
assert.Equal(userName, got1.UserName)
assert.Equal(loginName, got1.LoginName)
assert.Equal(1, gotCount1, "row count")
assert.NoError(db.TestVerifyOplog(t, rw, aa.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_UPDATE), db.WithCreateNotBefore(10*time.Second)))
ab.UserName = userName
got2, gotCount2, err := repo.UpdateAccount(context.Background(), ab, 1, []string{"UserName"})
ab.LoginName = loginName
got2, gotCount2, err := repo.UpdateAccount(context.Background(), ab, 1, []string{"LoginName"})
assert.Truef(errors.Is(err, db.ErrNotUnique), "want err: %v got: %v", db.ErrNotUnique, err)
assert.Nil(got2)
assert.Equal(db.NoRowsAffected, gotCount2, "row count")
@@ -1017,7 +1017,7 @@ func TestRepository_UpdateAccount(t *testing.T) {
assert.True(errors.Is(db.ErrRecordNotFound, err))
})
t.Run("valid-duplicate-usernames-diff-AuthMethods", func(t *testing.T) {
t.Run("valid-duplicate-loginnames-diff-AuthMethods", func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
repo, err := NewRepository(rw, rw, wrapper)
assert.NoError(err)
@@ -1031,7 +1031,7 @@ func TestRepository_UpdateAccount(t *testing.T) {
in := &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
}
in2 := in.clone()
@@ -1042,19 +1042,19 @@ func TestRepository_UpdateAccount(t *testing.T) {
require.NotNil(got)
assertPublicId(t, AccountPrefix, got.PublicId)
assert.NotSame(in, got)
assert.Equal(in.UserName, got.UserName)
assert.Equal(in.LoginName, got.LoginName)
in2.AuthMethodId = amb.PublicId
in2.UserName = "kazmierczak2"
in2.LoginName = "kazmierczak2"
got2, err := repo.CreateAccount(context.Background(), in2)
assert.NoError(err)
require.NotNil(got2)
got2.UserName = got.UserName
got3, gotCount3, err := repo.UpdateAccount(context.Background(), got2, 1, []string{"UserName"})
got2.LoginName = got.LoginName
got3, gotCount3, err := repo.UpdateAccount(context.Background(), got2, 1, []string{"LoginName"})
assert.NoError(err)
require.NotNil(got3)
assert.NotSame(got2, got3)
assert.Equal(got.UserName, got3.UserName)
assert.Equal(got.LoginName, got3.LoginName)
assert.Equal(1, gotCount3, "row count")
assert.NoError(db.TestVerifyOplog(t, rw, got2.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_UPDATE), db.WithCreateNotBefore(10*time.Second)))
})
@@ -157,17 +157,17 @@ func (r *Repository) DeleteAuthMethod(ctx context.Context, publicId string, opt
return rowsDeleted, nil
}
// TODO: Fix the MinPasswordLength and MinUserNameLength update path so they dont have
// TODO: Fix the MinPasswordLength and MinLoginNameLength update path so they dont have
// to rely on the response of NewAuthMethod but instead can be unset in order to be
// set to the default values.
// UpdateAuthMethod will update an auth method in the repository and return
// the written auth method. MinPasswordLength and MinUserNameLength should
// the written auth method. MinPasswordLength and MinLoginNameLength should
// not be set to null, but instead use the default values returned by
// NewAuthMethod. fieldMaskPaths provides field_mask.proto paths for fields
// that should be updated. Fields will be set to NULL if the field is a zero
// value and included in fieldMask. Name, Description, MinPasswordLength,
// and MinUserNameLength are the only updatable fields, If no updatable fields
// and MinLoginNameLength are the only updatable fields, If no updatable fields
// are included in the fieldMaskPaths, then an error is returned.
func (r *Repository) UpdateAuthMethod(ctx context.Context, authMethod *AuthMethod, version uint32, fieldMaskPaths []string, opt ...Option) (*AuthMethod, int, error) {
if authMethod == nil {
@@ -180,7 +180,7 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, authMethod *AuthMetho
switch {
case strings.EqualFold("name", f):
case strings.EqualFold("description", f):
case strings.EqualFold("MinUserNameLength", f):
case strings.EqualFold("MinLoginNameLength", f):
case strings.EqualFold("MinPasswordLength", f):
default:
return nil, db.NoRowsAffected, fmt.Errorf("update: password auth method: field: %s: %w", f, db.ErrInvalidFieldMask)
@@ -189,10 +189,10 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, authMethod *AuthMetho
var dbMask, nullFields []string
dbMask, nullFields = dbcommon.BuildUpdatePaths(
map[string]interface{}{
"Name": authMethod.Name,
"Description": authMethod.Description,
"MinPasswordLength": authMethod.MinPasswordLength,
"MinUserNameLength": authMethod.MinUserNameLength,
"Name": authMethod.Name,
"Description": authMethod.Description,
"MinPasswordLength": authMethod.MinPasswordLength,
"MinLoginNameLength": authMethod.MinLoginNameLength,
},
fieldMaskPaths,
)
@@ -565,21 +565,21 @@ func TestRepository_UpdateAuthMethod(t *testing.T) {
skipVersionCheck: true,
},
{
name: "change min username",
name: "change min login name",
args: args{
updates: &store.AuthMethod{
MinUserNameLength: 13,
MinLoginNameLength: 13,
},
fieldMaskPaths: []string{"MinUserNameLength"},
fieldMaskPaths: []string{"MinLoginNameLength"},
},
wantErr: false,
wantRowsUpdate: 1,
},
{
name: "null min username",
name: "null min login name",
args: args{
updates: &store.AuthMethod{},
fieldMaskPaths: []string{"MinUserNameLength"},
fieldMaskPaths: []string{"MinLoginNameLength"},
},
wantErr: false,
wantRowsUpdate: 1,
@@ -107,9 +107,9 @@ func (r *Repository) setArgon2Conf(ctx context.Context, c *Argon2Configuration)
}
type currentConfig struct {
ConfType string
MinUserNameLength int
MinPasswordLength int
ConfType string
MinLoginNameLength int
MinPasswordLength int
*Argon2Configuration
}
+15 -15
View File
@@ -18,8 +18,8 @@ type authAccount struct {
IsCurrentConf bool
}
// Authenticate authenticates userName and password match for userName in
// authMethodId. The account for the userName is returned if authentication
// Authenticate authenticates loginName and password match for loginName in
// authMethodId. The account for the loginName is returned if authentication
// is successful. Returns nil if authentication fails.
//
// The CredentialId in the returned account represents a user's current
@@ -29,18 +29,18 @@ type authAccount struct {
// Authenticate will update the stored values for password to the current
// password settings for authMethodId if authentication is successful and
// the stored values are not using the current password settings.
func (r *Repository) Authenticate(ctx context.Context, authMethodId string, userName string, password string) (*Account, error) {
func (r *Repository) Authenticate(ctx context.Context, authMethodId string, loginName string, password string) (*Account, error) {
if authMethodId == "" {
return nil, fmt.Errorf("password authenticate: no authMethodId: %w", db.ErrInvalidParameter)
}
if userName == "" {
return nil, fmt.Errorf("password authenticate: no userName: %w", db.ErrInvalidParameter)
if loginName == "" {
return nil, fmt.Errorf("password authenticate: no loginName: %w", db.ErrInvalidParameter)
}
if password == "" {
return nil, fmt.Errorf("password authenticate: no password: %w", db.ErrInvalidParameter)
}
acct, err := r.authenticate(ctx, authMethodId, userName, password)
acct, err := r.authenticate(ctx, authMethodId, loginName, password)
if err != nil {
return nil, fmt.Errorf("password authenticate: %w", err)
}
@@ -83,18 +83,18 @@ func (r *Repository) Authenticate(ctx context.Context, authMethodId string, user
return acct.Account, nil
}
// ChangePassword updates the password for userName in authMethodId to new
// if old equals the stored password. The account for the userName is
// ChangePassword updates the password for loginName in authMethodId to new
// if old equals the stored password. The account for the loginName is
// returned with a new CredentialId if password is successfully changed.
//
// Returns nil if old does not match the stored password for userName.
// Returns nil if old does not match the stored password for loginName.
// Returns ErrPasswordsEqual if old and new are equal.
func (r *Repository) ChangePassword(ctx context.Context, authMethodId string, userName string, old, new string) (*Account, error) {
func (r *Repository) ChangePassword(ctx context.Context, authMethodId string, loginName string, old, new string) (*Account, error) {
if authMethodId == "" {
return nil, fmt.Errorf("change password: no authMethodId: %w", db.ErrInvalidParameter)
}
if userName == "" {
return nil, fmt.Errorf("change password: no userName: %w", db.ErrInvalidParameter)
if loginName == "" {
return nil, fmt.Errorf("change password: no loginName: %w", db.ErrInvalidParameter)
}
if old == "" {
return nil, fmt.Errorf("change password: no old password: %w", db.ErrInvalidParameter)
@@ -106,7 +106,7 @@ func (r *Repository) ChangePassword(ctx context.Context, authMethodId string, us
return nil, fmt.Errorf("change password: %w", ErrPasswordsEqual)
}
acct, err := r.authenticate(ctx, authMethodId, userName, old)
acct, err := r.authenticate(ctx, authMethodId, loginName, old)
if err != nil {
return nil, fmt.Errorf("change password: %w", err)
}
@@ -153,14 +153,14 @@ func (r *Repository) ChangePassword(ctx context.Context, authMethodId string, us
return acct.Account, nil
}
func (r *Repository) authenticate(ctx context.Context, authMethodId string, userName string, password string) (*authAccount, error) {
func (r *Repository) authenticate(ctx context.Context, authMethodId string, loginName string, password string) (*authAccount, error) {
var accts []authAccount
tx, err := r.reader.DB()
if err != nil {
return nil, err
}
rows, err := tx.Query(authenticateQuery, authMethodId, userName)
rows, err := tx.Query(authenticateQuery, authMethodId, loginName)
if err != nil {
return nil, err
}
@@ -26,7 +26,7 @@ func TestRepository_Authenticate(t *testing.T) {
inAcct := &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
}
passwd := "12345678"
@@ -40,7 +40,7 @@ func TestRepository_Authenticate(t *testing.T) {
type args struct {
authMethodId string
userName string
loginName string
password string
}
@@ -54,16 +54,16 @@ func TestRepository_Authenticate(t *testing.T) {
name: "invalid-no-authMethodId",
args: args{
authMethodId: "",
userName: inAcct.UserName,
loginName: inAcct.LoginName,
password: passwd,
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-no-userName",
name: "invalid-no-loginName",
args: args{
authMethodId: inAcct.AuthMethodId,
userName: "",
loginName: "",
password: passwd,
},
wantIsErr: db.ErrInvalidParameter,
@@ -72,7 +72,7 @@ func TestRepository_Authenticate(t *testing.T) {
name: "invalid-no-password",
args: args{
authMethodId: inAcct.AuthMethodId,
userName: inAcct.UserName,
loginName: inAcct.LoginName,
password: "",
},
wantIsErr: db.ErrInvalidParameter,
@@ -81,7 +81,7 @@ func TestRepository_Authenticate(t *testing.T) {
name: "valid-authenticate",
args: args{
authMethodId: inAcct.AuthMethodId,
userName: inAcct.UserName,
loginName: inAcct.LoginName,
password: passwd,
},
want: outAcct,
@@ -90,7 +90,7 @@ func TestRepository_Authenticate(t *testing.T) {
name: "wrong-password",
args: args{
authMethodId: inAcct.AuthMethodId,
userName: inAcct.UserName,
loginName: inAcct.LoginName,
password: "foobar",
},
want: nil,
@@ -101,7 +101,7 @@ func TestRepository_Authenticate(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
authAcct, err := repo.Authenticate(context.Background(), tt.args.authMethodId, tt.args.userName, tt.args.password)
authAcct, err := repo.Authenticate(context.Background(), tt.args.authMethodId, tt.args.loginName, tt.args.password)
if tt.wantIsErr != nil {
assert.Truef(errors.Is(err, tt.wantIsErr), "want err: %q got: %q", tt.wantIsErr, err)
assert.Nil(authAcct, "returned account")
@@ -115,7 +115,7 @@ func TestRepository_Authenticate(t *testing.T) {
require.NotNil(authAcct, "returned account")
assert.NotEmpty(authAcct.CredentialId, "CredentialId")
assert.Equal(tt.args.authMethodId, authAcct.AuthMethodId, "authMethodId")
assert.Equal(tt.args.userName, authAcct.UserName, "UserName")
assert.Equal(tt.args.loginName, authAcct.LoginName, "LoginName")
err = db.TestVerifyOplog(t, rw, authAcct.CredentialId, db.WithOperation(oplog.OpType_OP_TYPE_UPDATE), db.WithCreateNotBefore(10*time.Second))
assert.Error(err)
assert.True(errors.Is(db.ErrRecordNotFound, err))
@@ -133,7 +133,7 @@ func TestRepository_AuthenticateRehash(t *testing.T) {
authMethods := TestAuthMethods(t, conn, o.GetPublicId(), 1)
authMethod := authMethods[0]
authMethodId := authMethod.GetPublicId()
userName := "kazmierczak"
loginName := "kazmierczak"
passwd := "12345678"
ctx := context.Background()
@@ -154,7 +154,7 @@ func TestRepository_AuthenticateRehash(t *testing.T) {
inAcct := &Account{
Account: &store.Account{
AuthMethodId: authMethod.PublicId,
UserName: userName,
LoginName: loginName,
},
}
@@ -173,7 +173,7 @@ func TestRepository_AuthenticateRehash(t *testing.T) {
origCredId := origCred.PrivateId
// Authenticate and verify the credential ID
authAcct, err := repo.Authenticate(ctx, authMethodId, userName, passwd)
authAcct, err := repo.Authenticate(ctx, authMethodId, loginName, passwd)
require.NoError(err)
require.NotNil(authAcct, "auth account")
assert.Equal(origAcct.PublicId, authAcct.PublicId)
@@ -209,7 +209,7 @@ func TestRepository_AuthenticateRehash(t *testing.T) {
assert.NotEqual(origConfId, upArgonConf.PrivateId)
// Authenticate and verify the credential ID has not changed
auth2Acct, err := repo.Authenticate(ctx, authMethodId, userName, passwd)
auth2Acct, err := repo.Authenticate(ctx, authMethodId, loginName, passwd)
require.NoError(err)
require.NotNil(auth2Acct, "auth2 account")
assert.Equal(origAcct.PublicId, auth2Acct.PublicId)
@@ -250,14 +250,14 @@ func TestRepository_ChangePassword(t *testing.T) {
inAcct := &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
}
passwd := "12345678"
type args struct {
authMethodId string
userName string
loginName string
old, new string
}
@@ -272,7 +272,7 @@ func TestRepository_ChangePassword(t *testing.T) {
name: "invalid-no-authMethodId",
args: args{
authMethodId: "",
userName: inAcct.UserName,
loginName: inAcct.LoginName,
old: passwd,
new: "12345678-changed",
},
@@ -280,38 +280,38 @@ func TestRepository_ChangePassword(t *testing.T) {
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-no-userName",
name: "invalid-no-loginName",
args: args{
userName: "",
old: passwd,
new: "12345678-changed",
loginName: "",
old: passwd,
new: "12345678-changed",
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-no-old-password",
args: args{
userName: inAcct.UserName,
old: "",
new: "12345678-changed",
loginName: inAcct.LoginName,
old: "",
new: "12345678-changed",
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-no-new-password",
args: args{
userName: inAcct.UserName,
old: passwd,
new: "",
loginName: inAcct.LoginName,
old: passwd,
new: "",
},
wantIsErr: db.ErrInvalidParameter,
},
{
name: "invalid-same-passwords",
args: args{
userName: inAcct.UserName,
old: passwd,
new: passwd,
loginName: inAcct.LoginName,
old: passwd,
new: passwd,
},
wantIsErr: ErrPasswordsEqual,
},
@@ -319,7 +319,7 @@ func TestRepository_ChangePassword(t *testing.T) {
name: "auth-failure-unknown-authMethodId",
args: args{
authMethodId: "not-an-authMethod-Id",
userName: inAcct.UserName,
loginName: inAcct.LoginName,
old: passwd,
new: "12345678-changed",
},
@@ -330,9 +330,9 @@ func TestRepository_ChangePassword(t *testing.T) {
{
name: "auth-failure-wrong-old-password",
args: args{
userName: inAcct.UserName,
old: "wrong-password",
new: "12345678-changed",
loginName: inAcct.LoginName,
old: "wrong-password",
new: "12345678-changed",
},
wantAccount: false,
wantIsErr: nil,
@@ -340,18 +340,18 @@ func TestRepository_ChangePassword(t *testing.T) {
{
name: "password-to-short",
args: args{
userName: inAcct.UserName,
old: passwd,
new: "1",
loginName: inAcct.LoginName,
old: passwd,
new: "1",
},
wantIsErr: ErrTooShort,
},
{
name: "valid",
args: args{
userName: inAcct.UserName,
old: passwd,
new: "12345678-changed",
loginName: inAcct.LoginName,
old: passwd,
new: "12345678-changed",
},
wantAccount: true,
},
@@ -373,7 +373,7 @@ func TestRepository_ChangePassword(t *testing.T) {
}
// Calls to Authenticate should always succeed in these tests
authFn := func(pwd string, name string) *Account {
acct, err := repo.Authenticate(context.Background(), inAcct.AuthMethodId, inAcct.UserName, pwd)
acct, err := repo.Authenticate(context.Background(), inAcct.AuthMethodId, inAcct.LoginName, pwd)
require.NotNilf(acct, "%s: Authenticate should return an account", name)
require.NoErrorf(err, "%s: Authenticate should succeed", name)
return acct
@@ -381,7 +381,7 @@ func TestRepository_ChangePassword(t *testing.T) {
// authenticate with original password
authAcct1 := authFn(passwd, "original account")
chgAuthAcct, err := repo.ChangePassword(context.Background(), tt.args.authMethodId, tt.args.userName, tt.args.old, tt.args.new)
chgAuthAcct, err := repo.ChangePassword(context.Background(), tt.args.authMethodId, tt.args.loginName, tt.args.old, tt.args.new)
if tt.wantIsErr != nil {
assert.Error(err)
assert.Truef(errors.Is(err, tt.wantIsErr), "want err: %q got: %q", tt.wantIsErr, err)
@@ -401,7 +401,7 @@ func TestRepository_ChangePassword(t *testing.T) {
assert.NotEmpty(chgAuthAcct.CredentialId, "CredentialId")
assert.NotEqual(authAcct1.CredentialId, chgAuthAcct.CredentialId, "CredentialId should change")
assert.Equal(authAcct1.AuthMethodId, chgAuthAcct.AuthMethodId, "authMethodId")
assert.Equal(authAcct1.UserName, chgAuthAcct.UserName, "UserName")
assert.Equal(authAcct1.LoginName, chgAuthAcct.LoginName, "LoginName")
authAcct2 := authFn(tt.args.new, "successful change password: using new password")
assert.Equal(chgAuthAcct.CredentialId, authAcct2.CredentialId, "CredentialId should not change")
@@ -423,13 +423,13 @@ func TestRepository_SetPassword(t *testing.T) {
template := &Account{
Account: &store.Account{
UserName: "kazmierczak",
LoginName: "kazmierczak",
},
}
origPasswd := "12345678"
wantAuthenticate := func(t *testing.T, authMethodId string, pwd string, msg string) string {
acct, err := repo.Authenticate(context.Background(), authMethodId, template.UserName, pwd)
acct, err := repo.Authenticate(context.Background(), authMethodId, template.LoginName, pwd)
assert.NoErrorf(t, err, "%s: authenticate should not return an error", msg)
if assert.NotNilf(t, acct, "%s: authenticate should succeed", msg) {
return acct.CredentialId
@@ -440,7 +440,7 @@ func TestRepository_SetPassword(t *testing.T) {
if authMethodId == "" || pwd == "" {
return ""
}
acct, err := repo.Authenticate(context.Background(), authMethodId, template.UserName, pwd)
acct, err := repo.Authenticate(context.Background(), authMethodId, template.LoginName, pwd)
assert.NoErrorf(t, err, "%s: authenticate should not return an error", msg)
assert.Nilf(t, acct, "%s: authenticate should not succeed", msg)
return ""
+54 -54
View File
@@ -56,7 +56,7 @@ type AuthMethod struct {
// @inject_tag: `gorm:"not_null"`
PasswordConfId string `protobuf:"bytes,8,opt,name=password_conf_id,json=passwordConfId,proto3" json:"password_conf_id,omitempty" gorm:"not_null"`
// @inject_tag: `gorm:"default:null"`
MinUserNameLength uint32 `protobuf:"varint,9,opt,name=min_user_name_length,json=minUserNameLength,proto3" json:"min_user_name_length,omitempty" gorm:"default:null"`
MinLoginNameLength uint32 `protobuf:"varint,9,opt,name=min_login_name_length,json=minLoginNameLength,proto3" json:"min_login_name_length,omitempty" gorm:"default:null"`
// @inject_tag: `gorm:"default:null"`
MinPasswordLength uint32 `protobuf:"varint,10,opt,name=min_password_length,json=minPasswordLength,proto3" json:"min_password_length,omitempty" gorm:"default:null"`
}
@@ -149,9 +149,9 @@ func (x *AuthMethod) GetPasswordConfId() string {
return ""
}
func (x *AuthMethod) GetMinUserNameLength() uint32 {
func (x *AuthMethod) GetMinLoginNameLength() uint32 {
if x != nil {
return x.MinUserNameLength
return x.MinLoginNameLength
}
return 0
}
@@ -187,7 +187,7 @@ type Account struct {
// @inject_tag: `gorm:"not_null"`
AuthMethodId string `protobuf:"bytes,7,opt,name=auth_method_id,json=authMethodId,proto3" json:"auth_method_id,omitempty" gorm:"not_null"`
// @inject_tag: `gorm:"not_null"`
UserName string `protobuf:"bytes,8,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty" gorm:"not_null"`
LoginName string `protobuf:"bytes,8,opt,name=login_name,json=loginName,proto3" json:"login_name,omitempty" gorm:"not_null"`
}
func (x *Account) Reset() {
@@ -271,9 +271,9 @@ func (x *Account) GetAuthMethodId() string {
return ""
}
func (x *Account) GetUserName() string {
func (x *Account) GetLoginName() string {
if x != nil {
return x.UserName
return x.LoginName
}
return ""
}
@@ -368,7 +368,7 @@ var file_controller_storage_auth_password_store_v1_password_proto_rawDesc = []by
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
0x65, 0x72, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x22, 0xeb, 0x03, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f,
0x74, 0x6f, 0x22, 0xed, 0x03, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b,
0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20,
@@ -393,53 +393,53 @@ var file_controller_storage_auth_password_store_v1_password_proto_rawDesc = []by
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0e, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64, 0x12,
0x2f, 0x0a, 0x14, 0x6d, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65,
0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x6d,
0x69, 0x6e, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68,
0x12, 0x2e, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x6d,
0x69, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68,
0x22, 0x85, 0x03, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09,
0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65,
0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a,
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72,
0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31,
0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61,
0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65,
0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f,
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65,
0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54,
0x69, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x42, 0x10, 0xc2, 0xdd, 0x29, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x64, 0x65, 0x73,
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1e,
0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b,
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61,
0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x75,
0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x75, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xb3, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65,
0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61,
0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69,
0x76, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f,
0x72, 0x64, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x11, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f,
0x72, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0e, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x49, 0x64,
0x12, 0x2c, 0x0a, 0x12, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x6d, 0x65, 0x74,
0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x64, 0x42, 0x42,
0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73,
0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f,
0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f,
0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x31, 0x0a, 0x15, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d,
0x65, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12,
0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x4c, 0x65, 0x6e, 0x67,
0x74, 0x68, 0x12, 0x2e, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f,
0x72, 0x64, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x11, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x4c, 0x65, 0x6e, 0x67,
0x74, 0x68, 0x22, 0x87, 0x03, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b,
0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e,
0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72,
0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61,
0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61,
0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e,
0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74,
0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x42, 0x10, 0xc2, 0xdd, 0x29, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x64,
0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x42, 0x1e, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a,
0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f,
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0c, 0x61, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a,
0x0a, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28,
0x09, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xb3, 0x01, 0x0a,
0x0a, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x70,
0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x09, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x69, 0x64, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x6f,
0x6e, 0x66, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x10, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64,
0x49, 0x64, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64,
0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x75, 0x74,
0x68, 0x2f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65,
0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
+9 -9
View File
@@ -63,7 +63,7 @@ type Server struct {
DefaultOrgId string
DevAuthMethodId string
DevUsername string
DevLoginName string
DevPassword string
DevDatabaseUrl string
@@ -502,13 +502,13 @@ func (b *Server) CreateDevDatabase(dialect string) error {
return fmt.Errorf("error saving auth method to the db: %w", err)
}
acctUserName := b.DevUsername
if acctUserName == "" {
acctUserName, err = base62.Random(10)
acctLoginName := b.DevLoginName
if acctLoginName == "" {
acctLoginName, err = base62.Random(10)
if err != nil {
return fmt.Errorf("unable to generate dev username: %w", err)
return fmt.Errorf("unable to generate dev login name: %w", err)
}
acctUserName = strings.ToLower(acctUserName)
acctLoginName = strings.ToLower(acctLoginName)
}
pw := b.DevPassword
@@ -519,7 +519,7 @@ func (b *Server) CreateDevDatabase(dialect string) error {
}
}
acct, err := password.NewAccount(amId, acctUserName)
acct, err := password.NewAccount(amId, acctLoginName)
if err != nil {
return fmt.Errorf("error creating new in memory auth account: %w", err)
}
@@ -528,10 +528,10 @@ func (b *Server) CreateDevDatabase(dialect string) error {
return fmt.Errorf("error saving auth account to the db: %w", err)
}
b.InfoKeys = append(b.InfoKeys, "dev org id", "dev auth method id", "dev username", "dev password")
b.InfoKeys = append(b.InfoKeys, "dev org id", "dev auth method id", "dev login name", "dev password")
b.Info["dev org id"] = b.DefaultOrgId
b.Info["dev auth method id"] = amId
b.Info["dev username"] = acct.GetUserName()
b.Info["dev login name"] = acct.GetLoginName()
b.Info["dev password"] = pw
// now that we have passed all the error cases, reset c to be a noop so the
+10 -10
View File
@@ -45,7 +45,7 @@ type Command struct {
flagLogFormat string
flagCombineLogs bool
flagDev bool
flagDevUsername string
flagDevLoginName string
flagDevPassword string
flagDevControllerAPIListenAddr string
flagDevControllerClusterListenAddr string
@@ -139,10 +139,10 @@ func (c *Command) Flags() *base.FlagSets {
})
f.StringVar(&base.StringVar{
Name: "dev-username",
Target: &c.flagDevUsername,
EnvVar: "WATCHTWER_DEV_USERNAME",
Usage: "Initial admin username. This only applies when running in \"dev\" " +
Name: "dev-login-name",
Target: &c.flagDevLoginName,
EnvVar: "WATCHTWER_DEV_LOGIN_NAME",
Usage: "Initial admin login name. This only applies when running in \"dev\" " +
"mode.",
})
@@ -337,11 +337,11 @@ func (c *Command) ParseFlagsAndConfig(args []string) int {
"You cannot specify a custom admin password outside of \"dev\" mode. " +
"Your request has been ignored."))
c.flagDevPassword = ""
case c.flagDevUsername != "":
case c.flagDevLoginName != "":
c.UI.Warn(base.WrapAtLength(
"You cannot specify a custom admin username outside of \"dev\" mode. " +
"You cannot specify a custom admin login name outside of \"dev\" mode. " +
"Your request has been ignored."))
c.flagDevUsername = ""
c.flagDevLoginName = ""
}
c.Config, err = config.LoadFile(c.flagConfig, c.configKMS)
@@ -372,8 +372,8 @@ func (c *Command) ParseFlagsAndConfig(args []string) int {
}
c.DevAuthMethodId = c.flagDevAuthMethodId
}
if c.flagDevUsername != "" {
c.DevUsername = c.flagDevUsername
if c.flagDevLoginName != "" {
c.DevLoginName = c.flagDevLoginName
}
if c.flagDevPassword != "" {
c.DevPassword = c.flagDevPassword
+7 -7
View File
@@ -35,7 +35,7 @@ type Command struct {
flagLogFormat string
flagCombineLogs bool
flagDev bool
flagDevUsername string
flagDevLoginName string
flagDevPassword string
flagDevOrgId string
flagDevAuthMethodId string
@@ -112,10 +112,10 @@ func (c *Command) Flags() *base.FlagSets {
})
f.StringVar(&base.StringVar{
Name: "dev-username",
Target: &c.flagDevUsername,
EnvVar: "WATCHTWER_DEV_USERNAME",
Usage: "Initial admin username. This only applies when running in \"dev\" " +
Name: "dev-login-name",
Target: &c.flagDevLoginName,
EnvVar: "WATCHTWER_DEV_LOGIN_NAME",
Usage: "Initial admin login name. This only applies when running in \"dev\" " +
"mode.",
})
@@ -186,8 +186,8 @@ func (c *Command) Run(args []string) int {
}
c.DevAuthMethodId = c.flagDevAuthMethodId
}
if c.flagDevUsername != "" {
c.DevUsername = c.flagDevUsername
if c.flagDevLoginName != "" {
c.DevLoginName = c.flagDevLoginName
}
if c.flagDevPassword != "" {
c.DevPassword = c.flagDevPassword
+6 -6
View File
@@ -1724,7 +1724,7 @@ begin;
description text,
create_time wt_timestamp,
update_time wt_timestamp,
min_user_name_length int not null default 3,
min_login_name_length int not null default 3,
min_password_length int not null default 8,
version wt_version,
foreign key (scope_id, public_id)
@@ -1756,11 +1756,11 @@ begin;
description text,
create_time wt_timestamp,
update_time wt_timestamp,
user_name text not null
login_name text not null
check(
lower(trim(user_name)) = user_name
lower(trim(login_name)) = login_name
and
length(user_name) > 0
length(login_name) > 0
),
version wt_version,
foreign key (scope_id, auth_method_id)
@@ -1772,7 +1772,7 @@ begin;
on delete cascade
on update cascade,
unique(auth_method_id, name),
unique(auth_method_id, user_name),
unique(auth_method_id, login_name),
unique(auth_method_id, public_id)
);
@@ -2133,7 +2133,7 @@ begin;
-- but the query to create the view should not need to be updated.
create or replace view auth_password_current_conf as
-- Rerun this query whenever auth_password_conf_union is updated.
select pm.min_user_name_length, pm.min_password_length, c.*
select pm.min_login_name_length, pm.min_password_length, c.*
from auth_password_method pm
inner join auth_password_conf_union c
on pm.password_conf_id = c.password_conf_id;
@@ -64,7 +64,7 @@ begin;
description text,
create_time wt_timestamp,
update_time wt_timestamp,
min_user_name_length int not null default 3,
min_login_name_length int not null default 3,
min_password_length int not null default 8,
version wt_version,
foreign key (scope_id, public_id)
@@ -96,11 +96,11 @@ begin;
description text,
create_time wt_timestamp,
update_time wt_timestamp,
user_name text not null
login_name text not null
check(
lower(trim(user_name)) = user_name
lower(trim(login_name)) = login_name
and
length(user_name) > 0
length(login_name) > 0
),
version wt_version,
foreign key (scope_id, auth_method_id)
@@ -112,7 +112,7 @@ begin;
on delete cascade
on update cascade,
unique(auth_method_id, name),
unique(auth_method_id, user_name),
unique(auth_method_id, login_name),
unique(auth_method_id, public_id)
);
@@ -17,7 +17,7 @@ begin;
-- but the query to create the view should not need to be updated.
create or replace view auth_password_current_conf as
-- Rerun this query whenever auth_password_conf_union is updated.
select pm.min_user_name_length, pm.min_password_length, c.*
select pm.min_login_name_length, pm.min_password_length, c.*
from auth_password_method pm
inner join auth_password_conf_union c
on pm.password_conf_id = c.password_conf_id;
@@ -181,8 +181,8 @@ type PasswordAccountAttributes struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The username of this account. This is unique per auth method.
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
// The login name of this account. This is unique per auth method.
LoginName string `protobuf:"bytes,1,opt,name=login_name,json=loginName,proto3" json:"login_name,omitempty"`
// The password for this account.
Password *wrappers.StringValue `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
}
@@ -219,9 +219,9 @@ func (*PasswordAccountAttributes) Descriptor() ([]byte, []int) {
return file_controller_api_resources_authmethods_v1_account_proto_rawDescGZIP(), []int{1}
}
func (x *PasswordAccountAttributes) GetUsername() string {
func (x *PasswordAccountAttributes) GetLoginName() string {
if x != nil {
return x.Username
return x.LoginName
}
return ""
}
@@ -291,22 +291,22 @@ var file_controller_api_resources_authmethods_v1_account_proto_rawDesc = []byte{
0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01, 0x52,
0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x22, 0x7d, 0x0a, 0x19, 0x50,
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x74,
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01,
0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x08, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01,
0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x5d, 0x5a, 0x5b, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f,
0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65,
0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x3b, 0x61, 0x75,
0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x22, 0x80, 0x01, 0x0a, 0x19,
0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41,
0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0a, 0x6c, 0x6f, 0x67,
0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xa0,
0xda, 0x29, 0x01, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3e,
0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x04,
0xa0, 0xda, 0x29, 0x01, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x5d,
0x5a, 0x5b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73,
0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f,
0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,
0x73, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -163,7 +163,7 @@ type PasswordAuthMethodAttributes struct {
unknownFields protoimpl.UnknownFields
// The minimum length allowed for user names for accounts in this auth method.
MinUserNameLength uint32 `protobuf:"varint,1,opt,name=min_user_name_length,json=minUserNameLength,proto3" json:"min_user_name_length,omitempty"`
MinLoginNameLength uint32 `protobuf:"varint,1,opt,name=min_login_name_length,json=minLoginNameLength,proto3" json:"min_login_name_length,omitempty"`
// The minimum length allowed for passwords for accounts in this auth method.
MinPasswordLength uint32 `protobuf:"varint,2,opt,name=min_password_length,json=minPasswordLength,proto3" json:"min_password_length,omitempty"`
}
@@ -200,9 +200,9 @@ func (*PasswordAuthMethodAttributes) Descriptor() ([]byte, []int) {
return file_controller_api_resources_authmethods_v1_auth_method_proto_rawDescGZIP(), []int{1}
}
func (x *PasswordAuthMethodAttributes) GetMinUserNameLength() uint32 {
func (x *PasswordAuthMethodAttributes) GetMinLoginNameLength() uint32 {
if x != nil {
return x.MinUserNameLength
return x.MinLoginNameLength
}
return 0
}
@@ -267,22 +267,22 @@ var file_controller_api_resources_authmethods_v1_auth_method_proto_rawDesc = []b
0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74,
0x42, 0x04, 0xa0, 0xda, 0x29, 0x01, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
0x65, 0x73, 0x22, 0x8b, 0x01, 0x0a, 0x1c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41,
0x65, 0x73, 0x22, 0x8d, 0x01, 0x0a, 0x1c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41,
0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75,
0x74, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x14, 0x6d, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0d, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01, 0x52, 0x11, 0x6d, 0x69, 0x6e, 0x55, 0x73, 0x65, 0x72,
0x4e, 0x61, 0x6d, 0x65, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x34, 0x0a, 0x13, 0x6d, 0x69,
0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74,
0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01, 0x52, 0x11, 0x6d,
0x69, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68,
0x42, 0x5d, 0x5a, 0x5b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68,
0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72,
0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65,
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68,
0x6f, 0x64, 0x73, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x65, 0x73, 0x12, 0x37, 0x0a, 0x15, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e,
0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0d, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01, 0x52, 0x12, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67,
0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x34, 0x0a, 0x13,
0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x6c, 0x65, 0x6e,
0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x04, 0xa0, 0xda, 0x29, 0x01, 0x52,
0x11, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x4c, 0x65, 0x6e, 0x67,
0x74, 0x68, 0x42, 0x5d, 0x5a, 0x5b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64,
0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e,
0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f,
0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x73, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,
0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -40,8 +40,8 @@ type PasswordCredentials struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
LoginName string `protobuf:"bytes,1,opt,name=login_name,json=loginName,proto3" json:"login_name,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
}
func (x *PasswordCredentials) Reset() {
@@ -76,9 +76,9 @@ func (*PasswordCredentials) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_authenticate_service_proto_rawDescGZIP(), []int{0}
}
func (x *PasswordCredentials) GetName() string {
func (x *PasswordCredentials) GetLoginName() string {
if x != nil {
return x.Name
return x.LoginName
}
return ""
}
@@ -299,54 +299,54 @@ var file_controller_api_services_v1_authenticate_service_proto_rawDesc = []byte{
0x36, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f,
0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f,
0x6b, 0x65, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65,
0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x61, 0x73, 0x73, 0x77,
0x6f, 0x72, 0x64, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x95,
0x01, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d,
0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
0x61, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x63,
0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65,
0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x22, 0x5d, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e,
0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45,
0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65,
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65,
0x6e, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52,
0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x17, 0x0a, 0x15, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65,
0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x18,
0x0a, 0x16, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa0, 0x02, 0x0a, 0x15, 0x41, 0x75, 0x74,
0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x12, 0x86, 0x02, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63,
0x61, 0x74, 0x65, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31,
0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65,
0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76,
0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x92, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x42, 0x22,
0x37, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75,
0x74, 0x68, 0x2d, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74, 0x68,
0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74, 0x68,
0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65,
0x6d, 0x92, 0x41, 0x47, 0x12, 0x45, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61,
0x74, 0x65, 0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x6e, 0x20,
0x73, 0x63, 0x6f, 0x70, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65,
0x76, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x42, 0x4d, 0x5a, 0x4b, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63,
0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x50, 0x0a, 0x13, 0x50, 0x61, 0x73, 0x73, 0x77,
0x6f, 0x72, 0x64, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x12, 0x1d,
0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a,
0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x95, 0x01, 0x0a, 0x13, 0x41, 0x75,
0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x24, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x75, 0x74, 0x68, 0x4d,
0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6b,
0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e,
0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74,
0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c,
0x73, 0x22, 0x5d, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x69, 0x74, 0x65,
0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x2e, 0x76, 0x31,
0x2e, 0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d,
0x22, 0x17, 0x0a, 0x15, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61,
0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x61,
0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x32, 0xa0, 0x02, 0x0a, 0x15, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x86, 0x02,
0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f,
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68,
0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74,
0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x92, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x42, 0x22, 0x37, 0x2f, 0x76, 0x31, 0x2f,
0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2d, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x73, 0x2f, 0x7b, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68,
0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63,
0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x47, 0x12,
0x45, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20,
0x75, 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x6e, 0x20, 0x73, 0x63, 0x6f, 0x70, 0x65,
0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x61, 0x6e,
0x20, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20,
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62,
0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
+1 -1
View File
@@ -22,7 +22,7 @@ initTx.Commit()
userCreate := oplog_test.TestUser{
TestUser: oplog_test.TestUser{
Name: userName,
Name: loginName,
},
}
tx := db.Begin()
+6 -6
View File
@@ -376,12 +376,12 @@ func Test_Replay(t *testing.T) {
require.NoError(err)
tx := db
userName := "foo-" + testId(t)
userCreate := testUser(t, db, userName, "", "")
loginName := "foo-" + testId(t)
userCreate := testUser(t, db, loginName, "", "")
userSave := oplog_test.TestUser{
Id: userCreate.Id,
Name: userCreate.Name,
Email: userName + "@hashicorp.com",
Email: loginName + "@hashicorp.com",
}
err = tx.Save(&userSave).Error
require.NoError(err)
@@ -433,7 +433,7 @@ func Test_Replay(t *testing.T) {
assert.Equal(foundUser.PhoneNumber, foundReplayedUser.PhoneNumber)
assert.Equal(foundReplayedUser.PhoneNumber, "867-5309")
assert.Equal(foundUser.Email, foundReplayedUser.Email)
assert.Equal(foundReplayedUser.Email, userName+"@hashicorp.com")
assert.Equal(foundReplayedUser.Email, loginName+"@hashicorp.com")
})
t.Run("replay:delete", func(t *testing.T) {
@@ -446,10 +446,10 @@ func Test_Replay(t *testing.T) {
require.NoError(err)
id4 := testId(t)
userName2 := "foo-" + id4
loginName2 := "foo-" + id4
// create a user that's replayable
userCreate2 := oplog_test.TestUser{
Name: userName2,
Name: loginName2,
}
err = tx2.Create(&userCreate2).Error
require.NoError(err)
@@ -54,8 +54,8 @@ message Account {
}
message PasswordAccountAttributes {
// The username of this account. This is unique per auth method.
string username = 1 [(custom_options.v1.generate_sdk_option) = true];
// The login name of this account. This is unique per auth method.
string login_name = 1 [(custom_options.v1.generate_sdk_option) = true];
// The password for this account.
google.protobuf.StringValue password = 2 [(custom_options.v1.generate_sdk_option) = true];
}
@@ -48,7 +48,7 @@ message AuthMethod {
message PasswordAuthMethodAttributes {
// The minimum length allowed for user names for accounts in this auth method.
uint32 min_user_name_length = 1 [(custom_options.v1.generate_sdk_option) = true];
uint32 min_login_name_length = 1 [(custom_options.v1.generate_sdk_option) = true];
// The minimum length allowed for passwords for accounts in this auth method.
uint32 min_password_length = 2 [(custom_options.v1.generate_sdk_option) = true];
@@ -40,7 +40,7 @@ service AuthenticationService {
// The layout of the struct for "credentials" field in AuthenticateRequest. This message isn't
// directly referenced anywhere but is used here to define the expected field names and types.
message PasswordCredentials {
string name = 1;
string login_name = 1;
string password = 2;
}
@@ -38,7 +38,7 @@ message AuthMethod {
string password_conf_id = 8;
// @inject_tag: `gorm:"default:null"`
uint32 min_user_name_length = 9;
uint32 min_login_name_length = 9;
// @inject_tag: `gorm:"default:null"`
uint32 min_password_length = 10;
@@ -71,7 +71,7 @@ message Account {
string auth_method_id = 7;
// @inject_tag: `gorm:"not_null"`
string user_name = 8;
string login_name = 8;
// the scope_id column is not included here as it is used only to ensure
// data integrity in the database between iam users and auth methods.
+2 -2
View File
@@ -16,13 +16,13 @@ func TestAuthenticationHandler(t *testing.T) {
c := NewTestController(t, &TestControllerOpts{
DefaultOrgId: "o_1234567890",
DisableAuthorizationFailures: true,
DefaultUsername: "admin",
DefaultLoginName: "admin",
DefaultPassword: "password123",
})
defer c.Shutdown()
resp, err := http.Post(fmt.Sprintf("%s/v1/scopes/o_1234567890/auth-methods/paum_1234567890:authenticate", c.ApiAddrs()[0]), "application/json",
strings.NewReader(`{"token_type": null, "credentials": {"name":"admin", "password": "password123"}}`))
strings.NewReader(`{"token_type": null, "credentials": {"login_name":"admin", "password": "password123"}}`))
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode, "Got response: %v", resp)
@@ -152,7 +152,7 @@ func (s Service) createInRepo(ctx context.Context, authMethodId string, item *pb
if item.GetDescription() != nil {
opts = append(opts, password.WithDescription(item.GetDescription().GetValue()))
}
a, err := password.NewAccount(authMethodId, pwAttrs.GetUsername(), opts...)
a, err := password.NewAccount(authMethodId, pwAttrs.GetLoginName(), opts...)
if err != nil {
return nil, status.Errorf(codes.Internal, "Unable to build user for creation: %v.", err)
}
@@ -220,7 +220,7 @@ func toProto(in *password.Account) (*pb.Account, error) {
if in.GetName() != "" {
out.Name = &wrapperspb.StringValue{Value: in.GetName()}
}
if st, err := handlers.ProtoToStruct(&pb.PasswordAccountAttributes{Username: in.GetUserName()}); err == nil {
if st, err := handlers.ProtoToStruct(&pb.PasswordAccountAttributes{LoginName: in.GetLoginName()}); err == nil {
out.Attributes = st
} else {
return nil, status.Errorf(codes.Internal, "failed building password attribute struct: %v", err)
@@ -271,8 +271,8 @@ func validateCreateRequest(req *pbs.CreateAccountRequest) error {
if err := handlers.StructToProto(item.GetAttributes(), pwAttrs); err != nil {
badFields["attributes"] = "Attribute fields do not match the expected format."
}
if pwAttrs.GetUsername() == "" {
badFields["username"] = "This is a required field for this type."
if pwAttrs.GetLoginName() == "" {
badFields["login_name"] = "This is a required field for this type."
}
default:
badFields["type"] = "This is a required field."
@@ -50,7 +50,7 @@ func TestGet(t *testing.T) {
Scope: &scopes.ScopeInfo{Id: org.GetPublicId(), Type: scope.Org.String()},
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{"username": structpb.NewStringValue(aa.GetUserName())}},
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{"login_name": structpb.NewStringValue(aa.GetLoginName())}},
}
cases := []struct {
@@ -116,7 +116,7 @@ func TestList(t *testing.T) {
Scope: &scopes.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String()},
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{"username": structpb.NewStringValue(aa.GetUserName())}},
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{"login_name": structpb.NewStringValue(aa.GetLoginName())}},
})
}
@@ -130,7 +130,7 @@ func TestList(t *testing.T) {
Scope: &scopes.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String()},
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{"username": structpb.NewStringValue(aa.GetUserName())}},
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{"login_name": structpb.NewStringValue(aa.GetLoginName())}},
})
}
@@ -302,7 +302,7 @@ func TestCreate(t *testing.T) {
defaultCreated, err := ptypes.Timestamp(defaultAccount.GetCreateTime().GetTimestamp())
require.NoError(t, err, "Error converting proto to timestamp.")
defaultSt, err := handlers.ProtoToStruct(&pb.PasswordAccountAttributes{Username: "thetestusername"})
defaultSt, err := handlers.ProtoToStruct(&pb.PasswordAccountAttributes{LoginName: "thetestloginname"})
require.NoError(t, err, "Error converting proto to struct.")
cases := []struct {
@@ -400,7 +400,7 @@ func TestCreate(t *testing.T) {
errCode: codes.InvalidArgument,
},
{
name: "Must specify username for password type",
name: "Must specify login name for password type",
req: &pbs.CreateAccountRequest{
AuthMethodId: defaultAccount.GetAuthMethodId(),
Item: &pb.Account{
@@ -19,8 +19,8 @@ import (
)
const (
nameKey = "name"
pwKey = "password"
loginNameKey = "login_name"
pwKey = "password"
)
var (
@@ -61,7 +61,7 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
return nil, err
}
creds := req.GetCredentials().GetFields()
tok, err := s.authenticateWithRepo(ctx, req.GetAuthMethodId(), creds[nameKey].GetStringValue(), creds[pwKey].GetStringValue())
tok, err := s.authenticateWithRepo(ctx, req.GetAuthMethodId(), creds[loginNameKey].GetStringValue(), creds[pwKey].GetStringValue())
if err != nil {
return nil, err
}
@@ -73,7 +73,7 @@ func (s Service) Deauthenticate(ctx context.Context, req *pbs.DeauthenticateRequ
return nil, status.Error(codes.Unimplemented, "Requested method is unimplemented.")
}
func (s Service) authenticateWithRepo(ctx context.Context, authMethodId, name, pw string) (*pba.AuthToken, error) {
func (s Service) authenticateWithRepo(ctx context.Context, authMethodId, loginName, pw string) (*pba.AuthToken, error) {
iamRepo, err := s.iamRepo()
if err != nil {
return nil, err
@@ -87,7 +87,7 @@ func (s Service) authenticateWithRepo(ctx context.Context, authMethodId, name, p
return nil, err
}
acct, err := pwRepo.Authenticate(ctx, authMethodId, name, pw)
acct, err := pwRepo.Authenticate(ctx, authMethodId, loginName, pw)
if err != nil {
return nil, err
}
@@ -152,8 +152,8 @@ func validateAuthenticateRequest(req *pbs.AuthenticateRequest) error {
badFields["credentials"] = "This is a required field."
}
creds := req.GetCredentials().GetFields()
if _, ok := creds[nameKey]; !ok {
badFields["credentials.name"] = "This is a required field."
if _, ok := creds[loginNameKey]; !ok {
badFields["credentials.login_name"] = "This is a required field."
}
if _, ok := creds[pwKey]; !ok {
badFields["credentials.password"] = "This is a required field."
@@ -20,8 +20,8 @@ import (
)
const (
testPassword = "thetestpassword"
testUsername = "default"
testPassword = "thetestpassword"
testLoginName = "default"
)
func TestAuthenticate(t *testing.T) {
@@ -35,7 +35,7 @@ func TestAuthenticate(t *testing.T) {
passwordRepoFn := func() (*password.Repository, error) { return password.NewRepository(rw, rw, wrapper) }
am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0]
acct, err := password.NewAccount(am.GetPublicId(), testUsername)
acct, err := password.NewAccount(am.GetPublicId(), testLoginName)
require.NoError(t, err)
pwRepo, err := passwordRepoFn()
@@ -56,8 +56,8 @@ func TestAuthenticate(t *testing.T) {
TokenType: "token",
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: testUsername}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -72,8 +72,8 @@ func TestAuthenticate(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: testUsername}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -89,8 +89,8 @@ func TestAuthenticate(t *testing.T) {
TokenType: "email",
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: testUsername}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -102,8 +102,8 @@ func TestAuthenticate(t *testing.T) {
request: &pbs.AuthenticateRequest{
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: testUsername}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -117,8 +117,8 @@ func TestAuthenticate(t *testing.T) {
TokenType: "token",
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: testUsername}},
"password": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}},
"password": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -126,14 +126,14 @@ func TestAuthenticate(t *testing.T) {
wantErr: status.Error(codes.Unauthenticated, "unauthenticated"),
},
{
name: "wrong-username",
name: "wrong-login-name",
request: &pbs.AuthenticateRequest{
AuthMethodId: am.GetPublicId(),
TokenType: "token",
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: "wrong"}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -178,7 +178,7 @@ func TestAuthenticate_AuthAccountConnectedToIamUser(t *testing.T) {
iamRepoFn := func() (*iam.Repository, error) { return iam.NewRepository(rw, rw, wrapper) }
am := password.TestAuthMethods(t, conn, o.GetPublicId(), 1)[0]
acct, err := password.NewAccount(am.GetPublicId(), testUsername)
acct, err := password.NewAccount(am.GetPublicId(), testLoginName)
require.NoError(err)
pwRepo, err := passwordRepoFn()
@@ -198,8 +198,8 @@ func TestAuthenticate_AuthAccountConnectedToIamUser(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Credentials: func() *structpb.Struct {
creds := map[string]*structpb.Value{
"name": {Kind: &structpb.Value_StringValue{StringValue: testUsername}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
"login_name": {Kind: &structpb.Value_StringValue{StringValue: testLoginName}},
"password": {Kind: &structpb.Value_StringValue{StringValue: testPassword}},
}
return &structpb.Struct{Fields: creds}
}(),
@@ -256,8 +256,8 @@ func toProto(in *password.AuthMethod) (*pb.AuthMethod, error) {
out.Name = &wrapperspb.StringValue{Value: in.GetName()}
}
st, err := handlers.ProtoToStruct(&pb.PasswordAuthMethodAttributes{
MinUserNameLength: in.GetMinUserNameLength(),
MinPasswordLength: in.GetMinPasswordLength(),
MinLoginNameLength: in.GetMinLoginNameLength(),
MinPasswordLength: in.GetMinPasswordLength(),
})
if err != nil {
return nil, status.Errorf(codes.Internal, "failed building password attribute struct: %v", err)
@@ -44,8 +44,8 @@ func TestGet(t *testing.T) {
UpdatedTime: am.UpdateTime.GetTimestamp(),
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
Version: 1,
Scope: &scopes.ScopeInfo{
@@ -126,8 +126,8 @@ func TestList(t *testing.T) {
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
})
}
@@ -142,8 +142,8 @@ func TestList(t *testing.T) {
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
})
}
@@ -316,8 +316,8 @@ func TestCreate(t *testing.T) {
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
},
},
@@ -374,8 +374,8 @@ func TestCreate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "Attributes must be valid for type"},
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"invalid_field": structpb.NewStringValue("invalid_value"),
"min_user_name_length": structpb.NewNumberValue(3),
"invalid_field": structpb.NewStringValue("invalid_value"),
"min_login_name_length": structpb.NewNumberValue(3),
}},
}},
res: nil,
@@ -468,8 +468,8 @@ func TestUpdate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "desc"},
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
},
},
@@ -492,8 +492,8 @@ func TestUpdate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "desc"},
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
},
},
@@ -546,8 +546,8 @@ func TestUpdate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "default"},
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
},
},
@@ -570,8 +570,8 @@ func TestUpdate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "default"},
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
},
},
@@ -594,8 +594,8 @@ func TestUpdate(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "notignored"},
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
"min_password_length": structpb.NewNumberValue(8),
"min_login_name_length": structpb.NewNumberValue(3),
}},
},
},
@@ -23,8 +23,8 @@ func TestStructToProtoToStruct(t *testing.T) {
}{
{
name: "password",
pb: &authpb.PasswordAccountAttributes{Username: "testun", Password: &wrapperspb.StringValue{Value: "testpw"}},
wantJson: `{"username": "testun", "password": "testpw"}`,
pb: &authpb.PasswordAccountAttributes{LoginName: "testun", Password: &wrapperspb.StringValue{Value: "testpw"}},
wantJson: `{"login_name": "testun", "password": "testpw"}`,
},
{
name: "ec2hostcatalog",
+4 -4
View File
@@ -117,8 +117,8 @@ type TestControllerOpts struct {
// DefaultAuthMethodId is the default auth method ID to use, if set.
DefaultAuthMethodId string
// DefaultUsername is the username used when creating the default account.
DefaultUsername string
// DefaultLoginName is the login name used when creating the default account.
DefaultLoginName string
// DefaultPassword is the password used when creating the default account.
DefaultPassword string
@@ -174,8 +174,8 @@ func NewTestController(t *testing.T, opts *TestControllerOpts) *TestController {
if opts.DefaultAuthMethodId != "" {
tc.b.DevAuthMethodId = opts.DefaultAuthMethodId
}
if opts.DefaultUsername != "" {
tc.b.DevUsername = opts.DefaultUsername
if opts.DefaultLoginName != "" {
tc.b.DevLoginName = opts.DefaultLoginName
}
if opts.DefaultPassword != "" {
tc.b.DevPassword = opts.DefaultPassword