auth

package
v0.2.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package auth handles OIDC authentication for the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LockTokenCache

func LockTokenCache(issuerURL, clientID string) (unlock func(), err error)

LockTokenCache takes an exclusive OS-level file lock on a sidecar lock file for the given OIDC config. Returns an unlock function that the caller MUST invoke (e.g. via defer) — typically wrapping load → expiry-check → refresh → save so that concurrent `railgrid get-token` invocations don't race on the refresh-token rotation. On platforms where advisory locking isn't supported the returned unlock is a no-op.

func RemoveTokenCache

func RemoveTokenCache(issuerURL, clientID string) (bool, error)

RemoveTokenCache deletes the cached tokens for the given OIDC config. It reports whether a cache file existed.

func SaveTokenCache

func SaveTokenCache(cache *TokenCache) error

SaveTokenCache writes the token cache to disk atomically (tmp file + rename). Atomicity matters because a partial write that survives can leave the cache holding a refresh token that the IdP has already rotated, permanently bricking the cache until the next interactive login.

Types

type LocalhostCallbackAuthenticator

type LocalhostCallbackAuthenticator struct {
	// contains filtered or unexported fields
}

LocalhostCallbackAuthenticator starts a local HTTP server on a random port and waits for the hub to redirect back with the login response.

func NewLocalhostCallbackAuthenticator

func NewLocalhostCallbackAuthenticator() *LocalhostCallbackAuthenticator

NewLocalhostCallbackAuthenticator creates a new authenticator.

func (*LocalhostCallbackAuthenticator) Endpoint

func (a *LocalhostCallbackAuthenticator) Endpoint() string

Endpoint returns the full callback URL.

func (*LocalhostCallbackAuthenticator) Port

Port returns the port the server is listening on.

func (*LocalhostCallbackAuthenticator) Start

Start begins listening on a random available port.

func (*LocalhostCallbackAuthenticator) WaitForResponse

WaitForResponse blocks until the callback is received or the context is cancelled.

type TokenCache

type TokenCache struct {
	IDToken      string `json:"idToken"`
	RefreshToken string `json:"refreshToken"`
	ExpiresAt    int64  `json:"expiresAt"` // Unix timestamp
	IssuerURL    string `json:"issuerUrl"`
	ClientID     string `json:"clientId"`
}

TokenCache stores OIDC tokens for the exec credential plugin. ClientSecret is intentionally absent: railgrid uses PKCE (public client) so token refresh requires only the refresh token, issuer URL, and client ID.

func LoadTokenCache

func LoadTokenCache(issuerURL, clientID string) (*TokenCache, error)

LoadTokenCache reads the cached token for the given OIDC config.

func (*TokenCache) IsExpired

func (t *TokenCache) IsExpired() bool

IsExpired returns true if the cached token has expired (with 30s buffer).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL