security

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ApplianceExternalIdType indicates Appliance ExternalID Type
	ApplianceExternalIdType = "Appliance"
	// SessionExternalIdType indicates Session ExternalID Type
	SessionExternalIdType = "Session"
	// UserExternalIdType indicates User ExternalID Type
	UserExternalIdType = "User"
	// PartnerExternalIdType indicates Partner ExternalID Type
	PartnerExternalIdType = "Partner"
)

Variables

This section is empty.

Functions

func Protect

func Protect(config *config.Config, handlerFunc func(w http.ResponseWriter, r *http.Request, token *JwtToken), allowedScopes []string, requireAdmin bool) func(w http.ResponseWriter, r *http.Request)

Protect authenticates and makes sure that caller is authorized to make the call before before invoking actual handler

Types

type JwtToken

type JwtToken struct {
	// UserID is id of user matching the token
	UserID         uuid.UUID   `json:"user,omitempty"`
	UserName       string      `json:"name,omitempty"`
	DisplayName    string      `json:"displayName,omitempty"`
	UserGroupIDs   []uuid.UUID `json:"usergroupIds,omitempty"`
	TenantID       uuid.UUID   `json:"tenant,omitempty"`
	TenantName     string      `json:"tenantName,omitempty"`
	ExternalID     string      `json:"externalId,omitempty"`
	ExternalIDType string      `json:"externalIdType,omitempty"`
	Scopes         []string    `json:"scope,omitempty"`
	Admin          bool        `json:"admin,omitempty"`
	PolicyID       uuid.UUID   `json:"policyId,omitempty"`  // PolicyID is id of policy matching the token
	PartnerID      uuid.UUID   `json:"partnerId,omitempty"` // PartnerID is id of partner matching the token
	Raw            string      `json:"-"`
	jwt.StandardClaims
}

JwtToken represents the parsed Token from Authentication Header

func GetTokenFromRawAuthHeader added in v1.0.0

func GetTokenFromRawAuthHeader(config *config.Config, rawAuthHeaderToken string) (*JwtToken, error)

GetTokenFromRawAuthHeader validates and gets JwtToken from given raw auth header token string rawAuthHeaderToken should be of format `Bearer {token-body}`

Jump to

Keyboard shortcuts

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