auth

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthService_Login_FullMethodName = "/auth.AuthService/Login"
)

Variables

View Source
var AuthService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "auth.AuthService",
	HandlerType: (*AuthServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Login",
			Handler:    _AuthService_Login_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "api/proto/auth.proto",
}

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

View Source
var File_api_proto_auth_proto protoreflect.FileDescriptor

Functions

func RegisterAuthServiceServer

func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer)

func RegisterServer

func RegisterServer(s grpc.ServiceRegistrar, token Token)

RegisterServer register the auth server

Types

type AuthServiceClient

type AuthServiceClient interface {
	// Login login to the api server and return the access token
	Login(ctx context.Context, in *LoginUser, opts ...grpc.CallOption) (*LoginReply, error)
}

AuthServiceClient is the client API for AuthService 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.

type AuthServiceServer

type AuthServiceServer interface {
	// Login login to the api server and return the access token
	Login(context.Context, *LoginUser) (*LoginReply, error)
	// contains filtered or unexported methods
}

AuthServiceServer is the server API for AuthService service. All implementations must embed UnimplementedAuthServiceServer for forward compatibility

type LoginReply

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

func (*LoginReply) Descriptor deprecated

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

Deprecated: Use LoginReply.ProtoReflect.Descriptor instead.

func (*LoginReply) GetToken

func (x *LoginReply) GetToken() string

func (*LoginReply) ProtoMessage

func (*LoginReply) ProtoMessage()

func (*LoginReply) ProtoReflect

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

func (*LoginReply) Reset

func (x *LoginReply) Reset()

func (*LoginReply) String

func (x *LoginReply) String() string

type LoginUser

type LoginUser struct {
	Username  string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	Password  string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	Timestamp int64  `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

func (*LoginUser) Descriptor deprecated

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

Deprecated: Use LoginUser.ProtoReflect.Descriptor instead.

func (*LoginUser) GetPassword

func (x *LoginUser) GetPassword() string

func (*LoginUser) GetTimestamp

func (x *LoginUser) GetTimestamp() int64

func (*LoginUser) GetUsername

func (x *LoginUser) GetUsername() string

func (*LoginUser) ProtoMessage

func (*LoginUser) ProtoMessage()

func (*LoginUser) ProtoReflect

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

func (*LoginUser) Reset

func (x *LoginUser) Reset()

func (*LoginUser) String

func (x *LoginUser) String() string

type Token

type Token interface {
	// GenerateToken generate a new token by user info
	GenerateToken(in *LoginUser) (token string, err error)
	// IsLogin resolve the token in the context.Context
	IsLogin(ctx context.Context) (user *auth.User, err error)
}

Token an authentication and token component

func NewToken

func NewToken(users []*auth.User, secret string) (Token, error)

NewToken create a default implementation of the Token

type TokenUser

type TokenUser struct {
	UserId   int32  `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	Expires  int64  `protobuf:"varint,3,opt,name=expires,proto3" json:"expires,omitempty"`
	// contains filtered or unexported fields
}

func (*TokenUser) Descriptor deprecated

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

Deprecated: Use TokenUser.ProtoReflect.Descriptor instead.

func (*TokenUser) GetExpires

func (x *TokenUser) GetExpires() int64

func (*TokenUser) GetUserId

func (x *TokenUser) GetUserId() int32

func (*TokenUser) GetUsername

func (x *TokenUser) GetUsername() string

func (*TokenUser) ProtoMessage

func (*TokenUser) ProtoMessage()

func (*TokenUser) ProtoReflect

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

func (*TokenUser) Reset

func (x *TokenUser) Reset()

func (*TokenUser) String

func (x *TokenUser) String() string

type UnimplementedAuthServiceServer

type UnimplementedAuthServiceServer struct {
}

UnimplementedAuthServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedAuthServiceServer) Login

type UnsafeAuthServiceServer

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

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

Jump to

Keyboard shortcuts

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