GODT-1609: use byte array for password

This commit is contained in:
Romain LE JEUNE
2022-10-03 21:12:00 +02:00
committed by James Houlahan
parent 3b5f931f06
commit b536b8707e
20 changed files with 64 additions and 73 deletions

View File

@ -468,7 +468,7 @@ type LoginRequest struct {
unknownFields protoimpl.UnknownFields
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
Password []byte `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
}
func (x *LoginRequest) Reset() {
@ -510,11 +510,11 @@ func (x *LoginRequest) GetUsername() string {
return ""
}
func (x *LoginRequest) GetPassword() string {
func (x *LoginRequest) GetPassword() []byte {
if x != nil {
return x.Password
}
return ""
return nil
}
type LoginAbortRequest struct {
@ -738,7 +738,7 @@ type User struct {
SetupGuideSeen bool `protobuf:"varint,6,opt,name=setupGuideSeen,proto3" json:"setupGuideSeen,omitempty"`
UsedBytes int64 `protobuf:"varint,7,opt,name=usedBytes,proto3" json:"usedBytes,omitempty"`
TotalBytes int64 `protobuf:"varint,8,opt,name=totalBytes,proto3" json:"totalBytes,omitempty"`
Password string `protobuf:"bytes,9,opt,name=password,proto3" json:"password,omitempty"`
Password []byte `protobuf:"bytes,9,opt,name=password,proto3" json:"password,omitempty"`
Addresses []string `protobuf:"bytes,10,rep,name=addresses,proto3" json:"addresses,omitempty"`
}
@ -830,11 +830,11 @@ func (x *User) GetTotalBytes() int64 {
return 0
}
func (x *User) GetPassword() string {
func (x *User) GetPassword() []byte {
if x != nil {
return x.Password
}
return ""
return nil
}
func (x *User) GetAddresses() []string {
@ -3727,7 +3727,7 @@ var file_bridge_proto_rawDesc = []byte{
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x75, 0x73, 0x65, 0x72, 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, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73,
0x77, 0x6f, 0x72, 0x64, 0x22, 0x2f, 0x0a, 0x11, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x41, 0x62, 0x6f,
0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65,
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65,
@ -3760,7 +3760,7 @@ var file_bridge_proto_rawDesc = []byte{
0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x79,
0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c,
0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x0a,
0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22,
0x46, 0x0a, 0x14, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x4d, 0x6f, 0x64, 0x65,

View File

@ -148,7 +148,7 @@ message ReportBugRequest {
message LoginRequest {
string username = 1;
string password = 2;
bytes password = 2;
}
message LoginAbortRequest {
@ -189,7 +189,7 @@ message User {
bool setupGuideSeen = 6;
int64 usedBytes = 7;
int64 totalBytes = 8;
string password = 9;
bytes password = 9;
repeated string addresses = 10;
}

View File

@ -356,8 +356,8 @@ func (s *Service) Login(ctx context.Context, login *LoginRequest) (*emptypb.Empt
go func() {
defer s.panicHandler.HandlePanic()
password, err := base64.StdEncoding.DecodeString(login.Password)
var password []byte
_, err := base64.StdEncoding.Decode(password, login.Password)
if err != nil {
s.log.WithError(err).Error("Cannot decode password")
_ = s.SendEvent(NewLoginError(LoginErrorType_USERNAME_PASSWORD_ERROR, "Cannot decode password"))
@ -368,7 +368,7 @@ func (s *Service) Login(ctx context.Context, login *LoginRequest) (*emptypb.Empt
// - bad credentials
// - bad proton plan
// - user already exists
userID, err := s.bridge.LoginUser(context.Background(), login.Username, string(password), nil, nil)
userID, err := s.bridge.LoginUser(context.Background(), login.Username, password, nil, nil)
if err != nil {
s.log.WithError(err).Error("Cannot login user")
_ = s.SendEvent(NewLoginError(LoginErrorType_USERNAME_PASSWORD_ERROR, "Cannot login user"))