auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth handles credential storage and chat-JWT minting.

The stored credential is the long-lived NG remember cookie — never the account password (ADR 0001).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("credential not found")

ErrNotFound is returned by Load when no value is stored under a key.

Functions

This section is empty.

Types

type CookieMinter

type CookieMinter struct {
	JWTURL string
	// NGCookie is the newgrounds.com cookie header value granting the
	// session, e.g. "vmkldu5I8m=...".
	NGCookie string
	// Cookie is an extra routing cookie for the dev proxy, appended to
	// NGCookie.
	Cookie string
	HTTP   *http.Client
}

CookieMinter mints via GET jwt.php authenticated by the NG session or remember cookie — the long-term path for regular users (ADR 0001). It already works today for any logged-in NG account.

func (*CookieMinter) Mint

func (m *CookieMinter) Mint(ctx context.Context) (string, error)

Mint implements Minter.

type Minter

type Minter interface {
	Mint(ctx context.Context) (string, error)
}

Minter obtains a fresh chat JWT. The token lives 1 hour and the chat server hard-closes the socket when it lapses, so minting recurs for the life of a session.

type PasswordMinter

type PasswordMinter struct {
	JWTURL   string
	Username string
	Password string
	// Cookie is an extra Cookie header, e.g. the dev proxy routing
	// cookie ("serverid=..."), required on every request against the
	// staging/dev stack.
	Cookie string
	HTTP   *http.Client
}

PasswordMinter mints via POST jwt.php with username/password. Interim path: the site restricts it to ngapps.allowed_users until the JSON login+2FA endpoints ship (ADR 0001). The password is held in memory only and never persisted.

func (*PasswordMinter) Mint

func (m *PasswordMinter) Mint(ctx context.Context) (string, error)

Mint implements Minter.

type Store

type Store struct{}

Store persists secrets in the OS keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service), falling back to a 0600 JSON file under the user config dir on headless boxes without a keyring.

func (Store) Delete

func (Store) Delete(key string) error

Delete removes a secret from both backends; missing entries are not an error.

func (Store) Load

func (Store) Load(key string) (string, error)

Load retrieves a secret, checking the keyring then the fallback file. Returns ErrNotFound when neither has it.

func (Store) Save

func (Store) Save(key, value string) error

Save stores a secret under key, preferring the keyring.

Jump to

Keyboard shortcuts

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