ninka

package
v0.0.0-...-5bbb7b8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	*jwt.Claims
	ID     common.UUID
	UserID common.UUID
}

Claims represents a set of claims with the token ID parsed into a UUID.

type InvalidToken

type InvalidToken struct {
	TokenID   *common.UUID
	ExpiresAt *time.Time
}

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

func (s *Server) RegisterServer(srv *ggrpc.Server)

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

func (s *Server) ValidateToken(ctx context.Context, in *ninka.Token) (*ninka.TokenResponse, error)

ValidateToken checks the validity of a token's signature, claims, user ID, and expiration time.

Jump to

Keyboard shortcuts

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