Merge pull request #695 from rithujohn191/add-list-password

api: add call to list passwords
This commit is contained in:
rithu leena john 2016-11-17 17:23:32 -08:00 committed by GitHub
commit 04360fa354
10 changed files with 242 additions and 44 deletions

View File

@ -21,6 +21,8 @@ It has these top-level messages:
UpdatePasswordResp UpdatePasswordResp
DeletePasswordReq DeletePasswordReq
DeletePasswordResp DeletePasswordResp
ListPasswordReq
ListPasswordResp
VersionReq VersionReq
VersionResp VersionResp
*/ */
@ -202,6 +204,32 @@ func (m *DeletePasswordResp) String() string { return proto.CompactTe
func (*DeletePasswordResp) ProtoMessage() {} func (*DeletePasswordResp) ProtoMessage() {}
func (*DeletePasswordResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } func (*DeletePasswordResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
// ListPasswordReq is a request to enumerate passwords.
type ListPasswordReq struct {
}
func (m *ListPasswordReq) Reset() { *m = ListPasswordReq{} }
func (m *ListPasswordReq) String() string { return proto.CompactTextString(m) }
func (*ListPasswordReq) ProtoMessage() {}
func (*ListPasswordReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
// ListPasswordResp returs a list of passwords.
type ListPasswordResp struct {
Passwords []*Password `protobuf:"bytes,1,rep,name=passwords" json:"passwords,omitempty"`
}
func (m *ListPasswordResp) Reset() { *m = ListPasswordResp{} }
func (m *ListPasswordResp) String() string { return proto.CompactTextString(m) }
func (*ListPasswordResp) ProtoMessage() {}
func (*ListPasswordResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
func (m *ListPasswordResp) GetPasswords() []*Password {
if m != nil {
return m.Passwords
}
return nil
}
// VersionReq is a request to fetch version info. // VersionReq is a request to fetch version info.
type VersionReq struct { type VersionReq struct {
} }
@ -209,7 +237,7 @@ type VersionReq struct {
func (m *VersionReq) Reset() { *m = VersionReq{} } func (m *VersionReq) Reset() { *m = VersionReq{} }
func (m *VersionReq) String() string { return proto.CompactTextString(m) } func (m *VersionReq) String() string { return proto.CompactTextString(m) }
func (*VersionReq) ProtoMessage() {} func (*VersionReq) ProtoMessage() {}
func (*VersionReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } func (*VersionReq) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
// VersionResp holds the version info of components. // VersionResp holds the version info of components.
type VersionResp struct { type VersionResp struct {
@ -223,7 +251,7 @@ type VersionResp struct {
func (m *VersionResp) Reset() { *m = VersionResp{} } func (m *VersionResp) Reset() { *m = VersionResp{} }
func (m *VersionResp) String() string { return proto.CompactTextString(m) } func (m *VersionResp) String() string { return proto.CompactTextString(m) }
func (*VersionResp) ProtoMessage() {} func (*VersionResp) ProtoMessage() {}
func (*VersionResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } func (*VersionResp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
func init() { func init() {
proto.RegisterType((*Client)(nil), "api.Client") proto.RegisterType((*Client)(nil), "api.Client")
@ -238,6 +266,8 @@ func init() {
proto.RegisterType((*UpdatePasswordResp)(nil), "api.UpdatePasswordResp") proto.RegisterType((*UpdatePasswordResp)(nil), "api.UpdatePasswordResp")
proto.RegisterType((*DeletePasswordReq)(nil), "api.DeletePasswordReq") proto.RegisterType((*DeletePasswordReq)(nil), "api.DeletePasswordReq")
proto.RegisterType((*DeletePasswordResp)(nil), "api.DeletePasswordResp") proto.RegisterType((*DeletePasswordResp)(nil), "api.DeletePasswordResp")
proto.RegisterType((*ListPasswordReq)(nil), "api.ListPasswordReq")
proto.RegisterType((*ListPasswordResp)(nil), "api.ListPasswordResp")
proto.RegisterType((*VersionReq)(nil), "api.VersionReq") proto.RegisterType((*VersionReq)(nil), "api.VersionReq")
proto.RegisterType((*VersionResp)(nil), "api.VersionResp") proto.RegisterType((*VersionResp)(nil), "api.VersionResp")
} }
@ -263,6 +293,8 @@ type DexClient interface {
UpdatePassword(ctx context.Context, in *UpdatePasswordReq, opts ...grpc.CallOption) (*UpdatePasswordResp, error) UpdatePassword(ctx context.Context, in *UpdatePasswordReq, opts ...grpc.CallOption) (*UpdatePasswordResp, error)
// DeletePassword deletes the password. // DeletePassword deletes the password.
DeletePassword(ctx context.Context, in *DeletePasswordReq, opts ...grpc.CallOption) (*DeletePasswordResp, error) DeletePassword(ctx context.Context, in *DeletePasswordReq, opts ...grpc.CallOption) (*DeletePasswordResp, error)
// ListPassword lists all password entries.
ListPasswords(ctx context.Context, in *ListPasswordReq, opts ...grpc.CallOption) (*ListPasswordResp, error)
// GetVersion returns version information of the server. // GetVersion returns version information of the server.
GetVersion(ctx context.Context, in *VersionReq, opts ...grpc.CallOption) (*VersionResp, error) GetVersion(ctx context.Context, in *VersionReq, opts ...grpc.CallOption) (*VersionResp, error)
} }
@ -320,6 +352,15 @@ func (c *dexClient) DeletePassword(ctx context.Context, in *DeletePasswordReq, o
return out, nil return out, nil
} }
func (c *dexClient) ListPasswords(ctx context.Context, in *ListPasswordReq, opts ...grpc.CallOption) (*ListPasswordResp, error) {
out := new(ListPasswordResp)
err := grpc.Invoke(ctx, "/api.Dex/ListPasswords", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *dexClient) GetVersion(ctx context.Context, in *VersionReq, opts ...grpc.CallOption) (*VersionResp, error) { func (c *dexClient) GetVersion(ctx context.Context, in *VersionReq, opts ...grpc.CallOption) (*VersionResp, error) {
out := new(VersionResp) out := new(VersionResp)
err := grpc.Invoke(ctx, "/api.Dex/GetVersion", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/api.Dex/GetVersion", in, out, c.cc, opts...)
@ -342,6 +383,8 @@ type DexServer interface {
UpdatePassword(context.Context, *UpdatePasswordReq) (*UpdatePasswordResp, error) UpdatePassword(context.Context, *UpdatePasswordReq) (*UpdatePasswordResp, error)
// DeletePassword deletes the password. // DeletePassword deletes the password.
DeletePassword(context.Context, *DeletePasswordReq) (*DeletePasswordResp, error) DeletePassword(context.Context, *DeletePasswordReq) (*DeletePasswordResp, error)
// ListPassword lists all password entries.
ListPasswords(context.Context, *ListPasswordReq) (*ListPasswordResp, error)
// GetVersion returns version information of the server. // GetVersion returns version information of the server.
GetVersion(context.Context, *VersionReq) (*VersionResp, error) GetVersion(context.Context, *VersionReq) (*VersionResp, error)
} }
@ -440,6 +483,24 @@ func _Dex_DeletePassword_Handler(srv interface{}, ctx context.Context, dec func(
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Dex_ListPasswords_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListPasswordReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DexServer).ListPasswords(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/api.Dex/ListPasswords",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DexServer).ListPasswords(ctx, req.(*ListPasswordReq))
}
return interceptor(ctx, in, info, handler)
}
func _Dex_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Dex_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VersionReq) in := new(VersionReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -482,6 +543,10 @@ var _Dex_serviceDesc = grpc.ServiceDesc{
MethodName: "DeletePassword", MethodName: "DeletePassword",
Handler: _Dex_DeletePassword_Handler, Handler: _Dex_DeletePassword_Handler,
}, },
{
MethodName: "ListPasswords",
Handler: _Dex_ListPasswords_Handler,
},
{ {
MethodName: "GetVersion", MethodName: "GetVersion",
Handler: _Dex_GetVersion_Handler, Handler: _Dex_GetVersion_Handler,
@ -494,42 +559,45 @@ var _Dex_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("api/api.proto", fileDescriptor0) } func init() { proto.RegisterFile("api/api.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 579 bytes of a gzipped FileDescriptorProto // 625 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x54, 0xcb, 0x6e, 0xdb, 0x3a, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x55, 0x4f, 0x4f, 0xdb, 0x4e,
0x10, 0x8d, 0x2d, 0x3f, 0xe4, 0xf1, 0x9b, 0xc8, 0x4d, 0x14, 0xdf, 0x8d, 0xc3, 0xa0, 0x80, 0xb3, 0x10, 0x4d, 0x62, 0x48, 0x9c, 0x49, 0x42, 0x92, 0x11, 0x3f, 0x30, 0xf9, 0x5d, 0x60, 0x51, 0x25,
0x49, 0x90, 0x14, 0x68, 0x17, 0x45, 0xbb, 0x71, 0xfa, 0xda, 0x05, 0x02, 0xdc, 0x65, 0x05, 0xc5, 0x50, 0x25, 0x10, 0x54, 0x6a, 0x0f, 0x55, 0xe9, 0x01, 0xfa, 0x4f, 0xea, 0x01, 0x59, 0x4a, 0x8f,
0x9a, 0x26, 0x04, 0x14, 0x89, 0x21, 0xa9, 0x3a, 0xfd, 0x80, 0x7e, 0x58, 0xff, 0xac, 0x20, 0x45, 0xb5, 0x4c, 0x3c, 0x85, 0x95, 0x8c, 0xbd, 0xdd, 0xb5, 0x1b, 0xfa, 0xf1, 0x7a, 0xe8, 0xf7, 0xaa,
0xbb, 0x92, 0xec, 0xc2, 0xdd, 0xf1, 0x1c, 0xce, 0x9c, 0xd1, 0xcc, 0x19, 0x0a, 0xfa, 0x21, 0x67, 0x76, 0xbd, 0x09, 0xb6, 0x43, 0x95, 0xde, 0xfc, 0xde, 0xce, 0xbc, 0xd9, 0x79, 0x33, 0x9b, 0xc0,
0x97, 0x21, 0x67, 0x17, 0x5c, 0xa4, 0x2a, 0x25, 0x4e, 0xc8, 0x19, 0xfd, 0x55, 0x83, 0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 0x43, 0x13, 0xf8, 0xc7, 0xac, 0xc9, 0xa8, 0x4c, 0xe8, 0x94, 0xfb, 0x24, 0xbf, 0x10, 0xa9, 0x8e, 0xdd, 0x8a, 0xac, 0x2c, 0x9d, 0x15, 0x59, 0xdd, 0x91, 0x42,
0xbb, 0x96, 0xf9, 0xd9, 0xbe, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x72, 0xb9, 0x88, 0x7f, 0x7d, 0xa4, 0x3a, 0x5d, 0x2b, 0xb2, 0xb2, 0x1d, 0x56, 0x64, 0x75, 0x15, 0x58, 0x03, 0x2f, 0x60, 0x50,
0x05, 0x00, 0x00, 0x1e, 0xae, 0xb2, 0x76, 0xd4, 0x76, 0xc0, 0xda, 0x51, 0x5f, 0x03, 0xd6, 0xc0, 0x33, 0x80, 0x0f,
0x94, 0xd9, 0x81, 0xe2, 0xd0, 0x84, 0x3d, 0x0e, 0x7b, 0x32, 0xaa, 0x12, 0x3a, 0xe5, 0xa6, 0x6d,
0xfe, 0x00, 0x5e, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0x34, 0x14, 0x6b, 0x5d, 0x11, 0x06, 0x00,
0x00,
} }

View File

@ -80,6 +80,14 @@ message DeletePasswordResp {
bool not_found = 1; bool not_found = 1;
} }
// ListPasswordReq is a request to enumerate passwords.
message ListPasswordReq {}
// ListPasswordResp returs a list of passwords.
message ListPasswordResp {
repeated Password passwords = 1;
}
// VersionReq is a request to fetch version info. // VersionReq is a request to fetch version info.
message VersionReq {} message VersionReq {}
@ -104,6 +112,8 @@ service Dex {
rpc UpdatePassword(UpdatePasswordReq) returns (UpdatePasswordResp) {}; rpc UpdatePassword(UpdatePasswordReq) returns (UpdatePasswordResp) {};
// DeletePassword deletes the password. // DeletePassword deletes the password.
rpc DeletePassword(DeletePasswordReq) returns (DeletePasswordResp) {}; rpc DeletePassword(DeletePasswordReq) returns (DeletePasswordResp) {};
// ListPassword lists all password entries.
rpc ListPasswords(ListPasswordReq) returns (ListPasswordResp) {};
// GetVersion returns version information of the server. // GetVersion returns version information of the server.
rpc GetVersion(VersionReq) returns (VersionResp) {}; rpc GetVersion(VersionReq) returns (VersionResp) {};
} }

View File

@ -171,3 +171,26 @@ func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.Versi
Api: apiVersion, Api: apiVersion,
}, nil }, nil
} }
func (d dexAPI) ListPasswords(ctx context.Context, req *api.ListPasswordReq) (*api.ListPasswordResp, error) {
passwordList, err := d.s.ListPasswords()
if err != nil {
log.Printf("api: failed to list passwords: %v", err)
return nil, fmt.Errorf("list passwords: %v", err)
}
var passwords []*api.Password
for _, password := range passwordList {
p := api.Password{
Email: password.Email,
Username: password.Username,
UserId: password.UserID,
}
passwords = append(passwords, &p)
}
return &api.ListPasswordResp{
Passwords: passwords,
}, nil
}

View File

@ -5,6 +5,7 @@ package conformance
import ( import (
"reflect" "reflect"
"sort"
"testing" "testing"
"time" "time"
@ -244,6 +245,12 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
} }
} }
type byEmail []storage.Password
func (n byEmail) Len() int { return len(n) }
func (n byEmail) Less(i, j int) bool { return n[i].Email < n[j].Email }
func (n byEmail) Swap(i, j int) { n[i], n[j] = n[j], n[i] }
func testPasswordCRUD(t *testing.T, s storage.Storage) { func testPasswordCRUD(t *testing.T, s storage.Storage) {
// Use bcrypt.MinCost to keep the tests short. // Use bcrypt.MinCost to keep the tests short.
passwordHash, err := bcrypt.GenerateFromPassword([]byte("secret"), bcrypt.MinCost) passwordHash, err := bcrypt.GenerateFromPassword([]byte("secret"), bcrypt.MinCost)
@ -285,6 +292,24 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
password.Username = "jane doe" password.Username = "jane doe"
getAndCompare("jane@example.com", password) getAndCompare("jane@example.com", password)
var passwordList []storage.Password
passwordList = append(passwordList, password)
listAndCompare := func(want []storage.Password) {
passwords, err := s.ListPasswords()
if err != nil {
t.Errorf("list password: %v", err)
return
}
sort.Sort(byEmail(want))
sort.Sort(byEmail(passwords))
if diff := pretty.Compare(want, passwords); diff != "" {
t.Errorf("password list retrieved from storage did not match: %s", diff)
}
}
listAndCompare(passwordList)
if err := s.DeletePassword(password.Email); err != nil { if err := s.DeletePassword(password.Email); err != nil {
t.Fatalf("failed to delete password: %v", err) t.Fatalf("failed to delete password: %v", err)
} }
@ -292,6 +317,7 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
if _, err := s.GetPassword(password.Email); err != storage.ErrNotFound { if _, err := s.GetPassword(password.Email); err != storage.ErrNotFound {
t.Errorf("after deleting password expected storage.ErrNotFound, got %v", err) t.Errorf("after deleting password expected storage.ErrNotFound, got %v", err)
} }
} }
func testKeysCRUD(t *testing.T, s storage.Storage) { func testKeysCRUD(t *testing.T, s storage.Storage) {

View File

@ -260,6 +260,25 @@ func (cli *client) ListRefreshTokens() ([]storage.RefreshToken, error) {
return nil, errors.New("not implemented") return nil, errors.New("not implemented")
} }
func (cli *client) ListPasswords() (passwords []storage.Password, err error) {
var passwordList PasswordList
if err = cli.list(resourcePassword, &passwordList); err != nil {
return passwords, fmt.Errorf("failed to list passwords: %v", err)
}
for _, password := range passwordList.Passwords {
p := storage.Password{
Email: password.Email,
Hash: password.Hash,
Username: password.Username,
UserID: password.UserID,
}
passwords = append(passwords, p)
}
return
}
func (cli *client) DeleteAuthRequest(id string) error { func (cli *client) DeleteAuthRequest(id string) error {
return cli.delete(resourceAuthRequest, id) return cli.delete(resourceAuthRequest, id)
} }

View File

@ -259,6 +259,13 @@ type Password struct {
UserID string `json:"userID,omitempty"` UserID string `json:"userID,omitempty"`
} }
// PasswordList is a list of Passwords.
type PasswordList struct {
k8sapi.TypeMeta `json:",inline"`
k8sapi.ListMeta `json:"metadata,omitempty"`
Passwords []Password `json:"items"`
}
func (cli *client) fromStoragePassword(p storage.Password) Password { func (cli *client) fromStoragePassword(p storage.Password) Password {
email := strings.ToLower(p.Email) email := strings.ToLower(p.Email)
return Password{ return Password{

View File

@ -192,6 +192,15 @@ func (s *memStorage) ListRefreshTokens() (tokens []storage.RefreshToken, err err
return return
} }
func (s *memStorage) ListPasswords() (passwords []storage.Password, err error) {
s.tx(func() {
for _, password := range s.passwords {
passwords = append(passwords, password)
}
})
return
}
func (s *memStorage) DeletePassword(email string) (err error) { func (s *memStorage) DeletePassword(email string) (err error) {
email = strings.ToLower(email) email = strings.ToLower(email)
s.tx(func() { s.tx(func() {

View File

@ -532,12 +532,39 @@ func (c *conn) GetPassword(email string) (storage.Password, error) {
} }
func getPassword(q querier, email string) (p storage.Password, err error) { func getPassword(q querier, email string) (p storage.Password, err error) {
email = strings.ToLower(email) return scanPassword(q.QueryRow(`
err = q.QueryRow(`
select select
email, hash, username, user_id email, hash, username, user_id
from password where email = $1; from password where email = $1;
`, email).Scan( `, strings.ToLower(email)))
}
func (c *conn) ListPasswords() ([]storage.Password, error) {
rows, err := c.Query(`
select
email, hash, username, user_id
from password;
`)
if err != nil {
return nil, err
}
var passwords []storage.Password
for rows.Next() {
p, err := scanPassword(rows)
if err != nil {
return nil, err
}
passwords = append(passwords, p)
}
if err := rows.Err(); err != nil {
return nil, err
}
return passwords, nil
}
func scanPassword(s scanner) (p storage.Password, err error) {
err = s.Scan(
&p.Email, &p.Hash, &p.Username, &p.UserID, &p.Email, &p.Hash, &p.Username, &p.UserID,
) )
if err != nil { if err != nil {

View File

@ -60,6 +60,8 @@ func (s staticClientsStorage) UpdateClient(id string, updater func(old Client) (
type staticPasswordsStorage struct { type staticPasswordsStorage struct {
Storage Storage
// A read-only set of passwords.
passwords []Password
passwordsByEmail map[string]Password passwordsByEmail map[string]Password
} }
@ -71,7 +73,7 @@ func WithStaticPasswords(s Storage, staticPasswords []Password) Storage {
p.Email = strings.ToLower(p.Email) p.Email = strings.ToLower(p.Email)
passwordsByEmail[p.Email] = p passwordsByEmail[p.Email] = p
} }
return staticPasswordsStorage{s, passwordsByEmail} return staticPasswordsStorage{s, staticPasswords, passwordsByEmail}
} }
func (s staticPasswordsStorage) GetPassword(email string) (Password, error) { func (s staticPasswordsStorage) GetPassword(email string) (Password, error) {
@ -81,6 +83,12 @@ func (s staticPasswordsStorage) GetPassword(email string) (Password, error) {
return Password{}, ErrNotFound return Password{}, ErrNotFound
} }
func (s staticPasswordsStorage) ListPasswords() ([]Password, error) {
passwords := make([]Password, len(s.passwords))
copy(passwords, s.passwords)
return passwords, nil
}
func (s staticPasswordsStorage) CreatePassword(p Password) error { func (s staticPasswordsStorage) CreatePassword(p Password) error {
return errors.New("static passwords: read-only cannot create password") return errors.New("static passwords: read-only cannot create password")
} }

View File

@ -70,6 +70,7 @@ type Storage interface {
ListClients() ([]Client, error) ListClients() ([]Client, error)
ListRefreshTokens() ([]RefreshToken, error) ListRefreshTokens() ([]RefreshToken, error)
ListPasswords() ([]Password, error)
// Delete methods MUST be atomic. // Delete methods MUST be atomic.
DeleteAuthRequest(id string) error DeleteAuthRequest(id string) error