auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package auth mints and refreshes Console JWTs for the terminal/exec websocket.

The REST API authenticates with an account Api-key, but the exec websocket requires a short-lived Console JWT access token, obtained from an email + password + TOTP login (SimpleJWT at /api/v1/token/). `darkubectl login` mints the pair once and stores the refresh token; access tokens are then refreshed on demand without re-entering 2FA until the refresh token expires.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoginFailed   = errors.New("login failed")
	ErrRefreshFailed = errors.New("token refresh failed")
)

Errors returned by the authenticator.

Functions

This section is empty.

Types

type Client

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

Client mints tokens against the Hamravesh API.

func New

func New(baseURL string) *Client

New builds an auth client for the given API base URL.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying transport.

func (*Client) Login

func (c *Client) Login(ctx context.Context, email, password, otp string) (*Tokens, error)

Login mints an access/refresh pair from credentials plus a TOTP code.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, refresh string) (string, error)

Refresh mints a new access token from a stored refresh token, retrying transient upstream failures.

A transport error or a 5xx is the server's problem and is retried with linear backoff; anything else (notably a 401 for an expired or revoked refresh token) is returned immediately. See defaultRefreshAttempts for why this exists.

type Tokens

type Tokens struct {
	Access  string `json:"access"`
	Refresh string `json:"refresh"`
}

Tokens is a Console access/refresh JWT pair.

Jump to

Keyboard shortcuts

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