server

package
v0.0.0-...-68fba19 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisableVerification = false

DisableVerification won't pass through invalid JWT in production mode.

Functions

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

AuthMiddleware verifies JWT with authenticator.

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

CORSMiddleware appends CORS headers

func GetBearer

func GetBearer(auth []string) (jwt string, ok bool)

GetBearer gets a bearer token from Authorization header

func LogMiddleware

func LogMiddleware(logger loggerEntryWithFields, timeFormat string, utc bool) gin.HandlerFunc

LogMiddleware returns a gin.HandlerFunc (middleware) that logs requests using logrus.

Requests with errors are logged using logrus.Error(). Requests without errors are logged using logrus.Info().

It receives:

  1. A time package format string (e.g. time.RFC3339).
  2. A boolean stating whether to use UTC time zone or local.

func OptionalAuthMiddleware

func OptionalAuthMiddleware() gin.HandlerFunc

OptionalAuthMiddleware does optional JWT verification.

func OptionalUserMiddleware

func OptionalUserMiddleware() gin.HandlerFunc

OptionalUserMiddleware 認証していればユーザー情報を取得する

func RequirePathParam

func RequirePathParam(param string) gin.HandlerFunc

RequirePathParam parses PathParameter as uint64 by given param and then sets it to gin Context.

func RequireStringPathParam

func RequireStringPathParam(param string) gin.HandlerFunc

RequireStringPathParam parses PathParameter as string by given param and then sets it to gin Context.

func ServiceKeyMiddleware

func ServiceKeyMiddleware(si factory.Servicer) gin.HandlerFunc

ServiceKeyMiddleware provides the service factory

func SetAuth

func SetAuth(authenticator auth.Authenticator) gin.HandlerFunc

SetAuth passes an authenticator.

func Start

func Start() error

Start starts api server func Start(serverOptions Options) error {

func UserHandler

func UserHandler(c *gin.Context) error

UserHandler は認証情報からユーザー取得を行う

func UserMiddleware

func UserMiddleware() gin.HandlerFunc

UserMiddleware 認証したユーザー情報を取得する

Types

type AuthenticatedUser

type AuthenticatedUser struct {
	Email string
	Sub   string
	Token *jwt.Token
}

AuthenticatedUser verified user information

Jump to

Keyboard shortcuts

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