gateway

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package gateway implments various auth logic used across noebs services

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCreateDbRow = errors.New("unable to create a new db row/column")
)

Functions

func GenerateAPIKey

func GenerateAPIKey() (string, error)

func GenerateSecretKey

func GenerateSecretKey(n int) ([]byte, error)

GenerateSecretKey generates secret key for jwt signing

func Instrumentation

func Instrumentation() gin.HandlerFunc

func NoebsCors added in v0.3.0

func NoebsCors(headers []string) func(c *gin.Context)

NoebsCors reads from noebs config to setup cors headers for the server

Types

type Cards

type Cards struct {
	gorm.Model
	PAN       string `json:"pan" binding:"required"`
	Expdate   string `json:"exp_date" binding:"required"`
	IsPrimary bool   `json:"is_primary" binding:"required"`
}

type ErrorResponse

type ErrorResponse struct {
	Code    uint
	Message string
}

type GetRedisClient

type GetRedisClient func(string) *redis.Client

type JWT

type JWT struct {
	gorm.Model
	SecretKey string
}

type JWTAuth

type JWTAuth struct {
	Key         []byte
	NoebsConfig ebs_fields.NoebsConfig
}

JWTAuth provides an encapsulation for jwt auth

func (*JWTAuth) AuthMiddleware

func (a *JWTAuth) AuthMiddleware() gin.HandlerFunc

AuthMiddleware is a JWT authorization middleware. It is used in our consumer services to get a username from the payload (maybe change it to mobile number at somepoint)

func (*JWTAuth) GenerateJWT

func (j *JWTAuth) GenerateJWT(serviceID string) (string, error)

GenerateJWT generates a JWT standard token with default values hardcoded. FIXME

func (*JWTAuth) Init

func (j *JWTAuth) Init()

Init initializes jwt auth

func (*JWTAuth) VerifyJWT

func (j *JWTAuth) VerifyJWT(tokenString string) (*TokenClaims, error)

VerifyJWT giving a jwt token and a secret it validates the token against a hard coded TokenClaims struct

type Service

type Service struct {
	gorm.Model
	ServiceName string `gorm:"index"`
	Password    string
	JWT         JWT
	JWTID       int
}

type Token

type Token struct {
	JWT       string `json:"authorization"`
	Signature string `json:"signature"`
	Message   string `json:"message"`
	Mobile    string `json:"mobile" binding:"required,len=10"`
}

Token used by noebs client to refresh an existing token, that is Token.JWT Signature is the signed Message (it could be a mobile username, or totp code) and Message is the raw message (it could be a mobile username, or totp code)

type TokenClaims

type TokenClaims struct {
	Mobile string `json:"mobile"`
	jwt.StandardClaims
}

TokenClaims noebs standard claim

Jump to

Keyboard shortcuts

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