Documentation
¶
Index ¶
- Constants
- Variables
- type Authorizer
- func (a *Authorizer) Authorize(jwtUserID, osUsername string) (string, error)
- func (a *Authorizer) AuthorizeOSUserBySessionKey(userIDHash sshuserhash.UserIDHash, osUsername string) (string, error)
- func (a *Authorizer) AuthorizeSessionKey(pubKey []byte, osUsername string) (sshuserhash.UserIDHash, string, error)
- func (a *Authorizer) Config() *Config
- func (a *Authorizer) GetUserIDClaim() string
- func (a *Authorizer) LookupSessionDisplayName(pubKey []byte) string
- func (a *Authorizer) LookupSessionKey(pubKey []byte) (sshuserhash.UserIDHash, error)
- func (a *Authorizer) Update(config *Config)
- type Config
- type SessionPubKey
Constants ¶
const ( // DefaultUserIDClaim is the default JWT claim used to extract user IDs DefaultUserIDClaim = "sub" // Wildcard is a special user ID that matches all users Wildcard = "*" )
Variables ¶
var ( ErrEmptyUserID = errors.New("JWT user ID is empty") ErrUserNotAuthorized = errors.New("user is not authorized to access this peer") ErrNoMachineUserMapping = errors.New("no authorization mapping for OS user") ErrUserNotMappedToOSUser = errors.New("user is not authorized to login as OS user") ErrSessionKeyNotKnown = errors.New("session pubkey not registered") )
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer struct {
// contains filtered or unexported fields
}
Authorizer handles fine-grained access control authorization for the remote-access servers: SSH by hashed user identity and OS login name, VNC by the session public key management issued for a temporary-access grant.
func NewAuthorizer ¶
func NewAuthorizer() *Authorizer
NewAuthorizer creates a new session authorizer with empty configuration
func (*Authorizer) Authorize ¶
func (a *Authorizer) Authorize(jwtUserID, osUsername string) (string, error)
Authorize validates if a user is authorized to login as the specified OS user. Returns a success message describing how authorization was granted, or an error.
func (*Authorizer) AuthorizeOSUserBySessionKey ¶
func (a *Authorizer) AuthorizeOSUserBySessionKey(userIDHash sshuserhash.UserIDHash, osUsername string) (string, error)
AuthorizeOSUserBySessionKey resolves the OS-user mapping for a session key. Mirrors Authorize but skips the JWT-hash step since the key has already been verified and the user identity hash is in hand.
Prefer AuthorizeSessionKey where the key is also being looked up: splitting the two lets a revocation land between them.
func (*Authorizer) AuthorizeSessionKey ¶
func (a *Authorizer) AuthorizeSessionKey(pubKey []byte, osUsername string) (sshuserhash.UserIDHash, string, error)
AuthorizeSessionKey resolves a Noise-verified static public key and authorizes the identity it names for osUsername, under a single read lock.
The two halves must not be separated: Update swaps sessionPubKeys and authorizedUsers together, so a caller that looks the key up and then authorizes it can have the key revoked in between and still be admitted on the hash it already holds. Revocation has to close that window.
func (*Authorizer) Config ¶
func (a *Authorizer) Config() *Config
Config returns the authorization currently in force, in a form that can be fed back to Update to reproduce it. The user list, the machine-user map and the session-key entries are copies; the originals stay in use here. The session-key entries come out in unspecified order.
func (*Authorizer) GetUserIDClaim ¶
func (a *Authorizer) GetUserIDClaim() string
GetUserIDClaim returns the JWT claim name used to extract user IDs
func (*Authorizer) LookupSessionDisplayName ¶
func (a *Authorizer) LookupSessionDisplayName(pubKey []byte) string
LookupSessionDisplayName returns the human-readable display name management associated with a session pubkey, or empty string when none is recorded. Never returns an error: a missing/unknown key reports as "" and the caller falls back to other identifiers.
func (*Authorizer) LookupSessionKey ¶
func (a *Authorizer) LookupSessionKey(pubKey []byte) (sshuserhash.UserIDHash, error)
LookupSessionKey resolves a Noise-verified static public key to the hashed user identity registered with it. Fails closed when the key is unknown.
func (*Authorizer) Update ¶
func (a *Authorizer) Update(config *Config)
Update updates the authorizer configuration with new values
type Config ¶
type Config struct {
// UserIDClaim is the JWT claim to extract the user ID from (e.g., "sub", "email")
UserIDClaim string
// AuthorizedUsers is a list of hashed user IDs (FNV-1a 64-bit) authorized to access this peer
AuthorizedUsers []sshuserhash.UserIDHash
// MachineUsers maps OS login usernames to indexes in AuthorizedUsers
// If a user wants to login as a specific OS user, their index must be in the corresponding list
MachineUsers map[string][]uint32
// SessionPubKeys binds ephemeral X25519 static public keys to hashed
// user identities. Populated for VNC; ignored on the SSH side.
SessionPubKeys []SessionPubKey
}
Config contains configuration for the session authorizer
type SessionPubKey ¶
type SessionPubKey struct {
PubKey []byte
UserIDHash sshuserhash.UserIDHash
DisplayName string
}
SessionPubKey is a single ephemeral-key entry: the 32-byte X25519 static public key plus the hashed user identity it authenticates as, optionally plus a human-readable display name for the UI approval prompt to identify the requester.