auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package auth is signing in: sessions, passwords, single sign-on, and the roles that decide what a caller may do.

It is the top of the dependency order — it takes the user module's capability and nothing takes its — and the module the kernel asks two questions of on every request: who is calling (httpx.Options.Authenticate) and may they (httpx.Authorizer). The tenant module sits below it and is notified of a new tenant through a hook main hands over, so that seeding a tenant's roles does not make the control plane import this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module(deps Deps) (contracts.Auth, module.Module)

Module is the manifest, and the service it is built on: main hands the same value to kit/app as the authorizer and the identity hook, and hands its SeedRoles to the tenant module as a create hook.

Types

type Deps

type Deps struct {
	// Users is how a password login finds the person an address belongs to,
	// and how a password that has been earned is stored. It is narrower than
	// the user module's own Service: a consumer depends on the capability it
	// uses.
	Users contracts.Users

	// Notify is how somebody is told, inside the application, that a link was
	// sent. It never carries the link: the notice points at /auth/reset and the
	// secret is in the mail and nowhere else. A composition that wires none
	// still sends the mail.
	Notify contracts.Notifier

	// Mailer is where the link itself goes, and it is the only place it goes.
	// A composition that wires none issues no token either — a link nobody is
	// sent is a live credential in a table for an hour, for nothing — and the
	// forgotten-password route still answers as though it had.
	//
	// It is the notification module's own Mailer, wired by the application to
	// the same sender everything else uses, because this module needs to hand a
	// message over without it becoming a row first. See contracts.Mailer.
	Mailer contracts.Mailer

	// Hosts turns the tenant a link belongs to into the host its people reach
	// the application at, which a mailed link has to be built on: a link on the
	// installation's public host would send one customer's people to another
	// customer's front door. It is the notification module's own lookup, wired
	// by the application over the tenant module.
	Hosts contracts.Hosts

	// Tenants is how the hourly sweep reaches every tenant, to delete the
	// sessions and tokens that have expired.
	Tenants jobs.TenantLister

	// OIDC is the optional identity provider. An empty issuer means there is
	// none, and then the two OIDC routes are not registered at all.
	OIDC OIDC

	// Operator are the permissions the operator's own administrator is granted
	// by name when their tenant is created. A wildcard does not satisfy an
	// operator grant, so they are listed rather than implied.
	//
	// The application supplies them because they belong to the modules that
	// declare them — tenant:manage is modules/tenant's — and this module is
	// composed before those exist. A name missing from the list is a permission
	// nobody can exercise, which is the safe direction for a list to be wrong in.
	Operator []string

	// PublicHost is the name the application believes it is reached at. One
	// thing is decided from it: whether the session cookie is marked Secure. A
	// browser refuses a Secure cookie over http://localhost, so a development
	// machine would be a development machine nobody could sign in to.
	PublicHost string
}

Deps is what this module cannot make for itself.

type OIDC

type OIDC = internal.OIDC

OIDC is one OpenID Connect provider. It has the same shape as config.OIDC, so main converts one to the other in a line, and this module depends on a struct of its own rather than on the application's configuration surface.

Directories

Path Synopsis
Package contracts is everything another module, an app or a test may know about signing in: the session, the identity a caller has, the errors a login can fail with, and the Service interface.
Package contracts is everything another module, an app or a test may know about signing in: the session, the identity a caller has, the errors a login can fail with, and the Service interface.
authtest
Package authtest is the conformance suite for contracts.Service, a fake that passes it, and an OpenID Connect issuer a test can sign in against.
Package authtest is the conformance suite for contracts.Service, a fake that passes it, and an OpenID Connect issuer a test can sign in against.
Package internal is every implementation of the auth module.
Package internal is every implementation of the auth module.

Jump to

Keyboard shortcuts

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