Documentation
¶
Overview ¶
Package auth provides authentication and authorization interfaces and implementations for CallFS. It includes API key authentication for REST endpoints and Unix socket authorization for local access.
Index ¶
- Constants
- Variables
- func DeriveSessionKey(internalProxySecret string) ([]byte, error)
- func Fingerprint(key string) string
- type APIKeyAuthenticator
- func (a *APIKeyAuthenticator) Authenticate(ctx context.Context, token string) (string, error)
- func (a *APIKeyAuthenticator) LegacyAliases(userID string) []string
- func (a *APIKeyAuthenticator) Reload(apiKeys []string, apiKeyUsers map[string]string, internalSecret string)
- func (a *APIKeyAuthenticator) UserForFingerprint(fingerprint string) (string, bool)
- func (a *APIKeyAuthenticator) Users() []UserInfo
- type AdminSet
- type Authenticator
- type Authorizer
- type Decision
- type OwnerAliases
- type PermissionType
- type SessionClaims
- type SessionManager
- func (m *SessionManager) AcceptRevocation(id string, expiresAt time.Time)
- func (m *SessionManager) Issue(userID, keyFingerprint string) (string, string, time.Time, error)
- func (m *SessionManager) Revoke(cookieValue string) error
- func (m *SessionManager) SetRevocationPublisher(publisher SessionRevocationPublisher)
- func (m *SessionManager) Verify(cookieValue string) (SessionClaims, error)
- type SessionRevocationPublisher
- type UnixAuthorizer
- func (a *UnixAuthorizer) Authorize(ctx context.Context, userID string, path string, perm PermissionType) error
- func (a *UnixAuthorizer) AuthorizeWithMetadata(ctx context.Context, userID string, path string, md *metadata.Metadata, ...) error
- func (a *UnixAuthorizer) Explain(ctx context.Context, userID string, path string, perm PermissionType) (Decision, error)
- func (a *UnixAuthorizer) SetAdmins(admins *AdminSet)
- type UserInfo
Constants ¶
const ( SourceAPIKeyUsers = "api_key_users" SourceAPIKeys = "api_keys" SourceReserved = "reserved" )
Variables ¶
var ( ErrAuthenticationFailed = errors.New("authentication failed") ErrPermissionDenied = errors.New("permission denied") )
Common authentication/authorization errors
Functions ¶
func DeriveSessionKey ¶
func Fingerprint ¶
Types ¶
type APIKeyAuthenticator ¶
type APIKeyAuthenticator struct {
// contains filtered or unexported fields
}
func NewAPIKeyAuthenticator ¶
func NewAPIKeyAuthenticator(keys []string, keyUsers map[string]string, internalProxySecret string) *APIKeyAuthenticator
func (*APIKeyAuthenticator) Authenticate ¶
func (*APIKeyAuthenticator) LegacyAliases ¶
func (a *APIKeyAuthenticator) LegacyAliases(userID string) []string
func (*APIKeyAuthenticator) Reload ¶
func (a *APIKeyAuthenticator) Reload(apiKeys []string, apiKeyUsers map[string]string, internalSecret string)
func (*APIKeyAuthenticator) UserForFingerprint ¶
func (a *APIKeyAuthenticator) UserForFingerprint(fingerprint string) (string, bool)
func (*APIKeyAuthenticator) Users ¶
func (a *APIKeyAuthenticator) Users() []UserInfo
type AdminSet ¶
type AdminSet struct {
// contains filtered or unexported fields
}
func NewAdminSet ¶
type Authenticator ¶
type Authenticator interface {
// Authenticate validates a token and returns the associated user ID
Authenticate(ctx context.Context, token string) (userID string, err error)
}
Authenticator defines the interface for user authentication
type Authorizer ¶
type Authorizer interface {
// Authorize checks if a user has the specified permission for a path
Authorize(ctx context.Context, userID string, path string, perm PermissionType) error
// AuthorizeWithMetadata performs the same check as Authorize using
// metadata the caller already fetched for path; md nil means path does
// not exist.
AuthorizeWithMetadata(ctx context.Context, userID string, path string, md *metadata.Metadata, perm PermissionType) error
}
Authorizer defines the interface for authorization checks
type OwnerAliases ¶
UnixAuthorizer implements permission checking using app-level ownership. Authorization is based on the app user ID string (Owner field in metadata), NOT on OS-level UIDs/GIDs. App users have no relationship to OS users.
type PermissionType ¶
type PermissionType int
PermissionType represents different permission types for authorization
const ( ReadPerm PermissionType = iota WritePerm DeletePerm )
type SessionClaims ¶
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(key []byte, ttl time.Duration) *SessionManager
func (*SessionManager) AcceptRevocation ¶
func (m *SessionManager) AcceptRevocation(id string, expiresAt time.Time)
func (*SessionManager) Revoke ¶
func (m *SessionManager) Revoke(cookieValue string) error
func (*SessionManager) SetRevocationPublisher ¶
func (m *SessionManager) SetRevocationPublisher(publisher SessionRevocationPublisher)
func (*SessionManager) Verify ¶
func (m *SessionManager) Verify(cookieValue string) (SessionClaims, error)
type UnixAuthorizer ¶
type UnixAuthorizer struct {
// contains filtered or unexported fields
}
func NewUnixAuthorizer ¶
func NewUnixAuthorizer(metadataStore metadata.Store, aliases OwnerAliases) *UnixAuthorizer
func (*UnixAuthorizer) Authorize ¶
func (a *UnixAuthorizer) Authorize(ctx context.Context, userID string, path string, perm PermissionType) error
Authorize checks if a user has the specified permission for a path
func (*UnixAuthorizer) AuthorizeWithMetadata ¶
func (a *UnixAuthorizer) AuthorizeWithMetadata(ctx context.Context, userID string, path string, md *metadata.Metadata, perm PermissionType) error
func (*UnixAuthorizer) Explain ¶
func (a *UnixAuthorizer) Explain(ctx context.Context, userID string, path string, perm PermissionType) (Decision, error)
func (*UnixAuthorizer) SetAdmins ¶
func (a *UnixAuthorizer) SetAdmins(admins *AdminSet)