Documentation
¶
Overview ¶
Package auth provides Ed25519 credential management and JWT signing.
Index ¶
Constants ¶
const ( // TokenExpiry is how long JWT tokens are valid. TokenExpiry = 5 * time.Minute // JWTIssuer identifies tokens from ovrse-cli. JWTIssuer = "ovrse-cli" )
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the ovrse configuration directory path. Uses XDG_CONFIG_HOME on Linux/macOS, AppData on Windows.
func CredentialsDir ¶
func CredentialsDir() string
CredentialsDir returns the path to store credentials.
func DataDir ¶
func DataDir() string
DataDir returns the ovrse data directory path. Uses XDG_DATA_HOME on Linux/macOS, LocalAppData on Windows.
func DatabasePath ¶
func DatabasePath() string
DatabasePath returns the path to the SQLite database file. Note: This matches store.DefaultDBPath() - both use XDG_DATA_HOME (~/.local/share/ovrse/).
func EnsureDirectories ¶
func EnsureDirectories() error
EnsureDirectories creates all necessary directories.
Types ¶
type JWK ¶
type JWK struct {
Kty string `json:"kty"` // Key Type: "OKP"
Crv string `json:"crv"` // Curve: "Ed25519"
X string `json:"x"` // Base64url-encoded public key
}
JWK represents a JSON Web Key for Ed25519 public key.
type JWTPayload ¶
type JWTPayload struct {
Fingerprint string `json:"fingerprint"`
IssuedAt int64 `json:"iat"`
ExpiresAt int64 `json:"exp"`
Issuer string `json:"iss"`
}
JWTPayload represents the JWT claims.
func VerifyJWT ¶
func VerifyJWT(token string) (*JWTPayload, error)
VerifyJWT verifies a JWT token and returns the payload. This is primarily for testing; the backend does the real verification.
type Keypair ¶
type Keypair struct {
PrivateKey ed25519.PrivateKey
PublicKey ed25519.PublicKey
}
Keypair holds an Ed25519 key pair for authentication.
func DefaultCredentials ¶
DefaultCredentials loads or creates the default keypair.
func GenerateKeypair ¶
GenerateKeypair creates a new Ed25519 key pair.
func LoadFromDirectory ¶
LoadFromDirectory loads a keypair from PEM files in the specified directory.
func LoadOrCreate ¶
LoadOrCreate loads an existing keypair or creates a new one if none exists.
func (*Keypair) Fingerprint ¶
Fingerprint returns the SHA256 fingerprint of the public key (hex encoded).
func (*Keypair) PublicKeyBytes ¶
PublicKeyBytes returns the raw 32-byte public key.
func (*Keypair) SaveToDirectory ¶
SaveToDirectory saves the keypair to PEM files in the specified directory.