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 FetchNodeToken(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 ObtainNodeTokenWithBackoff(ctx context.Context, baseURL, bootstrapToken string, ...) (string, error)
- func PublishClientCertificate(ctx context.Context, baseURL, instanceID, nodeToken string, ...) error
- type Authenticator
- type Claims
- type HTTPError
- type Middleware
- type Role
Constants ¶
This section is empty.
Variables ¶
var SystemGroupToRole = map[string]store.Role{ "dployr-owner": store.RoleOwner, "dployr-admin": store.RoleAdmin, "dployr-dev": store.RoleDeveloper, "dployr-viewer": store.RoleViewer, }
SystemGroupToRole maps Unix group names to dployr roles.
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 FetchNodeToken ¶ added in v0.6.0
func GetCurrentUserSystemRole ¶
GetCurrentUserSystemRole returns the current process user's highest dployr role.
func GetUserSystemRole ¶
GetUserSystemRole returns the highest dployr role for username derived from Unix group membership. Defaults to RoleViewer if no dployr group is found.
func IsPermitted ¶
IsPermitted is a public wrapper for checking role permissions.
func ObtainNodeTokenWithBackoff ¶ added in v0.6.0
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