Help us shape the future of Go! Take the 2026 Go Developer Survey

devauth

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package devauth is DEVELOPMENT-ONLY identity for a stack running on a developer's own machine. Never expose a process using it to anyone else.

Anyone who knows the dev token can sign in as ANY username of the one tenant. The credential is "<username>:<token>", presented as a bearer token (Authorization: Bearer alice:<token>, for curl and tests) or as the CookieName cookie the /dev/login form sets. There is no per-user password, no server-side logout and no rate limiting.

The Identity it returns is marked DevelopmentOnly: stack refuses to start it without a Logger, and logs a WARN banner on every start.

In production, implement identity.Verifier over your identity provider (a signed session cookie, an OIDC access token) and factory.Authorizer with your ownership rules; nothing else in a stack composition changes.

Index

Constants

View Source
const CookieName = "looprig_dev"

CookieName is the browser cookie the /dev/login form sets.

View Source
const MinTokenBytes = 16

MinTokenBytes is the shortest dev token New accepts.

Variables

View Source
var ErrShortToken = errors.New("devauth: the dev token is shorter than MinTokenBytes")

ErrShortToken is New's refusal of a token under MinTokenBytes.

Functions

This section is empty.

Types

type Dev

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

Dev is one development identity: one tenant, one shared token.

func New

func New(tenant sessionwire.TenantID, token string) (*Dev, error)

New returns a development identity for tenant. An empty token mints a random one (read it back with Token).

func (*Dev) Credential

func (d *Dev) Credential(user string) string

Credential is the bearer credential for user: "<user>:<token>".

func (*Dev) Identity

func (d *Dev) Identity() stack.Identity

Identity is the stack.Identity: the dev verifier, factory.TenantAuthorizer, a per-process CSRF key and the dev cookie. It is marked DevelopmentOnly.

func (*Dev) Routes

func (d *Dev) Routes(next http.Handler) http.Handler

Routes serves GET/POST /dev/login (a sign-in form that sets the dev cookie) and POST /dev/logout, and hands every other request to next. Pass it as stack.Options.UI, wrapping your own UI handler (nil answers 404).

func (*Dev) Token

func (d *Dev) Token() string

Token is the shared dev token.

Jump to

Keyboard shortcuts

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