Documentation ¶
Index ¶
- type Claims
- type InvalidToken
- type Server
- func (s *Server) CreateToken(ctx context.Context, in *ninka.TokenRequest) (token *ninka.Token, err error)
- func (s *Server) InvalidateToken(ctx context.Context, in *common.Claims) (*ninka.TokenResponse, error)
- func (s *Server) RegisterServer(srv *ggrpc.Server)
- func (s *Server) StartServer()
- func (s *Server) ValidateToken(ctx context.Context, in *ninka.Token) (*ninka.TokenResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InvalidToken ¶
InvalidToken stores the token IDs of manually invalidated JWTs until their normal expiration time.
type Server ¶
type Server struct { *grpc.Server ninka.NinkaServer // contains filtered or unexported fields }
Server defines the structure of a server for the Kazoku service.
func NewServer ¶
func NewServer(config *service.ServerConfig) *Server
NewServer returns a new gRPC server for the Ninka service.
func (*Server) CreateToken ¶
func (s *Server) CreateToken(ctx context.Context, in *ninka.TokenRequest) (token *ninka.Token, err error)
CreateToken creates and signs a new JWT for an authenticated user.
func (*Server) InvalidateToken ¶
func (s *Server) InvalidateToken(ctx context.Context, in *common.Claims) (*ninka.TokenResponse, error)
InvalidateToken saves the given token ID in the list of invalidated tokens. The record expires at the same time that the token itself would expire. If the token is already invalid, nothing is done.
func (*Server) RegisterServer ¶
RegisterServer registers the gRPC server as a Ninka service handler.
func (*Server) StartServer ¶
func (s *Server) StartServer()
StartServer initializes the MongoDB connection and database and starts the server.
func (*Server) ValidateToken ¶
ValidateToken checks the validity of a token's signature, claims, user ID, and expiration time.