service

package
v0.0.0-...-c131d26 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeGRPCTokenAffectRequest

func DecodeGRPCTokenAffectRequest(ctx context.Context, r interface{}) (interface{}, error)

func DecodeGRPCTokenAffectResponse

func DecodeGRPCTokenAffectResponse(_ context.Context, r interface{}) (interface{}, error)

func DecodeGRPCTokenRenewRequest

func DecodeGRPCTokenRenewRequest(ctx context.Context, r interface{}) (interface{}, error)

Encode and Decode Renew request

func DecodeGRPCTokenRequest

func DecodeGRPCTokenRequest(ctx context.Context, r interface{}) (interface{}, error)

func DecodeGRPCTokenResponse

func DecodeGRPCTokenResponse(_ context.Context, r interface{}) (interface{}, error)

func DecodeGRPCTokenVerifyRequest

func DecodeGRPCTokenVerifyRequest(ctx context.Context, r interface{}) (interface{}, error)

func DecodeGRPCTokenVerifyResponse

func DecodeGRPCTokenVerifyResponse(_ context.Context, r interface{}) (interface{}, error)

func EncodeGRPCTokenAffectRequest

func EncodeGRPCTokenAffectRequest(_ context.Context, r interface{}) (interface{}, error)

Encode and Decode Token Affect Request

func EncodeGRPCTokenAffectResponse

func EncodeGRPCTokenAffectResponse(_ context.Context, r interface{}) (interface{}, error)

Encode and Decode Token Response

func EncodeGRPCTokenRenewRequest

func EncodeGRPCTokenRenewRequest(_ context.Context, r interface{}) (interface{}, error)

Encode and Decode Token Request

func EncodeGRPCTokenRequest

func EncodeGRPCTokenRequest(_ context.Context, r interface{}) (interface{}, error)

Encode and Decode Token Request

func EncodeGRPCTokenResponse

func EncodeGRPCTokenResponse(_ context.Context, r interface{}) (interface{}, error)

Encode and Decode Token Response

func EncodeGRPCTokenVerifyRequest

func EncodeGRPCTokenVerifyRequest(_ context.Context, r interface{}) (interface{}, error)

/ Verify Request response - encode/decode

func EncodeGRPCTokenVerifyResponse

func EncodeGRPCTokenVerifyResponse(_ context.Context, r interface{}) (interface{}, error)

Encode and Decode Token Response

func ExtractTokenMetadata

func ExtractTokenMetadata(tokenString string, refresh bool) (*models.AccessDetails, jwt.MapClaims, error)

func FetchAuth

func FetchAuth(authD *models.AccessDetails) (uint64, string, error)

FetchAuth : ensure the token hasn't expired

func FetchRefresh

func FetchRefresh(authD *models.AccessDetails) (map[string]string, error)

FetchRefresh : ensure the token hasn't expired

func MakeTokenServicAffectEndpoint

func MakeTokenServicAffectEndpoint(svc TokenServiceInterface) endpoint.Endpoint

func MakeTokenServiceGenerateEndpoint

func MakeTokenServiceGenerateEndpoint(svc TokenServiceInterface) endpoint.Endpoint

func MakeTokenServiceRenewEndpoint

func MakeTokenServiceRenewEndpoint(svc TokenServiceInterface) endpoint.Endpoint

func MakeTokenServiceVerifyEndpoint

func MakeTokenServiceVerifyEndpoint(svc TokenServiceInterface) endpoint.Endpoint

func MergeClaims

func MergeClaims(claims map[string]string) jwt.MapClaims

func MergeClaimsReverse

func MergeClaimsReverse(claims jwt.MapClaims) map[string]string

func NewGRPCServer

func NewGRPCServer(ctx context.Context, endpoint TokenServiceEndpoints) pb.TokenServiceServer

create new grpc server

func RedisInit

func RedisInit() (string, error)

func TokenValid

func TokenValid(tokenString string) error

func VerifyTokenIntegrity

func VerifyTokenIntegrity(tokenString string, isRfresh bool) (*jwt.Token, error)

Types

type EndpointsConsul

type EndpointsConsul struct {
	ConsulHealthCheckEndpoint endpoint.Endpoint
	ConsulHealthWatchEndpoint endpoint.Endpoint
}

wrapper for the endpoints

type HealthServiceRequest

type HealthServiceRequest struct {
	Service string `json:"service,omitempty"`
}

type HealthServiceResponse

type HealthServiceResponse struct {
	Status int `json:"status,omitempty"`
}

type TokenRenewRequest

type TokenRenewRequest struct {
	RefreshToken string `json:"refresh_token,omitempty"`
}

type TokenRequest

type TokenRequest struct {
	Claims map[string]string `json:"claims,omitempty"`
}

type TokenResponse

type TokenResponse struct {
	Response models.AccessTokens `json:"tokens,omitempty"`
	Error    models.ServiceError
}

type TokenService

type TokenService struct {
}

func (TokenService) AffectToken

func (ts TokenService) AffectToken(ctx context.Context, tokenToAffect models.TokenAffectRequest) (*models.TokenAffectResponse, error)

AffectToken : Expandable service module API

func (TokenService) Generate

func (ts TokenService) Generate(ctx context.Context, claims map[string]string) (*models.AccessTokens, error)

Generate : Generate the Token Pair

func (TokenService) RenewTokens

func (ts TokenService) RenewTokens(ctx context.Context, token TokenRenewRequest) (*TokenResponse, error)

RenewTokens : Re-Generate a new token pair

func (TokenService) VerifyToken

func (ts TokenService) VerifyToken(ctx context.Context, tokenToverify TokenVerifyRequest) (*models.TokenVerifyResponse, interface{})

VerifyToken : Claim verification and authorisation

type TokenServiceEndpoints

type TokenServiceEndpoints struct {
	GenerateEndpoint endpoint.Endpoint
	VerifyEndpoint   endpoint.Endpoint
	AffectEndpoint   endpoint.Endpoint
	RenewEndpoint    endpoint.Endpoint
}

func (TokenServiceEndpoints) AffectToken

func (te TokenServiceEndpoints) AffectToken(ctx context.Context, tokenAffectRequest models.TokenAffectRequest) (*models.TokenAffectResponse, error)

func (TokenServiceEndpoints) Generate

func (te TokenServiceEndpoints) Generate(ctx context.Context, claims map[string]string) (*models.AccessTokens, error)

func (TokenServiceEndpoints) RenewTokens

func (te TokenServiceEndpoints) RenewTokens(ctx context.Context, refreshToken TokenRenewRequest) (*TokenResponse, error)

func (TokenServiceEndpoints) VerifyToken

func (te TokenServiceEndpoints) VerifyToken(ctx context.Context, tokenToverify TokenVerifyRequest) (*models.TokenVerifyResponse, interface{})

type TokenServiceInterface

type TokenServiceInterface interface {
	Generate(ctx context.Context, claims map[string]string) (*models.AccessTokens, error)
	VerifyToken(ctx context.Context, tokenToverify TokenVerifyRequest) (*models.TokenVerifyResponse, interface{})
	RenewTokens(ctx context.Context, token TokenRenewRequest) (*TokenResponse, error)
	AffectToken(ctx context.Context, tokenAffectRequest models.TokenAffectRequest) (*models.TokenAffectResponse, error)
}

type TokenVerifyRequest

type TokenVerifyRequest struct {
	Token   string `json:"token"`
	Service string `json:"service,omitempty"`
}

Jump to

Keyboard shortcuts

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