auth

package
v0.0.0-...-fd752eb Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInactiveAccessKey ...
	ErrInactiveAccessKey = errors.New("Inactive access key")
	// ErrTokenRevoked ...
	ErrTokenRevoked = errors.New("Token revoked")
	// ErrIssuer ...
	ErrIssuer = errors.New("Wrong Issuer for token")
	// ErrNullAccessKey ...
	ErrNullAccessKey = errors.New("Access key is empty")
	// ErrInactiveAccount ...
	ErrInactiveAccount = errors.New("Inactive account")
)

Functions

func RegisterAuthServiceServer

func RegisterAuthServiceServer(s *grpc.Server, srv AuthServiceServer)

Types

type AuthRequest

type AuthRequest struct {
	Token                string   `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

AuthRequest request for auth object

func (*AuthRequest) Descriptor

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

func (*AuthRequest) GetToken

func (m *AuthRequest) GetToken() string

func (*AuthRequest) ProtoMessage

func (*AuthRequest) ProtoMessage()

func (*AuthRequest) Reset

func (m *AuthRequest) Reset()

func (*AuthRequest) String

func (m *AuthRequest) String() string

func (*AuthRequest) XXX_DiscardUnknown

func (m *AuthRequest) XXX_DiscardUnknown()

func (*AuthRequest) XXX_Marshal

func (m *AuthRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AuthRequest) XXX_Merge

func (m *AuthRequest) XXX_Merge(src proto.Message)

func (*AuthRequest) XXX_Size

func (m *AuthRequest) XXX_Size() int

func (*AuthRequest) XXX_Unmarshal

func (m *AuthRequest) XXX_Unmarshal(b []byte) error

type AuthResponse

type AuthResponse struct {
	UserId               string   `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	CustomerId           string   `protobuf:"bytes,2,opt,name=customer_id,json=customerId,proto3" json:"customer_id,omitempty"`
	AppId                string   `protobuf:"bytes,3,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"`
	RoomId               string   `protobuf:"bytes,4,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"`
	PeerId               string   `protobuf:"bytes,5,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
	AuthId               string   `protobuf:"bytes,6,opt,name=auth_id,json=authId,proto3" json:"auth_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

AuthResponse response for auth object

func (*AuthResponse) Descriptor

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

func (*AuthResponse) GetAppId

func (m *AuthResponse) GetAppId() string

func (*AuthResponse) GetAuthId

func (m *AuthResponse) GetAuthId() string

func (*AuthResponse) GetCustomerId

func (m *AuthResponse) GetCustomerId() string

func (*AuthResponse) GetPeerId

func (m *AuthResponse) GetPeerId() string

func (*AuthResponse) GetRoomId

func (m *AuthResponse) GetRoomId() string

func (*AuthResponse) GetUserId

func (m *AuthResponse) GetUserId() string

func (*AuthResponse) Load

func (m *AuthResponse) Load(ctx context.Context, dbAuth *db.Auth, claims *Claims) error

Load load response data from auth object

func (*AuthResponse) ProtoMessage

func (*AuthResponse) ProtoMessage()

func (*AuthResponse) Reset

func (m *AuthResponse) Reset()

func (*AuthResponse) String

func (m *AuthResponse) String() string

func (*AuthResponse) XXX_DiscardUnknown

func (m *AuthResponse) XXX_DiscardUnknown()

func (*AuthResponse) XXX_Marshal

func (m *AuthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AuthResponse) XXX_Merge

func (m *AuthResponse) XXX_Merge(src proto.Message)

func (*AuthResponse) XXX_Size

func (m *AuthResponse) XXX_Size() int

func (*AuthResponse) XXX_Unmarshal

func (m *AuthResponse) XXX_Unmarshal(b []byte) error

type AuthServiceClient

type AuthServiceClient interface {
	// Send a token and validate
	ValidateToken(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*AuthResponse, error)
	GenerateToken(ctx context.Context, in *TokenRequest, opts ...grpc.CallOption) (*TokenResponse, error)
}

AuthServiceClient is the client API for AuthService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type AuthServiceServer

type AuthServiceServer interface {
	// Send a token and validate
	ValidateToken(context.Context, *AuthRequest) (*AuthResponse, error)
	GenerateToken(context.Context, *TokenRequest) (*TokenResponse, error)
}

AuthServiceServer is the server API for AuthService service.

type Claims

type Claims struct {
	AccessKey string `json:"access_key"`
	AppID     string `json:"app_id"`
	PeerID    string `json:"peer_id,omitempty"`
	RoomID    string `json:"room_id,omitempty"`
	jwt.StandardClaims
	// contains filtered or unexported fields
}

Claims defines jwt claims

func (*Claims) Valid

func (claims *Claims) Valid() error

Valid ...

type Config

type Config struct {
	Port      int    `mapstructure:"port,omitempty"`
	Algorithm string `mapstructure:"algo,omitempty"`
	Cert      string `mapstructure:"cert,omitempty"`
	Key       string `mapstructure:"key,omitempty"`
	UTC       bool   `mapstructure:"utc,omitempty"`
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig default config

func (Config) String

func (config Config) String() string

type Server

type Server struct {
	UnimplementedAuthServiceServer
	// contains filtered or unexported fields
}

Server ...

func NewServer

func NewServer(config *Config) *Server

NewServer ...

func (*Server) GenerateToken

func (s *Server) GenerateToken(ctx context.Context, req *TokenRequest) (*TokenResponse, error)

GenerateToken generate token

func (*Server) Start

func (s *Server) Start() error

Start start server

func (*Server) ValidateToken

func (s *Server) ValidateToken(ctx context.Context, req *AuthRequest) (*AuthResponse, error)

ValidateToken ...

type TokenRequest

type TokenRequest struct {
	Access_Key           string   `protobuf:"bytes,1,opt,name=access_Key,json=accessKey,proto3" json:"access_Key,omitempty"`
	Duration             int32    `protobuf:"varint,2,opt,name=duration,proto3" json:"duration,omitempty"`
	Starts               int32    `protobuf:"varint,3,opt,name=starts,proto3" json:"starts,omitempty"`
	RoomId               string   `protobuf:"bytes,4,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"`
	PeerId               string   `protobuf:"bytes,5,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Token Request

func (*TokenRequest) Descriptor

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

func (*TokenRequest) GetAccess_Key

func (m *TokenRequest) GetAccess_Key() string

func (*TokenRequest) GetDuration

func (m *TokenRequest) GetDuration() int32

func (*TokenRequest) GetPeerId

func (m *TokenRequest) GetPeerId() string

func (*TokenRequest) GetRoomId

func (m *TokenRequest) GetRoomId() string

func (*TokenRequest) GetStarts

func (m *TokenRequest) GetStarts() int32

func (*TokenRequest) ProtoMessage

func (*TokenRequest) ProtoMessage()

func (*TokenRequest) Reset

func (m *TokenRequest) Reset()

func (*TokenRequest) String

func (m *TokenRequest) String() string

func (*TokenRequest) XXX_DiscardUnknown

func (m *TokenRequest) XXX_DiscardUnknown()

func (*TokenRequest) XXX_Marshal

func (m *TokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TokenRequest) XXX_Merge

func (m *TokenRequest) XXX_Merge(src proto.Message)

func (*TokenRequest) XXX_Size

func (m *TokenRequest) XXX_Size() int

func (*TokenRequest) XXX_Unmarshal

func (m *TokenRequest) XXX_Unmarshal(b []byte) error

type TokenResponse

type TokenResponse struct {
	Token                string   `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Token Response

func (*TokenResponse) Descriptor

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

func (*TokenResponse) GetToken

func (m *TokenResponse) GetToken() string

func (*TokenResponse) ProtoMessage

func (*TokenResponse) ProtoMessage()

func (*TokenResponse) Reset

func (m *TokenResponse) Reset()

func (*TokenResponse) String

func (m *TokenResponse) String() string

func (*TokenResponse) XXX_DiscardUnknown

func (m *TokenResponse) XXX_DiscardUnknown()

func (*TokenResponse) XXX_Marshal

func (m *TokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TokenResponse) XXX_Merge

func (m *TokenResponse) XXX_Merge(src proto.Message)

func (*TokenResponse) XXX_Size

func (m *TokenResponse) XXX_Size() int

func (*TokenResponse) XXX_Unmarshal

func (m *TokenResponse) XXX_Unmarshal(b []byte) error

type UnimplementedAuthServiceServer

type UnimplementedAuthServiceServer struct {
}

UnimplementedAuthServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedAuthServiceServer) GenerateToken

func (*UnimplementedAuthServiceServer) ValidateToken

Jump to

Keyboard shortcuts

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