accesscontrol

package
v1.14.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultArgon2MemoryBudget uint32 = 256 * 1024

DefaultArgon2MemoryBudget is the memory in KiB that the argon2 derivations may use at the same time, if the settings give no beta_argon2_memory_budget.

View Source
const (
	DpopTyp = "dpop+jwt"
)

Variables

This section is empty.

Functions

func JwkToJKT added in v1.14.0

func JwkToJKT(jwk map[string]interface{}) string

JwkToJKT creates a JWK SHA-256 thumbprint.

func JwkToString added in v1.14.0

func JwkToString(jwk map[string]interface{}) string

Types

type AccessControl

type AccessControl interface {
	Validate(req *http.Request) error
}

type Argon2CostWarning added in v1.14.3

type Argon2CostWarning struct {
	User      string
	Line      int
	Parameter string // m, t or p
	Value     uint64
	Maximum   uint64
}

Argon2CostWarning names an htpasswd entry that loads with an argon2 parameter above the recommended maximum. Each request for this user pays that cost.

func (Argon2CostWarning) String added in v1.14.3

func (w Argon2CostWarning) String() string

String states the fact. The caller adds the location and the advice.

type Argon2Limiter added in v1.14.3

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

Argon2Limiter limits the argon2 derivations that run at the same time, so the peak memory follows a budget and not the number of requests. One limiter serves all basic_auth blocks of a configuration.

func NewArgon2Limiter added in v1.14.3

func NewArgon2Limiter(budget, memory uint32) *Argon2Limiter

NewArgon2Limiter gives as many slots as derivations of the most expensive entry fit into the budget, both in KiB. The number of cores is the upper limit, because a derivation keeps one core busy and more slots only raise the memory use. One derivation can always run, even if it alone exceeds the budget.

func (*Argon2Limiter) PeakMemory added in v1.14.3

func (l *Argon2Limiter) PeakMemory() uint64

PeakMemory returns the memory in KiB that all slots use together.

func (*Argon2Limiter) Slots added in v1.14.3

func (l *Argon2Limiter) Slots() int

Slots returns the number of derivations that run at the same time.

type BasicAuth

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

BasicAuth represents an AC-BasicAuth object

func NewBasicAuth

func NewBasicAuth(name, user, pass, file string) (*BasicAuth, error)

NewBasicAuth creates a new AC-BasicAuth object

func (*BasicAuth) Argon2Memory added in v1.14.3

func (ba *BasicAuth) Argon2Memory() uint32

Argon2Memory returns the memory in KiB that one derivation of the most expensive argon2 entry needs, or 0 if no entry uses argon2.

func (*BasicAuth) UseArgon2Limiter added in v1.14.3

func (ba *BasicAuth) UseArgon2Limiter(limiter *Argon2Limiter)

UseArgon2Limiter replaces the limiter, so all basic_auth blocks of a configuration share one memory budget.

func (*BasicAuth) Validate

func (ba *BasicAuth) Validate(req *http.Request) error

Validate implements the AccessControl interface

func (*BasicAuth) Warnings added in v1.14.3

func (ba *BasicAuth) Warnings() []Argon2CostWarning

Warnings lists the htpasswd entries that load with an argon2 parameter above the recommended maximum.

type DPoPTokenSource added in v1.14.0

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

func (*DPoPTokenSource) TokenValue added in v1.14.0

func (s *DPoPTokenSource) TokenValue(req *http.Request) (string, error)

func (*DPoPTokenSource) ValidateTokenClaims added in v1.14.0

func (s *DPoPTokenSource) ValidateTokenClaims(token string, tokenClaims map[string]interface{}, req *http.Request) error

type DisablePrivateCaching

type DisablePrivateCaching interface {
	DisablePrivateCaching() bool
}

type IntrospectionResponse added in v1.14.0

type IntrospectionResponse map[string]interface{}

IntrospectionResponse represents the response body to a token introspection request.

func NewIntrospectionResponse added in v1.14.0

func NewIntrospectionResponse(res *http.Response) (IntrospectionResponse, error)

func (IntrospectionResponse) Active added in v1.14.0

func (ir IntrospectionResponse) Active() bool

Active returns whether the token is active.

type Introspector added in v1.14.0

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

Introspector represents a token introspector.

func NewIntrospector added in v1.14.0

func NewIntrospector(evalCtx *hcl.EvalContext, conf *config.Introspection, transport http.RoundTripper, memStore *cache.MemoryStore) (*Introspector, error)

NewIntrospector creates a new token introspector.

func (*Introspector) Introspect added in v1.14.0

func (i *Introspector) Introspect(ctx context.Context, token string, exp, nbf int64) (IntrospectionResponse, error)

Introspect retrieves introspection data for the given token using either cached or fresh information.

type JWT

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

func NewJWT

func NewJWT(jwtConf *config.JWT, introspector *Introspector, key []byte, memStore *cache.MemoryStore) (*JWT, error)

NewJWT parses the key and creates Validation obj which can be referenced in related handlers.

func NewJWTFromJWKS

func NewJWTFromJWKS(jwtConf *config.JWT, introspector *Introspector, jwks *jwk.JWKS, memStore *cache.MemoryStore) (*JWT, error)

func (*JWT) DisablePrivateCaching

func (j *JWT) DisablePrivateCaching() bool

func (*JWT) Validate

func (j *JWT) Validate(req *http.Request) error

Validate reading the token from configured source and validates against the key.

type LimiterEntry added in v1.14.0

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

type List

type List []*ListItem

type ListItem

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

func NewItem

func NewItem(nameLabel string, control AccessControl, errHandler http.Handler) *ListItem

func (ListItem) DisablePrivateCaching

func (i ListItem) DisablePrivateCaching() bool

func (ListItem) ErrorHandler

func (i ListItem) ErrorHandler() http.Handler

func (ListItem) Kind added in v1.14.0

func (i ListItem) Kind() string

func (ListItem) Label added in v1.14.0

func (i ListItem) Label() string

func (ListItem) Validate

func (i ListItem) Validate(req *http.Request) error

type Map

type Map map[string]AccessControl

type NameTokenSource added in v1.14.0

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

func (*NameTokenSource) TokenValue added in v1.14.0

func (s *NameTokenSource) TokenValue(req *http.Request) (string, error)

func (*NameTokenSource) ValidateTokenClaims added in v1.14.0

func (s *NameTokenSource) ValidateTokenClaims(token string, tokenClaims map[string]interface{}, req *http.Request) error

type OAuth2Callback

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

OAuth2Callback represents the access control for the OAuth2 authorization code flow callback.

func NewOAuth2Callback

func NewOAuth2Callback(oauth2Client oauth2.AuthCodeFlowClient, name string) *OAuth2Callback

NewOAuth2Callback creates a new access control for the OAuth2 authorization code flow callback.

func (*OAuth2Callback) Validate

func (oa *OAuth2Callback) Validate(req *http.Request) error

Validate implements the AccessControl interface

type PermissionsControl

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

func NewPermissionsControl

func NewPermissionsControl(permissionExpr hcl.Expression) *PermissionsControl

func (*PermissionsControl) Validate

func (p *PermissionsControl) Validate(req *http.Request) error

Validate validates the granted permissions provided by access controls against the required permission.

type ProofClaims added in v1.14.0

type ProofClaims struct {
	jwt.RegisteredClaims
	Ath string `json:"ath,omitempty"`
	Htm string `json:"htm,omitempty"`
	Htu string `json:"htu,omitempty"`
	// contains filtered or unexported fields
}

func (*ProofClaims) Validate added in v1.14.0

func (p *ProofClaims) Validate() error

type ProtectedHandler

type ProtectedHandler interface {
	Child() http.Handler
}

type RateLimiter added in v1.14.0

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

RateLimiter represents an AC-RateLimiter object

func NewRateLimiter added in v1.14.0

func NewRateLimiter(ctx context.Context, name string, conf *config.RateLimiter) (*RateLimiter, error)

NewRateLimiter creates a new AC-RateLimiter object

func (*RateLimiter) ActiveKeyCount added in v1.14.0

func (rl *RateLimiter) ActiveKeyCount() int

ActiveKeyCount returns the number of currently tracked keys.

func (*RateLimiter) Name added in v1.14.0

func (rl *RateLimiter) Name() string

Name returns the rate limiter's configured name.

func (*RateLimiter) Validate added in v1.14.0

func (rl *RateLimiter) Validate(req *http.Request) error

Validate implements the AccessControl interface

type Saml2

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

func NewSAML2ACS

func NewSAML2ACS(provider samlpkg.MetadataProvider, name string, acsURL string, spEntityID string, arrayAttributes []string) (*Saml2, error)

func (*Saml2) GetAssertionData

func (s *Saml2) GetAssertionData(assertionInfo *saml2.AssertionInfo) map[string]interface{}

func (*Saml2) Validate

func (s *Saml2) Validate(req *http.Request) error

func (*Saml2) ValidateAssertionInfo

func (s *Saml2) ValidateAssertionInfo(assertionInfo *saml2.AssertionInfo) error

type TokenSource

type TokenSource interface {
	// TokenValue retrieves the token value from the request.
	TokenValue(req *http.Request) (string, error)
	// ValidateTokenClaims validates the token (claims) according to e.g. a specific request header field.
	ValidateTokenClaims(token string, tokenClaims map[string]interface{}, req *http.Request) error
}

TokenSource represents the source from which a token is retrieved.

func NewTokenSource

func NewTokenSource(bearer, dpop bool, cookie, header string, value hcl.Expression) (TokenSource, error)

NewTokenSource creates a new token source according to various configuration attributes.

type ValidateFunc

type ValidateFunc func(*http.Request) error

func (ValidateFunc) Validate

func (f ValidateFunc) Validate(req *http.Request) error

type ValueTokenSource added in v1.14.0

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

func (*ValueTokenSource) TokenValue added in v1.14.0

func (s *ValueTokenSource) TokenValue(req *http.Request) (string, error)

func (*ValueTokenSource) ValidateTokenClaims added in v1.14.0

func (s *ValueTokenSource) ValidateTokenClaims(token string, tokenClaims map[string]interface{}, req *http.Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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