Documentation ¶
Index ¶
- Constants
- Variables
- func GenRandomCode(length uint) string
- func GetCodeFromHTTP(r *http.Request) string
- func HashID(username, code string) string
- func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)
- type Code
- func (*Code) Descriptor() ([]byte, []int)deprecated
- func (x *Code) GetCode() string
- func (x *Code) GetExpiredMinite() uint32
- func (x *Code) GetId() string
- func (x *Code) GetIssueAt() int64
- func (x *Code) GetUsername() string
- func (c *Code) IsExpired() bool
- func (*Code) ProtoMessage()
- func (x *Code) ProtoReflect() protoreflect.Message
- func (x *Code) Reset()
- func (x *Code) String() string
- type IssueCodeRequest
- func (*IssueCodeRequest) Descriptor() ([]byte, []int)deprecated
- func (x *IssueCodeRequest) GetAccessToken() string
- func (x *IssueCodeRequest) GetAuthCode() string
- func (x *IssueCodeRequest) GetIssueBy() token.GRANT_TYPE
- func (x *IssueCodeRequest) GetPassword() string
- func (x *IssueCodeRequest) GetUsername() string
- func (*IssueCodeRequest) ProtoMessage()
- func (x *IssueCodeRequest) ProtoReflect() protoreflect.Message
- func (x *IssueCodeRequest) Reset()
- func (x *IssueCodeRequest) String() string
- func (req *IssueCodeRequest) Validate() error
- type IssueCodeResponse
- type RPCClient
- type RPCServer
- type Service
- type UnimplementedRPCServer
- type UnsafeRPCServer
- type VerifyCodeRequest
- func (*VerifyCodeRequest) Descriptor() ([]byte, []int)deprecated
- func (x *VerifyCodeRequest) GetCode() string
- func (x *VerifyCodeRequest) GetUsername() string
- func (req *VerifyCodeRequest) HashID() string
- func (*VerifyCodeRequest) ProtoMessage()
- func (x *VerifyCodeRequest) ProtoReflect() protoreflect.Message
- func (x *VerifyCodeRequest) Reset()
- func (x *VerifyCodeRequest) String() string
- func (req *VerifyCodeRequest) Validate() error
Constants ¶
const ( // CODE_HEADER_KEY = "X-MCENTER-CODE" // url?code=??? CODE_QUERY_KEY = "code" )
const (
AppName = "code"
)
Variables ¶
var File_apps_code_pb_code_proto protoreflect.FileDescriptor
var File_apps_code_pb_rpc_proto protoreflect.FileDescriptor
var RPC_ServiceDesc = grpc.ServiceDesc{ ServiceName: "go8.devcloud.mcenter.code.RPC", HandlerType: (*RPCServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "VerifyCode", Handler: _RPC_VerifyCode_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "apps/code/pb/rpc.proto", }
RPC_ServiceDesc is the grpc.ServiceDesc for RPC service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func GetCodeFromHTTP ¶
优先从认证头中获取, 如果头没有从Query String中获取
func RegisterRPCServer ¶
func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)
Types ¶
type Code ¶
type Code struct { // 编号 // @gotags: bson:"_id" json:"id" Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` // 验证码 // @gotags: bson:"code" json:"code" Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code" bson:"code"` // 用户名称 // @gotags: json:"username" validate:"required" Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username" 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 验证码
func (*Code) Descriptor
deprecated
func (*Code) GetExpiredMinite ¶
func (*Code) GetIssueAt ¶
func (*Code) GetUsername ¶
func (*Code) ProtoMessage ¶
func (*Code) ProtoMessage()
func (*Code) ProtoReflect ¶
func (x *Code) ProtoReflect() protoreflect.Message
type IssueCodeRequest ¶
type IssueCodeRequest struct { // 颁发方式 // @gotags: json:"issue_by" IssueBy token.GRANT_TYPE `protobuf:"varint,1,opt,name=issue_by,json=issueBy,proto3,enum=go8.devcloud.mcenter.token.GRANT_TYPE" json:"issue_by"` // PASSWORD/LDAP授权时, 用户名 // @gotags: json:"username,omitempty" Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` // PASSWORD/LDAP授权时, 用户密码 // @gotags: json:"password,omitempty" Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` // PRIVATE_TOKEN授权时, 访问令牌 // @gotags: json:"access_token,omitempty" AccessToken string `protobuf:"bytes,4,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` // AUTH_CODE授权时, Code, 针对第三方登陆: 飞书/钉钉/企业微信 // @gotags: json:"auth_code" AuthCode string `protobuf:"bytes,5,opt,name=auth_code,json=authCode,proto3" json:"auth_code"` // contains filtered or unexported fields }
IssueCodeRequest 验证码申请请求
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) GetAuthCode ¶
func (x *IssueCodeRequest) GetAuthCode() string
func (*IssueCodeRequest) GetIssueBy ¶
func (x *IssueCodeRequest) GetIssueBy() token.GRANT_TYPE
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
type IssueCodeResponse ¶
type IssueCodeResponse struct { // 颁发后返回的消息, 比如以发送到xxx手机 // @gotags: json:"message" Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message"` // contains filtered or unexported fields }
IssueCodeResponse 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 RPCClient ¶
type RPCClient interface {
VerifyCode(ctx context.Context, in *VerifyCodeRequest, opts ...grpc.CallOption) (*Code, error)
}
RPCClient is the client API for RPC 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 NewRPCClient ¶
func NewRPCClient(cc grpc.ClientConnInterface) RPCClient
type RPCServer ¶
type RPCServer interface { VerifyCode(context.Context, *VerifyCodeRequest) (*Code, error) // contains filtered or unexported methods }
RPCServer is the server API for RPC service. All implementations must embed UnimplementedRPCServer for forward compatibility
type Service ¶
type Service interface { RPCServer IssueCode(context.Context, *IssueCodeRequest) (*IssueCodeResponse, error) }
type UnimplementedRPCServer ¶
type UnimplementedRPCServer struct { }
UnimplementedRPCServer must be embedded to have forward compatible implementations.
func (UnimplementedRPCServer) VerifyCode ¶
func (UnimplementedRPCServer) VerifyCode(context.Context, *VerifyCodeRequest) (*Code, error)
type UnsafeRPCServer ¶
type UnsafeRPCServer interface {
// contains filtered or unexported methods
}
UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RPCServer will result in compilation errors.
type VerifyCodeRequest ¶
type VerifyCodeRequest struct { // 用户名 // @gotags: json:"username" validate:"required" Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username" validate:"required"` // 验证码 // @gotags: json:"code" validate:"required" Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code" validate:"required"` // contains filtered or unexported fields }
VerifyCodeRequest 验证码校验请求
func NewVerifyCodeRequest ¶
func NewVerifyCodeRequest(username, code string) *VerifyCodeRequest
func (*VerifyCodeRequest) Descriptor
deprecated
func (*VerifyCodeRequest) Descriptor() ([]byte, []int)
Deprecated: Use VerifyCodeRequest.ProtoReflect.Descriptor instead.
func (*VerifyCodeRequest) GetCode ¶
func (x *VerifyCodeRequest) GetCode() string
func (*VerifyCodeRequest) GetUsername ¶
func (x *VerifyCodeRequest) GetUsername() string
func (*VerifyCodeRequest) ProtoMessage ¶
func (*VerifyCodeRequest) ProtoMessage()
func (*VerifyCodeRequest) ProtoReflect ¶
func (x *VerifyCodeRequest) ProtoReflect() protoreflect.Message
func (*VerifyCodeRequest) Reset ¶
func (x *VerifyCodeRequest) Reset()
func (*VerifyCodeRequest) String ¶
func (x *VerifyCodeRequest) String() string