auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const OrgMemberContextKey = "authenticated_organization_member"

Variables

This section is empty.

Functions

func GetAuthenticatedOrgMemberNoFail

func GetAuthenticatedOrgMemberNoFail(ginctx *gin.Context) dbmodels.IOrganizationMember

GetAuthenticatedOrgMemberNoFail returns the OrganizationMember that's authenticated with the current request.

It assumes that the `NewOrgMemberLookupMiddleware()` middleware has already run, hence this function never returns an error.

func NewJwtMiddleware

func NewJwtMiddleware(db *gorm.DB) (*jwt.GinJWTMiddleware, error)

func NewOrgMemberLookupMiddleware

func NewOrgMemberLookupMiddleware(db *gorm.DB, testing bool) gin.HandlerFunc

NewOrgMemberLookupMiddleware returns a Gin middleware which finds out which organization member is authenticated with the current request, looks up its record from the database, and associates that record with the current request.

If `testing` is true, then it determines which organization member is authenticated by looking at the HTTP headers `TestOrgID`, `TestOrgMemberType` and `TestOrgMemberID`.

If `testing` is false, or if no HTTP headers specify which organization member to authenticate as, then it looks at the JWT authorization token. This requires that the `NewJwtMiddleware()` middleware has already run.

You can get the looked up record using `GetAuthenticatedOrgMemberNoFail()`.

If no OrganizationMember is found at the end, or if some other error occurs, then this middleware aborts the request with an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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