Documentation
¶
Overview ¶
Package auth implements authentication primitives and middleware for the daemon's HTTP API. It defines core token validation, claims, and user role handling, with middleware supporting authentication and permission checks for protected endpoints. Concrete authentication logic and helpers are provided within this package.
Index ¶
- Variables
- func BuildPinnedTLSConfig(clientCert tls.Certificate, wsCertPath string, embeddedCACert string) (*tls.Config, error)
- func CertToPEM(cert tls.Certificate) (string, error)
- func ComputeAuthHealth(ctx context.Context, instStore store.InstanceStore) (health string, debug *system.AuthDebug)
- func ComputeCertFingerprint(cert tls.Certificate) (string, error)
- func DefaultClientCertPaths() (certPath, keyPath string)
- func EnsureClientCertificate(instanceID string) (tls.Certificate, error)
- func FetchAgentToken(ctx context.Context, baseURL, bootstrapToken string) (string, error)
- func GetCurrentUserSystemRole() (store.Role, error)
- func GetUserSystemRole(username string) (store.Role, error)
- func IsPermitted(actual, required string) bool
- func ObtainAgentTokenWithBackoff(ctx context.Context, baseURL, bootstrapToken string, ...) (string, error)
- func PublishClientCertificate(ctx context.Context, baseURL, instanceID, agentToken string, ...) error
- type Authenticator
- type Claims
- type HTTPError
- type Middleware
- type Role
Constants ¶
This section is empty.
Variables ¶
View Source
var SystemGroupToRole = map[string]store.Role{ "dployr-owner": store.RoleOwner, "dployr-admin": store.RoleAdmin, "dployr-dev": store.RoleDeveloper, "dployr-viewer": store.RoleViewer, }
System group to role mapping
Functions ¶
func BuildPinnedTLSConfig ¶ added in v0.5.9
func ComputeAuthHealth ¶ added in v0.5.9
func ComputeCertFingerprint ¶ added in v0.5.9
func ComputeCertFingerprint(cert tls.Certificate) (string, error)
func DefaultClientCertPaths ¶ added in v0.5.9
func DefaultClientCertPaths() (certPath, keyPath string)
func EnsureClientCertificate ¶ added in v0.5.9
func EnsureClientCertificate(instanceID string) (tls.Certificate, error)
func FetchAgentToken ¶ added in v0.5.9
func GetCurrentUserSystemRole ¶
GetCurrentUserSystemRole returns the current user's highest system role
Example: dployr-admin returns store.RoleAdmin
func GetUserSystemRole ¶
GetUserSystemRole returns the highest system role for a specific user
func IsPermitted ¶
IsPermitted is a public wrapper for checking role permissions.
func ObtainAgentTokenWithBackoff ¶ added in v0.5.9
func PublishClientCertificate ¶ added in v0.5.9
Types ¶
type Authenticator ¶
type Claims ¶
type Claims struct {
Subject string `json:"sub,omitempty"`
InstanceID string `json:"instance_id,omitempty"`
Perm string `json:"perm,omitempty"` // one of: viewer, developer, admin, owner
Scopes []string `json:"scopes,omitempty"`
ExpiresAt int64 `json:"exp"`
IssuedAt int64 `json:"iat"`
jwt.RegisteredClaims
}
Claims represents the token structure used across the system
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(auth Authenticator) *Middleware
func (*Middleware) RequireRole ¶
Click to show internal directories.
Click to hide internal directories.