secret

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: MulanPSL-2.0 Imports: 20 Imported by: 0

README

#云商凭证管理

开始给provider提供凭证的是通过环境变量,但是一个provider下面可能有很多账号,不同账号下面还有很多region,这时候就需要一个统一管理seret的服务来给provider提供访问资源方的凭证

问题1 暴露的路由重复了 问题2 代码太冗余了 目前每个实现类都要对一个一个http handler来暴露出去,其实可以定义一个handler暴露所有的服务,只不过就是在handler中多加几个实现类的字段就可以了

问题3 secret服务缺少一个update方法

问题4 缺少secret信息填写的认证 比如这个secret id secret key 是否可以真的连接腾讯云 或者他的这个权限是否可以创建资源 是否可以在填写的region中都有权限创建

Documentation

Index

Constants

View Source
const (
	AppName = "secret"
)

Variables

View Source
var (
	Type_name = map[int32]string{
		0: "API_KEY",
		1: "PASSWORD",
	}
	Type_value = map[string]int32{
		"API_KEY":  0,
		"PASSWORD": 1,
	}
)

Enum value maps for Type.

View Source
var File_apps_secret_pb_secret_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "cmdb.secret.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateSecret",
			Handler:    _Service_CreateSecret_Handler,
		},
		{
			MethodName: "QuerySecret",
			Handler:    _Service_QuerySecret_Handler,
		},
		{
			MethodName: "DescribeSecret",
			Handler:    _Service_DescribeSecret_Handler,
		},
		{
			MethodName: "DeleteSecret",
			Handler:    _Service_DeleteSecret_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/secret/pb/secret.proto",
}

Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type CreateSecretRequest

type CreateSecretRequest struct {

	// 描述
	// @gotags: json:"description" validate:"required,lte=100"
	Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
	// 厂商
	// @gotags: json:"vendor"
	Vendor resource.Vendor `protobuf:"varint,2,opt,name=vendor,proto3,enum=cmdb.resource.Vendor" json:"vendor,omitempty"`
	// 允许同步的区域
	// @gotags: json:"allow_regions"
	AllowRegions []string `protobuf:"bytes,3,rep,name=allow_regions,json=allowRegions,proto3" json:"allow_regions,omitempty"`
	// 凭证类型
	// @gotags: json:"crendential_type"
	CrendentialType Type `` /* 129-byte string literal not displayed */
	// 服务地址, 云商不用填写
	// @gotags: json:"address"
	Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"`
	// key
	// @gotags: json:"api_key" validate:"required,lte=100"
	ApiKey string `protobuf:"bytes,6,opt,name=api_key,json=apiKey,proto3" json:"api_key,omitempty"`
	// secrete
	// @gotags: json:"api_secret" validate:"required,lte=100"
	ApiSecret string `protobuf:"bytes,7,opt,name=api_secret,json=apiSecret,proto3" json:"api_secret,omitempty"`
	// 请求速率限制, 默认1秒5个 这个参数没用
	// @gotags: json:"request_rate"
	RequestRate int32 `protobuf:"varint,8,opt,name=request_rate,json=requestRate,proto3" json:"request_rate,omitempty"`
	// contains filtered or unexported fields
}

func NewCreateSecretRequest

func NewCreateSecretRequest() *CreateSecretRequest

func (*CreateSecretRequest) AllowRegionString

func (req *CreateSecretRequest) AllowRegionString() string

func (*CreateSecretRequest) DecryptAPISecret

func (s *CreateSecretRequest) DecryptAPISecret(key string) error

func (*CreateSecretRequest) Descriptor deprecated

func (*CreateSecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateSecretRequest.ProtoReflect.Descriptor instead.

func (*CreateSecretRequest) Desense

func (s *CreateSecretRequest) Desense()

敏感数据脱敏

func (*CreateSecretRequest) EncryptAPISecret

func (s *CreateSecretRequest) EncryptAPISecret(key string) error

func (*CreateSecretRequest) GetAddress

func (x *CreateSecretRequest) GetAddress() string

func (*CreateSecretRequest) GetAllowRegions

func (x *CreateSecretRequest) GetAllowRegions() []string

func (*CreateSecretRequest) GetApiKey

func (x *CreateSecretRequest) GetApiKey() string

func (*CreateSecretRequest) GetApiSecret

func (x *CreateSecretRequest) GetApiSecret() string

func (*CreateSecretRequest) GetCrendentialType

func (x *CreateSecretRequest) GetCrendentialType() Type

func (*CreateSecretRequest) GetDescription

func (x *CreateSecretRequest) GetDescription() string

func (*CreateSecretRequest) GetRequestRate

func (x *CreateSecretRequest) GetRequestRate() int32

func (*CreateSecretRequest) GetVendor

func (x *CreateSecretRequest) GetVendor() resource.Vendor

func (*CreateSecretRequest) LoadAllowRegionFromString

func (req *CreateSecretRequest) LoadAllowRegionFromString(region string)

func (*CreateSecretRequest) ProtoMessage

func (*CreateSecretRequest) ProtoMessage()

func (*CreateSecretRequest) ProtoReflect

func (x *CreateSecretRequest) ProtoReflect() protoreflect.Message

func (*CreateSecretRequest) Reset

func (x *CreateSecretRequest) Reset()

func (*CreateSecretRequest) String

func (x *CreateSecretRequest) String() string

func (*CreateSecretRequest) Validate

func (req *CreateSecretRequest) Validate() error

type DeleteSecretRequest

type DeleteSecretRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func NewDeleteSecretRequestWithID

func NewDeleteSecretRequestWithID(id string) *DeleteSecretRequest

func (*DeleteSecretRequest) Descriptor deprecated

func (*DeleteSecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteSecretRequest.ProtoReflect.Descriptor instead.

func (*DeleteSecretRequest) GetId

func (x *DeleteSecretRequest) GetId() string

func (*DeleteSecretRequest) ProtoMessage

func (*DeleteSecretRequest) ProtoMessage()

func (*DeleteSecretRequest) ProtoReflect

func (x *DeleteSecretRequest) ProtoReflect() protoreflect.Message

func (*DeleteSecretRequest) Reset

func (x *DeleteSecretRequest) Reset()

func (*DeleteSecretRequest) String

func (x *DeleteSecretRequest) String() string

type DescribeSecretRequest

type DescribeSecretRequest struct {
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func NewDescribeSecretRequest

func NewDescribeSecretRequest(id string) *DescribeSecretRequest

func (*DescribeSecretRequest) Descriptor deprecated

func (*DescribeSecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribeSecretRequest.ProtoReflect.Descriptor instead.

func (*DescribeSecretRequest) GetId

func (x *DescribeSecretRequest) GetId() string

func (*DescribeSecretRequest) ProtoMessage

func (*DescribeSecretRequest) ProtoMessage()

func (*DescribeSecretRequest) ProtoReflect

func (x *DescribeSecretRequest) ProtoReflect() protoreflect.Message

func (*DescribeSecretRequest) Reset

func (x *DescribeSecretRequest) Reset()

func (*DescribeSecretRequest) String

func (x *DescribeSecretRequest) String() string

type QuerySecretRequest

type QuerySecretRequest struct {

	// 分页参数
	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page,omitempty"`
	// 关键字参数
	// @gotags: json:"keywords"
	Keywords string `protobuf:"bytes,2,opt,name=keywords,proto3" json:"keywords,omitempty"`
	// 所属Domain
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,14,opt,name=domain,proto3" json:"domain,omitempty"`
	// 所属Namespace
	// @gotags: json:"namespace"
	Namespace string `protobuf:"bytes,15,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// contains filtered or unexported fields
}

func NewQuerySecret

func NewQuerySecret() *QuerySecretRequest

func NewQuerySecretRequest

func NewQuerySecretRequest(r *http.Request) *QuerySecretRequest

func (*QuerySecretRequest) Descriptor deprecated

func (*QuerySecretRequest) Descriptor() ([]byte, []int)

Deprecated: Use QuerySecretRequest.ProtoReflect.Descriptor instead.

func (*QuerySecretRequest) GetDomain

func (x *QuerySecretRequest) GetDomain() string

func (*QuerySecretRequest) GetKeywords

func (x *QuerySecretRequest) GetKeywords() string

func (*QuerySecretRequest) GetNamespace

func (x *QuerySecretRequest) GetNamespace() string

func (*QuerySecretRequest) GetPage

func (x *QuerySecretRequest) GetPage() *request.PageRequest

func (*QuerySecretRequest) ProtoMessage

func (*QuerySecretRequest) ProtoMessage()

func (*QuerySecretRequest) ProtoReflect

func (x *QuerySecretRequest) ProtoReflect() protoreflect.Message

func (*QuerySecretRequest) Reset

func (x *QuerySecretRequest) Reset()

func (*QuerySecretRequest) String

func (x *QuerySecretRequest) String() string

type Secret

type Secret struct {

	// 全局唯一Id
	// @gotags: json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// 创建时间
	// @gotags: json:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at,omitempty"`
	// 创建信息
	// @gotags: json:"data"
	Data *CreateSecretRequest `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func NewDefaultSecret

func NewDefaultSecret() *Secret

func NewSecret

func NewSecret(req *CreateSecretRequest) (*Secret, error)

func (*Secret) Descriptor deprecated

func (*Secret) Descriptor() ([]byte, []int)

Deprecated: Use Secret.ProtoReflect.Descriptor instead.

func (*Secret) GetCreateAt

func (x *Secret) GetCreateAt() int64

func (*Secret) GetData

func (x *Secret) GetData() *CreateSecretRequest

func (*Secret) GetId

func (x *Secret) GetId() string

func (*Secret) ProtoMessage

func (*Secret) ProtoMessage()

func (*Secret) ProtoReflect

func (x *Secret) ProtoReflect() protoreflect.Message

func (*Secret) Reset

func (x *Secret) Reset()

func (*Secret) String

func (x *Secret) String() string

type SecretSet

type SecretSet struct {

	// @gotags: json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"`
	// @gotags: json:"items"
	Items []*Secret `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

func NewSecretSet

func NewSecretSet() *SecretSet

func (*SecretSet) Add

func (t *SecretSet) Add(s *Secret)

func (*SecretSet) Descriptor deprecated

func (*SecretSet) Descriptor() ([]byte, []int)

Deprecated: Use SecretSet.ProtoReflect.Descriptor instead.

func (*SecretSet) GetItems

func (x *SecretSet) GetItems() []*Secret

func (*SecretSet) GetTotal

func (x *SecretSet) GetTotal() int64

func (*SecretSet) ProtoMessage

func (*SecretSet) ProtoMessage()

func (*SecretSet) ProtoReflect

func (x *SecretSet) ProtoReflect() protoreflect.Message

func (*SecretSet) Reset

func (x *SecretSet) Reset()

func (*SecretSet) String

func (x *SecretSet) String() string

type ServiceClient

type ServiceClient interface {
	CreateSecret(ctx context.Context, in *CreateSecretRequest, opts ...grpc.CallOption) (*Secret, error)
	QuerySecret(ctx context.Context, in *QuerySecretRequest, opts ...grpc.CallOption) (*SecretSet, error)
	DescribeSecret(ctx context.Context, in *DescribeSecretRequest, opts ...grpc.CallOption) (*Secret, error)
	DeleteSecret(ctx context.Context, in *DeleteSecretRequest, opts ...grpc.CallOption) (*Secret, error)
}

ServiceClient is the client API for Service service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewServiceClient

func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient

type ServiceServer

type ServiceServer interface {
	CreateSecret(context.Context, *CreateSecretRequest) (*Secret, error)
	QuerySecret(context.Context, *QuerySecretRequest) (*SecretSet, error)
	DescribeSecret(context.Context, *DescribeSecretRequest) (*Secret, error)
	DeleteSecret(context.Context, *DeleteSecretRequest) (*Secret, error)
	// contains filtered or unexported methods
}

ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility

type Type

type Type int32
const (
	Type_API_KEY  Type = 0
	Type_PASSWORD Type = 1
)

func ParseTypeFromString

func ParseTypeFromString(str string) (Type, error)

ParseTypeFromString Parse Type from string

func (Type) Descriptor

func (Type) Descriptor() protoreflect.EnumDescriptor

func (Type) Enum

func (x Type) Enum() *Type

func (Type) EnumDescriptor deprecated

func (Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Type.Descriptor instead.

func (Type) Equal

func (t Type) Equal(target Type) bool

Equal type compare

func (Type) IsIn

func (t Type) IsIn(targets ...Type) bool

IsIn todo

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (Type) Number

func (x Type) Number() protoreflect.EnumNumber

func (Type) String

func (x Type) String() string

func (Type) Type

func (Type) Type() protoreflect.EnumType

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) CreateSecret

func (UnimplementedServiceServer) DeleteSecret

func (UnimplementedServiceServer) DescribeSecret

func (UnimplementedServiceServer) QuerySecret

type UnsafeServiceServer

type UnsafeServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ServiceServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL