verifycode

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "verifycode"
)

Variables

View Source
var (
	NotifyType_name = map[int32]string{
		0: "MAIL",
		2: "SMS",
	}
	NotifyType_value = map[string]int32{
		"MAIL": 0,
		"SMS":  2,
	}
)

Enum value maps for NotifyType.

View Source
var (
	IssueType_name = map[int32]string{
		0: "PASS",
		1: "TOKEN",
	}
	IssueType_value = map[string]int32{
		"PASS":  0,
		"TOKEN": 1,
	}
)

Enum value maps for IssueType.

View Source
var File_apps_verifycode_pb_enum_proto protoreflect.FileDescriptor
View Source
var File_apps_verifycode_pb_request_proto protoreflect.FileDescriptor
View Source
var File_apps_verifycode_pb_service_proto protoreflect.FileDescriptor
View Source
var File_apps_verifycode_pb_verifycode_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "infraboard.keyauth.verifycode.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "IssueCode",
			Handler:    _Service_IssueCode_Handler,
		},
		{
			MethodName: "CheckCode",
			Handler:    _Service_CheckCode_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/verifycode/pb/service.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 GenRandomCode

func GenRandomCode(length uint) string

GenRandomCode todo

func HashID

func HashID(username, number string) string

HashID todo

func HttpEntry

func HttpEntry() *http.EntrySet

HttpEntry todo

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type CheckCodeRequest

type CheckCodeRequest struct {

	// @gotags: json:"username" validate:"required"
	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username" validate:"required"`
	// @gotags: json:"number" validate:"required"
	Number string `protobuf:"bytes,2,opt,name=number,proto3" json:"number" validate:"required"`
	// contains filtered or unexported fields
}

CheckCodeRequest 验证码校验请求

func NewCheckCodeRequest

func NewCheckCodeRequest(username, number string) *CheckCodeRequest

NewCheckCodeRequest todo

func (*CheckCodeRequest) Descriptor deprecated

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

Deprecated: Use CheckCodeRequest.ProtoReflect.Descriptor instead.

func (*CheckCodeRequest) GetNumber

func (x *CheckCodeRequest) GetNumber() string

func (*CheckCodeRequest) GetUsername

func (x *CheckCodeRequest) GetUsername() string

func (*CheckCodeRequest) HashID

func (req *CheckCodeRequest) HashID() string

HashID todo

func (*CheckCodeRequest) ProtoMessage

func (*CheckCodeRequest) ProtoMessage()

func (*CheckCodeRequest) ProtoReflect

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

func (*CheckCodeRequest) Reset

func (x *CheckCodeRequest) Reset()

func (*CheckCodeRequest) String

func (x *CheckCodeRequest) String() string

func (*CheckCodeRequest) Validate

func (req *CheckCodeRequest) Validate() error

Validate todo

type CheckCodeResponse

type CheckCodeResponse struct {

	// @gotags: json:"message"
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message"`
	// contains filtered or unexported fields
}

CheckCodeResponse todo

func (*CheckCodeResponse) Descriptor deprecated

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

Deprecated: Use CheckCodeResponse.ProtoReflect.Descriptor instead.

func (*CheckCodeResponse) GetMessage

func (x *CheckCodeResponse) GetMessage() string

func (*CheckCodeResponse) ProtoMessage

func (*CheckCodeResponse) ProtoMessage()

func (*CheckCodeResponse) ProtoReflect

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

func (*CheckCodeResponse) Reset

func (x *CheckCodeResponse) Reset()

func (*CheckCodeResponse) String

func (x *CheckCodeResponse) String() string

type Code

type Code struct {

	// @gotags: bson:"_id" json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
	// @gotags: json:"username" validate:"required"
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username" validate:"required"`
	// @gotags: json:"number" validate:"required"
	Number string `protobuf:"bytes,3,opt,name=number,proto3" json:"number" validate:"required"`
	// @gotags: bson:"issue_at" json:"issue_at"
	IssueAt int64 `protobuf:"varint,4,opt,name=issue_at,json=issueAt,proto3" json:"issue_at" bson:"issue_at"`
	// @gotags: bson:"expired_minite" json:"expired_minite"
	ExpiredMinite uint32 `protobuf:"varint,5,opt,name=expired_minite,json=expiredMinite,proto3" json:"expired_minite" bson:"expired_minite"`
	// contains filtered or unexported fields
}

Code todo

func NewCode

func NewCode(req *IssueCodeRequest) (*Code, error)

NewCode todo

func NewDefaultCode

func NewDefaultCode() *Code

NewDefaultCode todo

func (*Code) Descriptor deprecated

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

Deprecated: Use Code.ProtoReflect.Descriptor instead.

func (*Code) ExpiredMiniteString

func (c *Code) ExpiredMiniteString() string

ExpiredMiniteString todo

func (*Code) GetExpiredMinite

func (x *Code) GetExpiredMinite() uint32

func (*Code) GetId

func (x *Code) GetId() string

func (*Code) GetIssueAt

func (x *Code) GetIssueAt() int64

func (*Code) GetNumber

func (x *Code) GetNumber() string

func (*Code) GetUsername

func (x *Code) GetUsername() string

func (*Code) IsExpired

func (c *Code) IsExpired() bool

IsExpired todo

func (*Code) ProtoMessage

func (*Code) ProtoMessage()

func (*Code) ProtoReflect

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

func (*Code) Reset

func (x *Code) Reset()

func (*Code) String

func (x *Code) String() string

type Config

type Config struct {
	NotifyType    NotifyType `bson:"notify_type" json:"notify_type"`
	ExpireMinutes uint       `bson:"expire_minutes" json:"expire_minutes" validate:"required,gte=10,lte=600"` // 验证码默认过期时间
	MailTemplate  string     `bson:"mail_template" json:"mail_template"`                                      // 邮件通知时的模板
	SmsTemplateID string     `bson:"sms_template_id" json:"sms_template_id"`                                  // 短信通知时的云商模板ID
}

Config todo

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig todo

func (*Config) RenderMailTemplate

func (conf *Config) RenderMailTemplate(number, expiiredMinite string) string

RenderMailTemplate todo

func (*Config) Validate

func (conf *Config) Validate() error

Validate todo

type IssueCodeRequest

type IssueCodeRequest struct {

	// @gotags: json:"issue_type"
	IssueType IssueType `protobuf:"varint,1,opt,name=issue_type,json=issueType,proto3,enum=infraboard.keyauth.verifycode.IssueType" json:"issue_type"`
	// @gotags: json:"username"
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username"`
	// @gotags: json:"password"
	Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password"`
	// @gotags: json:"access_token"
	AccessToken string `protobuf:"bytes,6,opt,name=access_token,json=accessToken,proto3" json:"access_token"`
	// @gotags: json:"client_id" validate:"required"
	ClientId string `protobuf:"bytes,4,opt,name=client_id,json=clientId,proto3" json:"client_id" validate:"required"`
	// @gotags: json:"client_secret" validate:"required"
	ClientSecret string `protobuf:"bytes,5,opt,name=client_secret,json=clientSecret,proto3" json:"client_secret" validate:"required"`
	// contains filtered or unexported fields
}

IssueCodeRequest 验证码申请请求

func NewIssueCodeRequestByPass

func NewIssueCodeRequestByPass() *IssueCodeRequest

NewIssueCodeRequestByPass todo

func NewIssueCodeRequestByToken

func NewIssueCodeRequestByToken() *IssueCodeRequest

NewIssueCodeRequestByToken todo

func (*IssueCodeRequest) Account

func (req *IssueCodeRequest) Account() string

Account todo

func (*IssueCodeRequest) Descriptor deprecated

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

Deprecated: Use IssueCodeRequest.ProtoReflect.Descriptor instead.

func (*IssueCodeRequest) GetAccessToken

func (x *IssueCodeRequest) GetAccessToken() string

func (*IssueCodeRequest) GetClientId

func (x *IssueCodeRequest) GetClientId() string

func (*IssueCodeRequest) GetClientSecret

func (x *IssueCodeRequest) GetClientSecret() string

func (*IssueCodeRequest) GetIssueType

func (x *IssueCodeRequest) GetIssueType() IssueType

func (*IssueCodeRequest) GetPassword

func (x *IssueCodeRequest) GetPassword() string

func (*IssueCodeRequest) GetUsername

func (x *IssueCodeRequest) GetUsername() string

func (*IssueCodeRequest) ProtoMessage

func (*IssueCodeRequest) ProtoMessage()

func (*IssueCodeRequest) ProtoReflect

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

func (*IssueCodeRequest) Reset

func (x *IssueCodeRequest) Reset()

func (*IssueCodeRequest) String

func (x *IssueCodeRequest) String() string

func (*IssueCodeRequest) Validate

func (req *IssueCodeRequest) Validate() error

Validate 请求校验

func (*IssueCodeRequest) ValidateByPass

func (req *IssueCodeRequest) ValidateByPass() error

ValidateByPass todo

func (*IssueCodeRequest) ValidateByToken

func (req *IssueCodeRequest) ValidateByToken() error

ValidateByToken todo

type IssueCodeResponse

type IssueCodeResponse struct {

	// @gotags: json:"message"
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message"`
	// contains filtered or unexported fields
}

IssueCodeResponse todo

func NewIssueCodeResponse

func NewIssueCodeResponse(message string) *IssueCodeResponse

NewIssueCodeResponse todo

func (*IssueCodeResponse) Descriptor deprecated

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

Deprecated: Use IssueCodeResponse.ProtoReflect.Descriptor instead.

func (*IssueCodeResponse) GetMessage

func (x *IssueCodeResponse) GetMessage() string

func (*IssueCodeResponse) ProtoMessage

func (*IssueCodeResponse) ProtoMessage()

func (*IssueCodeResponse) ProtoReflect

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

func (*IssueCodeResponse) Reset

func (x *IssueCodeResponse) Reset()

func (*IssueCodeResponse) String

func (x *IssueCodeResponse) String() string

type IssueType

type IssueType int32
const (
	IssueType_PASS  IssueType = 0
	IssueType_TOKEN IssueType = 1
)

func ParseIssueTypeFromString

func ParseIssueTypeFromString(str string) (IssueType, error)

ParseIssueTypeFromString Parse IssueType from string

func (IssueType) Descriptor

func (IssueType) Descriptor() protoreflect.EnumDescriptor

func (IssueType) Enum

func (x IssueType) Enum() *IssueType

func (IssueType) EnumDescriptor deprecated

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

Deprecated: Use IssueType.Descriptor instead.

func (IssueType) Equal

func (t IssueType) Equal(target IssueType) bool

Equal type compare

func (IssueType) IsIn

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

IsIn todo

func (IssueType) MarshalJSON

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

MarshalJSON todo

func (IssueType) Number

func (x IssueType) Number() protoreflect.EnumNumber

func (IssueType) String

func (x IssueType) String() string

func (IssueType) Type

func (*IssueType) UnmarshalJSON

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

UnmarshalJSON todo

type NotifyType

type NotifyType int32
const (
	NotifyType_MAIL NotifyType = 0
	NotifyType_SMS  NotifyType = 2
)

func ParseNotifyTypeFromString

func ParseNotifyTypeFromString(str string) (NotifyType, error)

ParseNotifyTypeFromString Parse NotifyType from string

func (NotifyType) Descriptor

func (NotifyType) Descriptor() protoreflect.EnumDescriptor

func (NotifyType) Enum

func (x NotifyType) Enum() *NotifyType

func (NotifyType) EnumDescriptor deprecated

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

Deprecated: Use NotifyType.Descriptor instead.

func (NotifyType) Equal

func (t NotifyType) Equal(target NotifyType) bool

Equal type compare

func (NotifyType) IsIn

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

IsIn todo

func (NotifyType) MarshalJSON

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

MarshalJSON todo

func (NotifyType) Number

func (x NotifyType) Number() protoreflect.EnumNumber

func (NotifyType) String

func (x NotifyType) String() string

func (NotifyType) Type

func (*NotifyType) UnmarshalJSON

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

UnmarshalJSON todo

type ServiceClient

type ServiceClient interface {
	IssueCode(ctx context.Context, in *IssueCodeRequest, opts ...grpc.CallOption) (*IssueCodeResponse, error)
	CheckCode(ctx context.Context, in *CheckCodeRequest, opts ...grpc.CallOption) (*Code, 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 {
	IssueCode(context.Context, *IssueCodeRequest) (*IssueCodeResponse, error)
	CheckCode(context.Context, *CheckCodeRequest) (*Code, error)
	// contains filtered or unexported methods
}

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

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) CheckCode

func (UnimplementedServiceServer) IssueCode

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