mirror of https://github.com/mitchell/selfpass.git
Modify sp and services to use the protobuf module
This commit is contained in:
parent
66ec035ee0
commit
4fc74b0994
|
@ -15,8 +15,8 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
protobuf "github.com/mitchell/selfpass/protobuf/go"
|
||||
"github.com/mitchell/selfpass/services/credentials/middleware"
|
||||
"github.com/mitchell/selfpass/services/credentials/protobuf"
|
||||
"github.com/mitchell/selfpass/services/credentials/repositories"
|
||||
"github.com/mitchell/selfpass/services/credentials/service"
|
||||
"github.com/mitchell/selfpass/services/credentials/transport"
|
||||
|
@ -68,7 +68,7 @@ func main() {
|
|||
|
||||
gsrv := transport.NewGRPCServer(svc, logger)
|
||||
srv := grpc.NewServer(grpc.Creds(creds))
|
||||
protobuf.RegisterCredentialServiceServer(srv, gsrv)
|
||||
protobuf.RegisterCredentialsServer(srv, gsrv)
|
||||
|
||||
addr := ":" + *port
|
||||
lis, err := net.Listen("tcp", addr)
|
||||
|
|
|
@ -30,7 +30,7 @@ func MakeGetEndpoint(svc types.Service) endpoint.Endpoint {
|
|||
|
||||
func MakeGetAllMetadataEndpoint(svc types.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (response interface{}, err error) {
|
||||
r := request.(GetAllMetadataRequest)
|
||||
r := request.(SourceHostRequest)
|
||||
|
||||
mdch, errch := svc.GetAllMetadata(ctx, r.SourceHost)
|
||||
|
||||
|
@ -48,13 +48,6 @@ func MakeUpdateEndpoint(svc types.Service) endpoint.Endpoint {
|
|||
}
|
||||
}
|
||||
|
||||
func MakeDumpEndpoint(svc types.Service) endpoint.Endpoint {
|
||||
return func(ctx context.Context, request interface{}) (response interface{}, err error) {
|
||||
contents, err := svc.DumpDB(ctx)
|
||||
return DumpResponse{Contents: contents}, err
|
||||
}
|
||||
}
|
||||
|
||||
type DumpResponse struct {
|
||||
Contents []byte
|
||||
}
|
||||
|
@ -63,7 +56,7 @@ type IDRequest struct {
|
|||
ID string
|
||||
}
|
||||
|
||||
type GetAllMetadataRequest struct {
|
||||
type SourceHostRequest struct {
|
||||
SourceHost string
|
||||
}
|
||||
|
||||
|
|
|
@ -1,867 +0,0 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: credentials/protobuf/service.proto
|
||||
|
||||
package protobuf
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type DeleteResponse struct {
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteResponse) Reset() { *m = DeleteResponse{} }
|
||||
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteResponse) ProtoMessage() {}
|
||||
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{0}
|
||||
}
|
||||
|
||||
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteResponse.Merge(m, src)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteResponse.Size(m)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *DeleteResponse) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type GetAllMetadataRequest struct {
|
||||
SourceHost string `protobuf:"bytes,1,opt,name=source_host,json=sourceHost,proto3" json:"source_host,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetAllMetadataRequest) Reset() { *m = GetAllMetadataRequest{} }
|
||||
func (m *GetAllMetadataRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetAllMetadataRequest) ProtoMessage() {}
|
||||
func (*GetAllMetadataRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{1}
|
||||
}
|
||||
|
||||
func (m *GetAllMetadataRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetAllMetadataRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetAllMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetAllMetadataRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetAllMetadataRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetAllMetadataRequest.Merge(m, src)
|
||||
}
|
||||
func (m *GetAllMetadataRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_GetAllMetadataRequest.Size(m)
|
||||
}
|
||||
func (m *GetAllMetadataRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetAllMetadataRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetAllMetadataRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *GetAllMetadataRequest) GetSourceHost() string {
|
||||
if m != nil {
|
||||
return m.SourceHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type IdRequest struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *IdRequest) Reset() { *m = IdRequest{} }
|
||||
func (m *IdRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*IdRequest) ProtoMessage() {}
|
||||
func (*IdRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{2}
|
||||
}
|
||||
|
||||
func (m *IdRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_IdRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *IdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_IdRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *IdRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_IdRequest.Merge(m, src)
|
||||
}
|
||||
func (m *IdRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_IdRequest.Size(m)
|
||||
}
|
||||
func (m *IdRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_IdRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_IdRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *IdRequest) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Credential *CredentialRequest `protobuf:"bytes,2,opt,name=credential,proto3" json:"credential,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UpdateRequest) Reset() { *m = UpdateRequest{} }
|
||||
func (m *UpdateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*UpdateRequest) ProtoMessage() {}
|
||||
func (*UpdateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{3}
|
||||
}
|
||||
|
||||
func (m *UpdateRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UpdateRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UpdateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UpdateRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *UpdateRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UpdateRequest.Merge(m, src)
|
||||
}
|
||||
func (m *UpdateRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_UpdateRequest.Size(m)
|
||||
}
|
||||
func (m *UpdateRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UpdateRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UpdateRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *UpdateRequest) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateRequest) GetCredential() *CredentialRequest {
|
||||
if m != nil {
|
||||
return m.Credential
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DumpResponse struct {
|
||||
Contents []byte `protobuf:"bytes,1,opt,name=contents,proto3" json:"contents,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DumpResponse) Reset() { *m = DumpResponse{} }
|
||||
func (m *DumpResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DumpResponse) ProtoMessage() {}
|
||||
func (*DumpResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{4}
|
||||
}
|
||||
|
||||
func (m *DumpResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DumpResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DumpResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DumpResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DumpResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DumpResponse.Merge(m, src)
|
||||
}
|
||||
func (m *DumpResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_DumpResponse.Size(m)
|
||||
}
|
||||
func (m *DumpResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DumpResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DumpResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *DumpResponse) GetContents() []byte {
|
||||
if m != nil {
|
||||
return m.Contents
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EmptyRequest struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EmptyRequest) Reset() { *m = EmptyRequest{} }
|
||||
func (m *EmptyRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*EmptyRequest) ProtoMessage() {}
|
||||
func (*EmptyRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{5}
|
||||
}
|
||||
|
||||
func (m *EmptyRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EmptyRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EmptyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EmptyRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *EmptyRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EmptyRequest.Merge(m, src)
|
||||
}
|
||||
func (m *EmptyRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_EmptyRequest.Size(m)
|
||||
}
|
||||
func (m *EmptyRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EmptyRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EmptyRequest proto.InternalMessageInfo
|
||||
|
||||
type Metadata struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
CreatedAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
|
||||
UpdatedAt *timestamp.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
|
||||
Primary string `protobuf:"bytes,4,opt,name=primary,proto3" json:"primary,omitempty"`
|
||||
SourceHost string `protobuf:"bytes,5,opt,name=source_host,json=sourceHost,proto3" json:"source_host,omitempty"`
|
||||
LoginUrl string `protobuf:"bytes,6,opt,name=login_url,json=loginUrl,proto3" json:"login_url,omitempty"`
|
||||
Tag string `protobuf:"bytes,7,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Metadata) Reset() { *m = Metadata{} }
|
||||
func (m *Metadata) String() string { return proto.CompactTextString(m) }
|
||||
func (*Metadata) ProtoMessage() {}
|
||||
func (*Metadata) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{6}
|
||||
}
|
||||
|
||||
func (m *Metadata) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Metadata.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Metadata.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Metadata) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Metadata.Merge(m, src)
|
||||
}
|
||||
func (m *Metadata) XXX_Size() int {
|
||||
return xxx_messageInfo_Metadata.Size(m)
|
||||
}
|
||||
func (m *Metadata) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Metadata.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Metadata proto.InternalMessageInfo
|
||||
|
||||
func (m *Metadata) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetCreatedAt() *timestamp.Timestamp {
|
||||
if m != nil {
|
||||
return m.CreatedAt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Metadata) GetUpdatedAt() *timestamp.Timestamp {
|
||||
if m != nil {
|
||||
return m.UpdatedAt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Metadata) GetPrimary() string {
|
||||
if m != nil {
|
||||
return m.Primary
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetSourceHost() string {
|
||||
if m != nil {
|
||||
return m.SourceHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetLoginUrl() string {
|
||||
if m != nil {
|
||||
return m.LoginUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetTag() string {
|
||||
if m != nil {
|
||||
return m.Tag
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Credential struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
CreatedAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
|
||||
UpdatedAt *timestamp.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
|
||||
Primary string `protobuf:"bytes,4,opt,name=primary,proto3" json:"primary,omitempty"`
|
||||
Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username,omitempty"`
|
||||
Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,7,opt,name=password,proto3" json:"password,omitempty"`
|
||||
SourceHost string `protobuf:"bytes,8,opt,name=source_host,json=sourceHost,proto3" json:"source_host,omitempty"`
|
||||
LoginUrl string `protobuf:"bytes,9,opt,name=login_url,json=loginUrl,proto3" json:"login_url,omitempty"`
|
||||
Tag string `protobuf:"bytes,10,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||
OtpSecret string `protobuf:"bytes,11,opt,name=otp_secret,json=otpSecret,proto3" json:"otp_secret,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Credential) Reset() { *m = Credential{} }
|
||||
func (m *Credential) String() string { return proto.CompactTextString(m) }
|
||||
func (*Credential) ProtoMessage() {}
|
||||
func (*Credential) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{7}
|
||||
}
|
||||
|
||||
func (m *Credential) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Credential.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Credential) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Credential.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Credential) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Credential.Merge(m, src)
|
||||
}
|
||||
func (m *Credential) XXX_Size() int {
|
||||
return xxx_messageInfo_Credential.Size(m)
|
||||
}
|
||||
func (m *Credential) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Credential.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Credential proto.InternalMessageInfo
|
||||
|
||||
func (m *Credential) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetCreatedAt() *timestamp.Timestamp {
|
||||
if m != nil {
|
||||
return m.CreatedAt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Credential) GetUpdatedAt() *timestamp.Timestamp {
|
||||
if m != nil {
|
||||
return m.UpdatedAt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Credential) GetPrimary() string {
|
||||
if m != nil {
|
||||
return m.Primary
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetUsername() string {
|
||||
if m != nil {
|
||||
return m.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetEmail() string {
|
||||
if m != nil {
|
||||
return m.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetPassword() string {
|
||||
if m != nil {
|
||||
return m.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetSourceHost() string {
|
||||
if m != nil {
|
||||
return m.SourceHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetLoginUrl() string {
|
||||
if m != nil {
|
||||
return m.LoginUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetTag() string {
|
||||
if m != nil {
|
||||
return m.Tag
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Credential) GetOtpSecret() string {
|
||||
if m != nil {
|
||||
return m.OtpSecret
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CredentialRequest struct {
|
||||
Primary string `protobuf:"bytes,1,opt,name=primary,proto3" json:"primary,omitempty"`
|
||||
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
|
||||
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
|
||||
SourceHost string `protobuf:"bytes,5,opt,name=source_host,json=sourceHost,proto3" json:"source_host,omitempty"`
|
||||
LoginUrl string `protobuf:"bytes,6,opt,name=login_url,json=loginUrl,proto3" json:"login_url,omitempty"`
|
||||
Tag string `protobuf:"bytes,7,opt,name=tag,proto3" json:"tag,omitempty"`
|
||||
OtpSecret string `protobuf:"bytes,8,opt,name=otp_secret,json=otpSecret,proto3" json:"otp_secret,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) Reset() { *m = CredentialRequest{} }
|
||||
func (m *CredentialRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CredentialRequest) ProtoMessage() {}
|
||||
func (*CredentialRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ad34efc7bbd96e69, []int{8}
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CredentialRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *CredentialRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_CredentialRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *CredentialRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_CredentialRequest.Merge(m, src)
|
||||
}
|
||||
func (m *CredentialRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_CredentialRequest.Size(m)
|
||||
}
|
||||
func (m *CredentialRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_CredentialRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_CredentialRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *CredentialRequest) GetPrimary() string {
|
||||
if m != nil {
|
||||
return m.Primary
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetUsername() string {
|
||||
if m != nil {
|
||||
return m.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetEmail() string {
|
||||
if m != nil {
|
||||
return m.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetPassword() string {
|
||||
if m != nil {
|
||||
return m.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetSourceHost() string {
|
||||
if m != nil {
|
||||
return m.SourceHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetLoginUrl() string {
|
||||
if m != nil {
|
||||
return m.LoginUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetTag() string {
|
||||
if m != nil {
|
||||
return m.Tag
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CredentialRequest) GetOtpSecret() string {
|
||||
if m != nil {
|
||||
return m.OtpSecret
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*DeleteResponse)(nil), "selfpass.credentials.DeleteResponse")
|
||||
proto.RegisterType((*GetAllMetadataRequest)(nil), "selfpass.credentials.GetAllMetadataRequest")
|
||||
proto.RegisterType((*IdRequest)(nil), "selfpass.credentials.IdRequest")
|
||||
proto.RegisterType((*UpdateRequest)(nil), "selfpass.credentials.UpdateRequest")
|
||||
proto.RegisterType((*DumpResponse)(nil), "selfpass.credentials.DumpResponse")
|
||||
proto.RegisterType((*EmptyRequest)(nil), "selfpass.credentials.EmptyRequest")
|
||||
proto.RegisterType((*Metadata)(nil), "selfpass.credentials.Metadata")
|
||||
proto.RegisterType((*Credential)(nil), "selfpass.credentials.Credential")
|
||||
proto.RegisterType((*CredentialRequest)(nil), "selfpass.credentials.CredentialRequest")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("credentials/protobuf/service.proto", fileDescriptor_ad34efc7bbd96e69) }
|
||||
|
||||
var fileDescriptor_ad34efc7bbd96e69 = []byte{
|
||||
// 561 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0x4d, 0x6f, 0xd3, 0x4c,
|
||||
0x10, 0xc7, 0xe5, 0xa4, 0x4d, 0xed, 0x69, 0x9f, 0xe8, 0x61, 0x55, 0x24, 0xcb, 0x15, 0x24, 0x32,
|
||||
0x48, 0x54, 0x45, 0x72, 0x51, 0xb9, 0xc0, 0x31, 0xb4, 0x28, 0xe5, 0x80, 0x90, 0x1c, 0x7a, 0xe1,
|
||||
0x12, 0x6d, 0xed, 0x69, 0x6a, 0xc9, 0xf6, 0x9a, 0xdd, 0x31, 0xa8, 0x1f, 0x8c, 0x0f, 0x05, 0x1f,
|
||||
0x81, 0x13, 0xf2, 0xfa, 0x25, 0x2f, 0x75, 0x9a, 0x48, 0x5c, 0xb8, 0xed, 0x8c, 0xff, 0xb3, 0x9a,
|
||||
0xdf, 0xec, 0xee, 0xdf, 0xe0, 0x06, 0x12, 0x43, 0x4c, 0x29, 0xe2, 0xb1, 0x3a, 0xcd, 0xa4, 0x20,
|
||||
0x71, 0x9d, 0xdf, 0x9c, 0x2a, 0x94, 0xdf, 0xa2, 0x00, 0x3d, 0x9d, 0x60, 0x87, 0x0a, 0xe3, 0x9b,
|
||||
0x8c, 0x2b, 0xe5, 0x2d, 0x88, 0x9d, 0xc1, 0x4c, 0x88, 0x59, 0x8c, 0xf3, 0x22, 0x8a, 0x12, 0x54,
|
||||
0xc4, 0x93, 0xac, 0x2c, 0x73, 0x4f, 0xa0, 0x7f, 0x81, 0x31, 0x12, 0xfa, 0xa8, 0x32, 0x91, 0x2a,
|
||||
0x64, 0x36, 0xec, 0xa9, 0x3c, 0x08, 0x50, 0x29, 0xdb, 0x18, 0x1a, 0xc7, 0xa6, 0x5f, 0x87, 0xee,
|
||||
0x1b, 0x78, 0x3c, 0x46, 0x1a, 0xc5, 0xf1, 0x47, 0x24, 0x1e, 0x72, 0xe2, 0x3e, 0x7e, 0xcd, 0x51,
|
||||
0x11, 0x1b, 0xc0, 0xbe, 0x12, 0xb9, 0x0c, 0x70, 0x7a, 0x2b, 0x14, 0xe9, 0x32, 0xcb, 0x87, 0x32,
|
||||
0x75, 0x29, 0x14, 0xb9, 0x47, 0x60, 0x7d, 0x08, 0x6b, 0x75, 0x1f, 0x3a, 0x51, 0x58, 0x89, 0x3a,
|
||||
0x51, 0xe8, 0xde, 0xc2, 0x7f, 0x57, 0x59, 0xc8, 0x8b, 0x16, 0x5a, 0x05, 0x6c, 0x0c, 0x30, 0x67,
|
||||
0xb2, 0x3b, 0x43, 0xe3, 0x78, 0xff, 0xec, 0x85, 0xd7, 0xc6, 0xeb, 0x9d, 0x37, 0xeb, 0x6a, 0x33,
|
||||
0x7f, 0xa1, 0xd4, 0x3d, 0x81, 0x83, 0x8b, 0x3c, 0xc9, 0x1a, 0x54, 0x07, 0xcc, 0x40, 0xa4, 0x84,
|
||||
0x29, 0x95, 0xac, 0x07, 0x7e, 0x13, 0xbb, 0x7d, 0x38, 0x78, 0x9f, 0x64, 0x74, 0x57, 0xed, 0xe3,
|
||||
0xfe, 0x36, 0xc0, 0xac, 0xb9, 0xef, 0x75, 0xf8, 0x56, 0x77, 0xc8, 0x09, 0xc3, 0x29, 0xa7, 0xaa,
|
||||
0x43, 0xc7, 0x2b, 0x67, 0xef, 0xd5, 0xb3, 0xf7, 0x3e, 0xd7, 0xb3, 0xf7, 0xad, 0x4a, 0x3d, 0xa2,
|
||||
0xa2, 0x34, 0xd7, 0xf4, 0xba, 0xb4, 0xbb, 0xb9, 0xb4, 0x52, 0x8f, 0xa8, 0x38, 0xa9, 0x4c, 0x46,
|
||||
0x09, 0x97, 0x77, 0xf6, 0x8e, 0x6e, 0xa5, 0x0e, 0x57, 0x0f, 0x64, 0x77, 0xf5, 0x40, 0xd8, 0x11,
|
||||
0x58, 0xb1, 0x98, 0x45, 0xe9, 0x34, 0x97, 0xb1, 0xdd, 0xd3, 0x9f, 0x4d, 0x9d, 0xb8, 0x92, 0x31,
|
||||
0xfb, 0x1f, 0xba, 0xc4, 0x67, 0xf6, 0x9e, 0x4e, 0x17, 0x4b, 0xf7, 0x67, 0x07, 0x60, 0x3e, 0xda,
|
||||
0x7f, 0x1e, 0xdf, 0x01, 0x33, 0x57, 0x28, 0x53, 0x9e, 0x60, 0xc5, 0xde, 0xc4, 0xec, 0x10, 0x76,
|
||||
0x31, 0xe1, 0x51, 0x4d, 0x5d, 0x06, 0x45, 0x45, 0x71, 0x97, 0xbe, 0x0b, 0x19, 0x56, 0xdc, 0x4d,
|
||||
0xbc, 0x3a, 0x4c, 0xf3, 0xe1, 0x61, 0x5a, 0xed, 0xc3, 0x84, 0x66, 0x98, 0xec, 0x09, 0x80, 0xa0,
|
||||
0x6c, 0xaa, 0x30, 0x90, 0x48, 0xf6, 0xbe, 0xfe, 0x60, 0x09, 0xca, 0x26, 0x3a, 0xe1, 0xfe, 0x32,
|
||||
0xe0, 0xd1, 0xbd, 0x6b, 0xbc, 0x08, 0x6b, 0xac, 0x87, 0xed, 0xac, 0x83, 0xed, 0xae, 0x83, 0xdd,
|
||||
0x79, 0x18, 0xf6, 0x6f, 0x6f, 0xce, 0x0a, 0xac, 0xb9, 0x02, 0x7b, 0xf6, 0xa3, 0xbb, 0x08, 0x3b,
|
||||
0x29, 0x1d, 0x8d, 0x4d, 0xa1, 0xbf, 0x6c, 0x34, 0xec, 0x65, 0xfb, 0x73, 0x6f, 0xb5, 0x23, 0xe7,
|
||||
0x69, 0xbb, 0xb8, 0x96, 0xbd, 0x32, 0xd8, 0x25, 0x74, 0xc7, 0x48, 0x6c, 0xd0, 0x2e, 0x6c, 0xac,
|
||||
0xca, 0x19, 0x6e, 0x72, 0x19, 0x36, 0x81, 0xde, 0xb9, 0xbe, 0xcc, 0x6c, 0x5b, 0x47, 0xda, 0x62,
|
||||
0xd3, 0x4f, 0xd0, 0x2b, 0x1d, 0x91, 0x3d, 0x6b, 0xd7, 0x2e, 0xf9, 0xe5, 0x76, 0x1b, 0x96, 0x2e,
|
||||
0xbf, 0x19, 0xf9, 0x79, 0xbb, 0x60, 0xf9, 0x27, 0xf1, 0x0e, 0xbe, 0x98, 0xf5, 0xe3, 0xbc, 0xee,
|
||||
0xe9, 0xd5, 0xeb, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xde, 0x03, 0x4f, 0xb2, 0xa6, 0x06, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// CredentialServiceClient is the client API for CredentialService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type CredentialServiceClient interface {
|
||||
GetAllMetadata(ctx context.Context, in *GetAllMetadataRequest, opts ...grpc.CallOption) (CredentialService_GetAllMetadataClient, error)
|
||||
Get(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Credential, error)
|
||||
Create(ctx context.Context, in *CredentialRequest, opts ...grpc.CallOption) (*Credential, error)
|
||||
Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*Credential, error)
|
||||
Delete(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*DeleteResponse, error)
|
||||
}
|
||||
|
||||
type credentialServiceClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewCredentialServiceClient(cc *grpc.ClientConn) CredentialServiceClient {
|
||||
return &credentialServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *credentialServiceClient) GetAllMetadata(ctx context.Context, in *GetAllMetadataRequest, opts ...grpc.CallOption) (CredentialService_GetAllMetadataClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &_CredentialService_serviceDesc.Streams[0], "/selfpass.credentials.CredentialService/GetAllMetadata", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &credentialServiceGetAllMetadataClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type CredentialService_GetAllMetadataClient interface {
|
||||
Recv() (*Metadata, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type credentialServiceGetAllMetadataClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *credentialServiceGetAllMetadataClient) Recv() (*Metadata, error) {
|
||||
m := new(Metadata)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *credentialServiceClient) Get(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Credential, error) {
|
||||
out := new(Credential)
|
||||
err := c.cc.Invoke(ctx, "/selfpass.credentials.CredentialService/Get", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *credentialServiceClient) Create(ctx context.Context, in *CredentialRequest, opts ...grpc.CallOption) (*Credential, error) {
|
||||
out := new(Credential)
|
||||
err := c.cc.Invoke(ctx, "/selfpass.credentials.CredentialService/Create", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *credentialServiceClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*Credential, error) {
|
||||
out := new(Credential)
|
||||
err := c.cc.Invoke(ctx, "/selfpass.credentials.CredentialService/Update", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *credentialServiceClient) Delete(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*DeleteResponse, error) {
|
||||
out := new(DeleteResponse)
|
||||
err := c.cc.Invoke(ctx, "/selfpass.credentials.CredentialService/Delete", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// CredentialServiceServer is the server API for CredentialService service.
|
||||
type CredentialServiceServer interface {
|
||||
GetAllMetadata(*GetAllMetadataRequest, CredentialService_GetAllMetadataServer) error
|
||||
Get(context.Context, *IdRequest) (*Credential, error)
|
||||
Create(context.Context, *CredentialRequest) (*Credential, error)
|
||||
Update(context.Context, *UpdateRequest) (*Credential, error)
|
||||
Delete(context.Context, *IdRequest) (*DeleteResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedCredentialServiceServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedCredentialServiceServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedCredentialServiceServer) GetAllMetadata(req *GetAllMetadataRequest, srv CredentialService_GetAllMetadataServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method GetAllMetadata not implemented")
|
||||
}
|
||||
func (*UnimplementedCredentialServiceServer) Get(ctx context.Context, req *IdRequest) (*Credential, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
|
||||
}
|
||||
func (*UnimplementedCredentialServiceServer) Create(ctx context.Context, req *CredentialRequest) (*Credential, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
|
||||
}
|
||||
func (*UnimplementedCredentialServiceServer) Update(ctx context.Context, req *UpdateRequest) (*Credential, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
|
||||
}
|
||||
func (*UnimplementedCredentialServiceServer) Delete(ctx context.Context, req *IdRequest) (*DeleteResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
|
||||
}
|
||||
|
||||
func RegisterCredentialServiceServer(s *grpc.Server, srv CredentialServiceServer) {
|
||||
s.RegisterService(&_CredentialService_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _CredentialService_GetAllMetadata_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(GetAllMetadataRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(CredentialServiceServer).GetAllMetadata(m, &credentialServiceGetAllMetadataServer{stream})
|
||||
}
|
||||
|
||||
type CredentialService_GetAllMetadataServer interface {
|
||||
Send(*Metadata) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type credentialServiceGetAllMetadataServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *credentialServiceGetAllMetadataServer) Send(m *Metadata) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func _CredentialService_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(IdRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CredentialServiceServer).Get(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/selfpass.credentials.CredentialService/Get",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CredentialServiceServer).Get(ctx, req.(*IdRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CredentialService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CredentialRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CredentialServiceServer).Create(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/selfpass.credentials.CredentialService/Create",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CredentialServiceServer).Create(ctx, req.(*CredentialRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CredentialService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CredentialServiceServer).Update(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/selfpass.credentials.CredentialService/Update",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CredentialServiceServer).Update(ctx, req.(*UpdateRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CredentialService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(IdRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CredentialServiceServer).Delete(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/selfpass.credentials.CredentialService/Delete",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CredentialServiceServer).Delete(ctx, req.(*IdRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _CredentialService_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "selfpass.credentials.CredentialService",
|
||||
HandlerType: (*CredentialServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Get",
|
||||
Handler: _CredentialService_Get_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Create",
|
||||
Handler: _CredentialService_Create_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Update",
|
||||
Handler: _CredentialService_Update_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Delete",
|
||||
Handler: _CredentialService_Delete_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "GetAllMetadata",
|
||||
Handler: _CredentialService_GetAllMetadata_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "credentials/protobuf/service.proto",
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package selfpass.credentials;
|
||||
|
||||
option go_package = "protobuf";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
service CredentialService {
|
||||
rpc GetAllMetadata (GetAllMetadataRequest) returns (stream Metadata);
|
||||
rpc Get (IdRequest) returns (Credential);
|
||||
rpc Create (CredentialRequest) returns (Credential);
|
||||
rpc Update (UpdateRequest) returns (Credential);
|
||||
rpc Delete (IdRequest) returns (DeleteResponse);
|
||||
// rpc Dump (EmptyRequest) returns (DumpResponse);
|
||||
}
|
||||
|
||||
message DeleteResponse {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetAllMetadataRequest {
|
||||
string source_host = 1;
|
||||
}
|
||||
|
||||
message IdRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message UpdateRequest {
|
||||
string id = 1;
|
||||
CredentialRequest credential = 2;
|
||||
}
|
||||
|
||||
message DumpResponse {
|
||||
bytes contents = 1;
|
||||
}
|
||||
|
||||
message EmptyRequest {
|
||||
}
|
||||
|
||||
message Metadata {
|
||||
string id = 1;
|
||||
google.protobuf.Timestamp created_at = 2;
|
||||
google.protobuf.Timestamp updated_at = 3;
|
||||
string primary = 4;
|
||||
string source_host = 5;
|
||||
string login_url = 6;
|
||||
string tag = 7;
|
||||
}
|
||||
|
||||
message Credential {
|
||||
string id = 1;
|
||||
google.protobuf.Timestamp created_at = 2;
|
||||
google.protobuf.Timestamp updated_at = 3;
|
||||
string primary = 4;
|
||||
string username = 5;
|
||||
string email = 6;
|
||||
string password = 7;
|
||||
string source_host = 8;
|
||||
string login_url = 9;
|
||||
string tag = 10;
|
||||
string otp_secret = 11;
|
||||
}
|
||||
|
||||
message CredentialRequest {
|
||||
string primary = 1;
|
||||
string username = 2;
|
||||
string email = 3;
|
||||
string password = 4;
|
||||
string source_host = 5;
|
||||
string login_url = 6;
|
||||
string tag = 7;
|
||||
string otp_secret = 8;
|
||||
}
|
|
@ -10,13 +10,13 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
protobuf "github.com/mitchell/selfpass/protobuf/go"
|
||||
"github.com/mitchell/selfpass/services/credentials/endpoints"
|
||||
"github.com/mitchell/selfpass/services/credentials/protobuf"
|
||||
"github.com/mitchell/selfpass/services/credentials/transport"
|
||||
"github.com/mitchell/selfpass/services/credentials/types"
|
||||
)
|
||||
|
||||
func NewCredentialServiceClient(ctx context.Context, target, ca, cert, key string) (types.CredentialClient, error) {
|
||||
func NewCredentialsClient(ctx context.Context, target, ca, cert, key string) (types.CredentialsClient, error) {
|
||||
keypair, err := tls.X509KeyPair([]byte(cert), []byte(key))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -39,16 +39,16 @@ func NewCredentialServiceClient(ctx context.Context, target, ca, cert, key strin
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return credentialServiceClient{
|
||||
client: protobuf.NewCredentialServiceClient(conn),
|
||||
return credentialsClient{
|
||||
client: protobuf.NewCredentialsClient(conn),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type credentialServiceClient struct {
|
||||
client protobuf.CredentialServiceClient
|
||||
type credentialsClient struct {
|
||||
client protobuf.CredentialsClient
|
||||
}
|
||||
|
||||
func (c credentialServiceClient) GetAllMetadata(ctx context.Context, sourceHost string) (output <-chan types.Metadata, errch chan error) {
|
||||
func (c credentialsClient) GetAllMetadata(ctx context.Context, sourceHost string) (output <-chan types.Metadata, errch chan error) {
|
||||
pbmdch := make(chan protobuf.Metadata, 1)
|
||||
errch = make(chan error, 1)
|
||||
|
||||
|
@ -57,7 +57,7 @@ func (c credentialServiceClient) GetAllMetadata(ctx context.Context, sourceHost
|
|||
Errors: errch,
|
||||
})
|
||||
|
||||
srv, err := c.client.GetAllMetadata(ctx, &protobuf.GetAllMetadataRequest{SourceHost: sourceHost})
|
||||
srv, err := c.client.GetAllMetadata(ctx, &protobuf.SourceHostRequest{SourceHost: sourceHost})
|
||||
if err != nil {
|
||||
errch <- err
|
||||
return nil, errch
|
||||
|
@ -89,7 +89,7 @@ func (c credentialServiceClient) GetAllMetadata(ctx context.Context, sourceHost
|
|||
return stream.Metadata, stream.Errors
|
||||
}
|
||||
|
||||
func (c credentialServiceClient) Get(ctx context.Context, id string) (output types.Credential, err error) {
|
||||
func (c credentialsClient) Get(ctx context.Context, id string) (output types.Credential, err error) {
|
||||
req := transport.EncodeIdRequest(endpoints.IDRequest{ID: id})
|
||||
|
||||
res, err := c.client.Get(ctx, &req)
|
||||
|
@ -100,7 +100,7 @@ func (c credentialServiceClient) Get(ctx context.Context, id string) (output typ
|
|||
return transport.DecodeCredential(*res)
|
||||
}
|
||||
|
||||
func (c credentialServiceClient) Create(ctx context.Context, ci types.CredentialInput) (output types.Credential, err error) {
|
||||
func (c credentialsClient) Create(ctx context.Context, ci types.CredentialInput) (output types.Credential, err error) {
|
||||
req := transport.EncodeCredentialRequest(ci)
|
||||
|
||||
res, err := c.client.Create(ctx, &req)
|
||||
|
@ -111,7 +111,7 @@ func (c credentialServiceClient) Create(ctx context.Context, ci types.Credential
|
|||
return transport.DecodeCredential(*res)
|
||||
}
|
||||
|
||||
func (c credentialServiceClient) Update(ctx context.Context, id string, ci types.CredentialInput) (output types.Credential, err error) {
|
||||
func (c credentialsClient) Update(ctx context.Context, id string, ci types.CredentialInput) (output types.Credential, err error) {
|
||||
req := transport.EncodeUpdateRequest(endpoints.UpdateRequest{ID: id, Credential: ci})
|
||||
|
||||
res, err := c.client.Update(ctx, &req)
|
||||
|
@ -122,7 +122,7 @@ func (c credentialServiceClient) Update(ctx context.Context, id string, ci types
|
|||
return transport.DecodeCredential(*res)
|
||||
}
|
||||
|
||||
func (c credentialServiceClient) Delete(ctx context.Context, id string) (err error) {
|
||||
func (c credentialsClient) Delete(ctx context.Context, id string) (err error) {
|
||||
req := transport.EncodeIdRequest(endpoints.IDRequest{ID: id})
|
||||
|
||||
res, err := c.client.Delete(ctx, &req)
|
||||
|
|
|
@ -8,14 +8,14 @@ import (
|
|||
"github.com/mitchell/selfpass/services/credentials/types"
|
||||
)
|
||||
|
||||
func NewCredentials(repo types.CredentialRepo) Credentials {
|
||||
func NewCredentials(repo types.CredentialsRepo) Credentials {
|
||||
return Credentials{
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
repo types.CredentialRepo
|
||||
repo types.CredentialsRepo
|
||||
}
|
||||
|
||||
func (svc Credentials) GetAllMetadata(ctx context.Context, sourceHost string) (output <-chan types.Metadata, errch chan error) {
|
||||
|
|
|
@ -5,32 +5,25 @@ import (
|
|||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
protobuf "github.com/mitchell/selfpass/protobuf/go"
|
||||
"github.com/mitchell/selfpass/services/credentials/endpoints"
|
||||
"github.com/mitchell/selfpass/services/credentials/protobuf"
|
||||
"github.com/mitchell/selfpass/services/credentials/types"
|
||||
)
|
||||
|
||||
func decodeGetAllMetadataRequest(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
r := request.(protobuf.GetAllMetadataRequest)
|
||||
return endpoints.GetAllMetadataRequest{
|
||||
func decodeSourceHostRequest(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
r := request.(protobuf.SourceHostRequest)
|
||||
return endpoints.SourceHostRequest{
|
||||
SourceHost: r.SourceHost,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func EncodeGetAllMetadataRequest(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
r := request.(endpoints.GetAllMetadataRequest)
|
||||
return protobuf.GetAllMetadataRequest{
|
||||
func EncodeSourceHostRequest(ctx context.Context, request interface{}) (interface{}, error) {
|
||||
r := request.(endpoints.SourceHostRequest)
|
||||
return protobuf.SourceHostRequest{
|
||||
SourceHost: r.SourceHost,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeDumpResponse(ctx context.Context, response interface{}) (interface{}, error) {
|
||||
r := response.(endpoints.DumpResponse)
|
||||
return protobuf.DumpResponse{
|
||||
Contents: r.Contents,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func encodeMetadataStreamResponse(ctx context.Context, response interface{}) (interface{}, error) {
|
||||
r := response.(endpoints.MetadataStream)
|
||||
pbmdch := make(chan protobuf.Metadata, 1)
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
protobuf "github.com/mitchell/selfpass/protobuf/go"
|
||||
"github.com/mitchell/selfpass/services/credentials/endpoints"
|
||||
"github.com/mitchell/selfpass/services/credentials/protobuf"
|
||||
"github.com/mitchell/selfpass/services/credentials/types"
|
||||
)
|
||||
|
||||
|
@ -18,7 +18,7 @@ func NewGRPCServer(svc types.Service, logger log.Logger) GRPCServer {
|
|||
return GRPCServer{
|
||||
getAllMetadata: grpc.NewServer(
|
||||
endpoints.MakeGetAllMetadataEndpoint(svc),
|
||||
decodeGetAllMetadataRequest,
|
||||
decodeSourceHostRequest,
|
||||
encodeMetadataStreamResponse,
|
||||
grpc.ServerErrorLogger(logger),
|
||||
),
|
||||
|
@ -46,12 +46,6 @@ func NewGRPCServer(svc types.Service, logger log.Logger) GRPCServer {
|
|||
noOp,
|
||||
grpc.ServerErrorLogger(logger),
|
||||
),
|
||||
dump: grpc.NewServer(
|
||||
endpoints.MakeDumpEndpoint(svc),
|
||||
noOp,
|
||||
encodeDumpResponse,
|
||||
grpc.ServerErrorLogger(logger),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,10 +55,9 @@ type GRPCServer struct {
|
|||
create *grpc.Server
|
||||
update *grpc.Server
|
||||
delete *grpc.Server
|
||||
dump *grpc.Server
|
||||
}
|
||||
|
||||
func (s GRPCServer) GetAllMetadata(r *protobuf.GetAllMetadataRequest, srv protobuf.CredentialService_GetAllMetadataServer) (err error) {
|
||||
func (s GRPCServer) GetAllMetadata(r *protobuf.SourceHostRequest, srv protobuf.Credentials_GetAllMetadataServer) (err error) {
|
||||
defer func() { err = handlerGRPCError(err) }()
|
||||
|
||||
var i interface{}
|
||||
|
@ -133,26 +126,14 @@ func (s GRPCServer) Update(ctx context.Context, r *protobuf.UpdateRequest) (*pro
|
|||
return c, nil
|
||||
}
|
||||
|
||||
func (s GRPCServer) Delete(ctx context.Context, r *protobuf.IdRequest) (*protobuf.DeleteResponse, error) {
|
||||
func (s GRPCServer) Delete(ctx context.Context, r *protobuf.IdRequest) (*protobuf.SuccessResponse, error) {
|
||||
ctx, _, err := s.delete.ServeGRPC(ctx, *r)
|
||||
if err != nil {
|
||||
err = handlerGRPCError(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &protobuf.DeleteResponse{Success: true}, nil
|
||||
}
|
||||
|
||||
func (s GRPCServer) Dump(ctx context.Context, r *protobuf.EmptyRequest) (*protobuf.DumpResponse, error) {
|
||||
ctx, i, err := s.dump.ServeGRPC(ctx, *r)
|
||||
if err != nil {
|
||||
err = handlerGRPCError(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := &protobuf.DumpResponse{}
|
||||
*res = i.(protobuf.DumpResponse)
|
||||
return res, nil
|
||||
return &protobuf.SuccessResponse{Success: true}, nil
|
||||
}
|
||||
|
||||
func handlerGRPCError(err error) error {
|
||||
|
|
|
@ -11,7 +11,7 @@ type Service interface {
|
|||
DumpDB(ctx context.Context) (bs []byte, err error)
|
||||
}
|
||||
|
||||
type CredentialRepo interface {
|
||||
type CredentialsRepo interface {
|
||||
GetAllMetadata(ctx context.Context, sourceHost string, errch chan<- error) (output <-chan Metadata)
|
||||
Get(ctx context.Context, id string) (output Credential, err error)
|
||||
Put(ctx context.Context, c Credential) (err error)
|
||||
|
@ -19,9 +19,9 @@ type CredentialRepo interface {
|
|||
DumpDB(ctx context.Context) (bs []byte, err error)
|
||||
}
|
||||
|
||||
type CredentialClientInit func(ctx context.Context, target, ca, cert, key string) (c CredentialClient, err error)
|
||||
type CredentialsClientInit func(ctx context.Context, target, ca, cert, key string) (c CredentialsClient, err error)
|
||||
|
||||
type CredentialClient interface {
|
||||
type CredentialsClient interface {
|
||||
GetAllMetadata(ctx context.Context, sourceHost string) (output <-chan Metadata, errch chan error)
|
||||
Get(ctx context.Context, id string) (output Credential, err error)
|
||||
Create(ctx context.Context, ci CredentialInput) (output Credential, err error)
|
||||
|
|
|
@ -8,5 +8,8 @@ require (
|
|||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/golang/protobuf v1.3.2
|
||||
github.com/mediocregopher/radix/v3 v3.3.0
|
||||
github.com/mitchell/selfpass/protobuf/go v0.0.0-00010101000000-000000000000
|
||||
google.golang.org/grpc v1.22.0
|
||||
)
|
||||
|
||||
replace github.com/mitchell/selfpass/protobuf/go => ../protobuf/go
|
||||
|
|
|
@ -13,6 +13,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekf
|
|||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/mitchell/selfpass/services/credentials/types"
|
||||
)
|
||||
|
||||
type CredentialClientInit func(ctx context.Context) (c types.CredentialClient)
|
||||
type CredentialsClientInit func(ctx context.Context) (c types.CredentialsClient)
|
||||
|
||||
func check(err error) {
|
||||
if err != nil {
|
||||
|
@ -21,7 +21,7 @@ func check(err error) {
|
|||
}
|
||||
}
|
||||
|
||||
func selectCredential(client types.CredentialClient) types.Credential {
|
||||
func selectCredential(client types.CredentialsClient) types.Credential {
|
||||
var (
|
||||
idKey string
|
||||
source string
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
clitypes "github.com/mitchell/selfpass/sp/types"
|
||||
)
|
||||
|
||||
func makeCreate(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command {
|
||||
func makeCreate(repo clitypes.ConfigRepo, initClient CredentialsClientInit) *cobra.Command {
|
||||
var length uint
|
||||
var numbers bool
|
||||
var specials bool
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"gopkg.in/AlecAivazis/survey.v1"
|
||||
)
|
||||
|
||||
func makeDelete(initClient CredentialClientInit) *cobra.Command {
|
||||
func makeDelete(initClient CredentialsClientInit) *cobra.Command {
|
||||
deleteCmd := &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "Delete a credential using the given ID",
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
clitypes "github.com/mitchell/selfpass/sp/types"
|
||||
)
|
||||
|
||||
func makeGCMToCBC(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command {
|
||||
func makeGCMToCBC(repo clitypes.ConfigRepo, initClient CredentialsClientInit) *cobra.Command {
|
||||
gcmToCBC := &cobra.Command{
|
||||
Use: "gcm-to-cbc",
|
||||
Hidden: true,
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
clitypes "github.com/mitchell/selfpass/sp/types"
|
||||
)
|
||||
|
||||
func makeGet(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command {
|
||||
func makeGet(repo clitypes.ConfigRepo, initClient CredentialsClientInit) *cobra.Command {
|
||||
getCmd := &cobra.Command{
|
||||
Use: "get",
|
||||
Short: "Get a credential info and copy password to clipboard",
|
||||
|
|
|
@ -30,7 +30,8 @@ the users private key, and server certificates. (All of which will be encrypted)
|
|||
prompt survey.Prompt
|
||||
privateKey = strings.Replace(uuid.New().String(), "-", "", -1)
|
||||
)
|
||||
_, cfg, _ := repo.OpenConfig()
|
||||
_, cfg, err := repo.OpenConfig()
|
||||
check(err)
|
||||
|
||||
prompt = &survey.Password{Message: "New master password:"}
|
||||
check(survey.AskOne(prompt, &masterpass, nil))
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/mitchell/selfpass/services/credentials/types"
|
||||
)
|
||||
|
||||
func makeList(initClient CredentialClientInit) *cobra.Command {
|
||||
func makeList(initClient CredentialsClientInit) *cobra.Command {
|
||||
var sourceHost string
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
|
|
@ -23,7 +23,7 @@ can interact with the entire Selfpass API.`,
|
|||
cfgFile := rootCmd.PersistentFlags().String("config", "", "config file (default is $HOME/.sp.toml)")
|
||||
|
||||
mgr := repositories.NewConfigManager(cfgFile)
|
||||
clientInit := credrepos.NewCredentialServiceClient
|
||||
clientInit := credrepos.NewCredentialsClient
|
||||
|
||||
rootCmd.AddCommand(
|
||||
makeInit(mgr),
|
||||
|
@ -41,8 +41,8 @@ can interact with the entire Selfpass API.`,
|
|||
check(rootCmd.Execute())
|
||||
}
|
||||
|
||||
func makeInitClient(repo types.ConfigRepo, initClient credtypes.CredentialClientInit) CredentialClientInit {
|
||||
return func(ctx context.Context) credtypes.CredentialClient {
|
||||
func makeInitClient(repo types.ConfigRepo, initClient credtypes.CredentialsClientInit) CredentialsClientInit {
|
||||
return func(ctx context.Context) credtypes.CredentialsClient {
|
||||
_, cfg, err := repo.OpenConfig()
|
||||
check(err)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
clitypes "github.com/mitchell/selfpass/sp/types"
|
||||
)
|
||||
|
||||
func makeUpdate(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command {
|
||||
func makeUpdate(repo clitypes.ConfigRepo, initClient CredentialsClientInit) *cobra.Command {
|
||||
var length uint
|
||||
var numbers bool
|
||||
var specials bool
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
"io"
|
||||
)
|
||||
|
||||
var ErrAuthenticationFailed = errors.New("cipher: message authentication failed")
|
||||
|
||||
func GCMEncrypt(key []byte, plaintext []byte) ([]byte, error) {
|
||||
if len(key) != 32 {
|
||||
return nil, fmt.Errorf("key is not 32 bytes")
|
||||
|
|
|
@ -4,6 +4,7 @@ go 1.12
|
|||
|
||||
require (
|
||||
github.com/atotto/clipboard v0.1.2
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/mitchell/selfpass/services v0.0.0-00010101000000-000000000000
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
|
@ -16,3 +17,5 @@ require (
|
|||
)
|
||||
|
||||
replace github.com/mitchell/selfpass/services => ../services
|
||||
|
||||
replace github.com/mitchell/selfpass/protobuf/go => ../protobuf/go
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -67,15 +66,15 @@ func (mgr *ConfigManager) OpenConfig() (output string, v *viper.Viper, err error
|
|||
}
|
||||
|
||||
contents, err = decryptConfig(mgr.masterpass, cfg)
|
||||
if err != nil && err == errConfigDecrypted {
|
||||
if err == errConfigDecrypted {
|
||||
configDecrypted = true
|
||||
} else if err != nil && err.Error() == crypto.ErrAuthenticationFailed.Error() {
|
||||
return output, nil, errors.New("incorrect masterpass")
|
||||
} else if err != nil {
|
||||
return output, nil, err
|
||||
}
|
||||
|
||||
if err = mgr.v.ReadConfig(bytes.NewBuffer(contents)); err != nil && strings.HasPrefix(err.Error(), "While parsing config") {
|
||||
return output, nil, fmt.Errorf("incorrect master password")
|
||||
} else if err != nil {
|
||||
if err = mgr.v.ReadConfig(bytes.NewBuffer(contents)); err != nil {
|
||||
return output, nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue