requestguard

package
v0.0.0-...-e2a5574 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: LGPL-2.1 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceScopeDomain  = ResourceScope("domain")
	ResourceScopeOrg     = ResourceScope("org")
	ResourceScopeOrgUnit = ResourceScope("orgunit")
	ResourceScopePrivate = ResourceScope("private")
)

Variables

This section is empty.

Functions

func AssertPermission

func AssertPermission(ctx corectx.Context, requiredPerm Perm) *ft.ClientErrors

Types

type ExtGetUserEntitlementsQuery

type ExtGetUserEntitlementsQuery struct {
	UserId    *model.Id `json:"user_id"`
	UserEmail *string   `json:"user_email"`
}

func (ExtGetUserEntitlementsQuery) CqrsRequestType

func (ExtGetUserEntitlementsQuery) CqrsRequestType() cqrs.RequestType

type ExtGetUserEntitlementsResultData

type ExtGetUserEntitlementsResultData struct {
	IsOwner      bool                 `json:"is_owner"`
	Entitlements []string             `json:"entitlements"`
	OrgUnitId    *model.Id            `json:"org_unit_id"`
	OrgUnitOrgId *model.Id            `json:"org_unit_org_id"`
	UserId       model.Id             `json:"user_id"`
	UserOrgIds   []model.Id           `json:"user_org_ids"`
	User         dmodel.DynamicFields `json:"user"`
}

type GetUserEntitlementsQuery

type GetUserEntitlementsQuery = ExtGetUserEntitlementsQuery

type GetUserEntitlementsResult

type GetUserEntitlementsResult = dyn.OpResult[GetUserEntitlementsResultData]

type GetUserEntitlementsResultData

type GetUserEntitlementsResultData = ExtGetUserEntitlementsResultData

type Perm

type Perm struct {
	ResourceCode string
	ActionCode   string
	Scope        ResourceScope
	// This is Org Unit ID to which the resource belongs (if any).
	// If this is not nil, then OrgId must be this Org Unit's Org ID.
	OrgUnitId *model.Id

	// This is the Org ID to which the resource belongs (if any)
	// Or, this can be the Org Unit's Org ID (if the resource belongs to an org unit)
	OrgId *model.Id
}

type PermissionContext

type PermissionContext struct {
	IsOwner      bool
	Entitlements []string
}

type RequestGuardService

type RequestGuardService interface {
	// Calculate a fingerprint for the request that can be used to identify the request.
	// This can be used for caching or to prevent replay attacks.
	CalcRequestFingerprint(ctx corectx.Context, request *http.Request) (fingerprint string, err error)
	GetCorsMiddleware(ctx corectx.Context) (echo.MiddlewareFunc, error)
	GetUserEntitlements(ctx corectx.Context, query GetUserEntitlementsQuery) (*GetUserEntitlementsResult, error)
	VerifyJwt(ctx corectx.Context, request *http.Request) (result *VerifyRequestResult, err error)
}

func NewStaticRequestGuardServiceImpl

func NewStaticRequestGuardServiceImpl(params StaticRequestGuardServiceParams) RequestGuardService

type ResourceScope

type ResourceScope string

type StaticRequestGuardServiceImpl

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

func (*StaticRequestGuardServiceImpl) CalcRequestFingerprint

func (this *StaticRequestGuardServiceImpl) CalcRequestFingerprint(_ corectx.Context, request *http.Request) (fingerprint string, err error)

func (*StaticRequestGuardServiceImpl) GetCorsMiddleware

func (this *StaticRequestGuardServiceImpl) GetCorsMiddleware(_ corectx.Context) (echo.MiddlewareFunc, error)

func (*StaticRequestGuardServiceImpl) GetUserEntitlements

func (*StaticRequestGuardServiceImpl) VerifyJwt

func (*StaticRequestGuardServiceImpl) VerifyJwtDpop

func (this *StaticRequestGuardServiceImpl) VerifyJwtDpop(ctx corectx.Context, request *http.Request) (*VerifyRequestResult, error)

Verify JWT DPoP (OAuth2 Demonstraing Proof of Possession)

func (*StaticRequestGuardServiceImpl) VerifySessionBlacklist

func (this *StaticRequestGuardServiceImpl) VerifySessionBlacklist(ctx corectx.Context, request *http.Request) (*VerifyRequestResult, error)

type StaticRequestGuardServiceParams

type StaticRequestGuardServiceParams struct {
	dig.In

	ConfigSvc config.ConfigService
	CqrsBus   cqrs.CqrsBus
	TokenSvc  coretoken.AuthTokenService
}

type VerifyRequestResult

type VerifyRequestResult struct {
	IsOk        bool
	JwtClaims   jwt.Claims
	ClientError *ft.ClientErrorItem
}

Jump to

Keyboard shortcuts

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