Documentation
¶
Overview ¶
Package auth defines authentication pipeline interfaces and shared context types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthContext ¶
type AuthContext struct {
Request *radius.Request
Response *radius.Packet
User *domain.RadiusUser
Nas *domain.NetNas
VendorRequest interface{}
IsMacAuth bool // whether this is MAC authentication
Metadata map[string]interface{} // Additional metadata
}
AuthContext represents the authentication context
type BaseGuard ¶
type BaseGuard struct{}
BaseGuard provides a default implementation of Guard interface. Embed this in custom guards to get default behavior.
func (*BaseGuard) OnAuthError ¶
func (g *BaseGuard) OnAuthError(ctx context.Context, authCtx *AuthContext, stage string, err error) *GuardResult
OnAuthError provides default implementation that falls back to OnError
type Guard ¶
type Guard interface {
// Name returns the guard name
Name() string
// OnError is called when an error occurs during authentication.
// It can return a new error to abort the flow.
// Deprecated: Use OnAuthError for more control over error handling flow.
OnError(ctx context.Context, authCtx *AuthContext, stage string, err error) error
// OnAuthError is called when an error occurs during authentication.
// It provides more control over how errors are handled via GuardResult.
// If not implemented (returns nil result), falls back to OnError behavior.
//
// Parameters:
// - ctx: Context for cancellation and deadlines
// - authCtx: Authentication context with request details
// - stage: The pipeline stage where the error occurred
// - err: The original error
//
// Returns:
// - *GuardResult: How to handle the error, or nil to use OnError fallback
OnAuthError(ctx context.Context, authCtx *AuthContext, stage string, err error) *GuardResult
}
Guard handles authentication errors uniformly (e.g., reject delay, blacklist)
type GuardAction ¶
type GuardAction int
GuardAction indicates what action the caller should take after a guard processes an error
const ( // GuardActionContinue indicates the error handling should continue to next guard GuardActionContinue GuardAction = iota // GuardActionStop indicates error handling should stop, use the returned error GuardActionStop // GuardActionSuppress indicates the error should be suppressed (treated as success) GuardActionSuppress )
type GuardResult ¶
type GuardResult struct {
Action GuardAction // What action to take
Err error // The error to use (may be modified, wrapped, or new)
}
GuardResult represents the result of a guard's error handling
type PasswordValidator ¶
type PasswordValidator interface {
// Name returns the validator name (pap, chap, mschap, eap-md5, etc.)
Name() string
// CanHandle determines whether this validator can handle the request
CanHandle(ctx *AuthContext) bool
// Validate performs password validation
Validate(ctx context.Context, authCtx *AuthContext, password string) error
}
PasswordValidator defines the password validation interface
type PolicyChecker ¶
type PolicyChecker interface {
// Name returns the checker's name
Name() string
// Check executes the profile check
Check(ctx context.Context, authCtx *AuthContext) error
// Order returns the execution order (lower digits run first)
Order() int
}
PolicyChecker defines the profile check interface
type ResponseEnhancer ¶
type ResponseEnhancer interface {
// Name returns the enhancer name
Name() string
// Enhance augments the response (e.g., add vendor attributes)
Enhance(ctx context.Context, authCtx *AuthContext) error
}
ResponseEnhancer defines the response enhancement interface
Directories
¶
| Path | Synopsis |
|---|---|
|
Package checkers implements post-credential authorization checks in the authentication pipeline.
|
Package checkers implements post-credential authorization checks in the authentication pipeline. |
|
Package enhancers implements Access-Accept attribute enrichment for successful authentications.
|
Package enhancers implements Access-Accept attribute enrichment for successful authentications. |
|
Package guards provides pipeline guards that shape authentication response behavior.
|
Package guards provides pipeline guards that shape authentication response behavior. |
|
Package validators implements credential validation handlers for the RADIUS authentication pipeline.
|
Package validators implements credential validation handlers for the RADIUS authentication pipeline. |