gateway

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// KeyUserID is identifier to get the current user's ID from the session store
	KeyUserID = "Grac-Session-User-Id"
	// KeyUserRole is the identifier to get the current user's role from the session store
	KeyUserRole = "Grac-Session-User-Role"
	// KeyDeleteSession is the identifier to check whether the session should be deleted
	KeyDeleteSession = "Grac-Is-Delete-Session"
	// KeyAuthorization is the key to look for the authorization header
	KeyAuthorization = "authorization"
	// KeyUserCSRFToken is the identifier for csrf token
	KeyUserCSRFToken = "X-Xsrf-Token"
	// ErrFailedTokenGeneration is to show when the token generation fails
	ErrFailedTokenGeneration = "GRAC Error: Failed to generate access token"
)

Variables

This section is empty.

Functions

func GetRequestFromContext added in v0.0.5

func GetRequestFromContext(ctx context.Context) *http.Request

GetRequestFromContext pulls the request from context (set in middleware above)

func Middleware

func Middleware(next http.Handler) http.Handler

Middleware adds request to context

Types

type Modifier

type Modifier struct {
	// contains filtered or unexported fields
}

Modifier defines a store to save session

func NewModifier added in v0.0.2

func NewModifier(store *redisstore.RedisStore, config interface{}) *Modifier

NewModifier returns a gateway input/output modifier

func (*Modifier) MetadataAnnotator

func (m *Modifier) MetadataAnnotator(ctx context.Context, r *http.Request) metadata.MD

MetadataAnnotator looks up session and passes session data and jwt token to gRPC method

func (*Modifier) ResponseModifier added in v0.0.2

func (m *Modifier) ResponseModifier(ctx context.Context, w http.ResponseWriter, resp protoiface.MessageV1) error

ResponseModifier checks whether the gRPC method called has requested for changing the response before the http response is sent

type Session

type Session struct {
	// User ID
	UserID int
	// CSRF token for the session
	CSRFToken *manager.Token
	// User role
	Role string
}

Session is the structure holding session data that gorilla's session store will convert into a cookie.

Jump to

Keyboard shortcuts

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