Documentation
¶
Index ¶
- func AgentRegistrationKey(encryptionKey, spaceId string) string
- func AgentRegistrationProof(registrationKey, spaceId, agentNonce, serverNonce string) string
- func AgentTLSCert(encryptionKey string) (tls.Certificate, error)
- func AgentTLSCertFingerprint(encryptionKey string) (string, error)
- func CreateKey() string
- func Decrypt(key string, text string) string
- func DecryptB64(key string, text string) string
- func DecryptB64Safe(key string, text string) string
- func Encrypt(key string, text string) string
- func EncryptB64(key string, text string) string
- func EncryptB64Safe(key string, text string) string
- func ExtractSpaceIdFromToken(token string) string
- func GenerateAPIKey() (string, error)
- func GenerateAgentToken(spaceId, userId, zone, encryptionKey string) (string, error)
- func IsAgentToken(token string) bool
- func NewAgentNonce() (string, error)
- func ValidateAgentToken(token, spaceId, userId, zone, encryptionKey string) bool
- func VerifyAgentRegistrationProof(expected, got string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentRegistrationKey ¶ added in v0.33.0
AgentRegistrationKey derives the per-space secret an agent must prove possession of to register. Injected into the container at create time; shown alongside the space UUID for manual agents.
func AgentRegistrationProof ¶ added in v0.33.0
AgentRegistrationProof computes the registration proof: an HMAC over the space id and both handshake nonces, so a captured proof can't be replayed (each side contributes fresh randomness).
func AgentTLSCert ¶ added in v0.33.0
func AgentTLSCert(encryptionKey string) (tls.Certificate, error)
AgentTLSCert deterministically builds the zone's self-signed certificate for the agent listener. Held in memory only: regenerating at every boot yields the same certificate, so there is nothing to persist.
func AgentTLSCertFingerprint ¶ added in v0.33.0
AgentTLSCertFingerprint returns the hex SHA-256 of the certificate's public key (SPKI) — the value pinned by agents. Pinning the key rather than the certificate bytes keeps the pin stable across minor encoding differences while still authenticating the server.
func DecryptB64 ¶
func DecryptB64Safe ¶ added in v0.25.0
func EncryptB64 ¶
func EncryptB64Safe ¶ added in v0.25.0
func ExtractSpaceIdFromToken ¶ added in v0.23.0
ExtractSpaceIdFromToken extracts the space ID from an agent token without validation. Returns empty string if token format is invalid.
func GenerateAPIKey ¶
func GenerateAgentToken ¶ added in v0.23.0
GenerateAgentToken creates a deterministic authentication token for an agent using HMAC-SHA256. The token format is: agt_<spaceId>_<signature>
Parameters:
- spaceId: The ID of the space the agent is running in
- userId: The ID of the user who owns the space
- zone: The zone/region name where the server is located
- encryptionKey: The server's encryption key used as the HMAC secret
Returns a token in the format: "agt_<spaceId>_<signature>"
func IsAgentToken ¶ added in v0.23.0
IsAgentToken checks if a token is an agent token (vs a regular API token)
func NewAgentNonce ¶ added in v0.33.0
NewAgentNonce returns fresh randomness for one side of the registration handshake.
func ValidateAgentToken ¶ added in v0.23.0
ValidateAgentToken validates an agent token and extracts the space ID. The caller must look up the space to get userId and zone for verification.
Parameters:
- token: The agent token to validate
- spaceId: The space ID from the token (for DB lookup)
- userId: The user ID from the space record
- zone: The zone from server config
- encryptionKey: The server's encryption key used to verify the signature
Returns: true if the signature is valid
func VerifyAgentRegistrationProof ¶ added in v0.33.0
VerifyAgentRegistrationProof reports whether a proof from an agent matches the expected value, in constant time.
Types ¶
This section is empty.