Documentation
¶
Overview ¶
Package auth is signing in: sessions, passwords, single sign-on, and the roles that decide what a caller may do.
The application constructs tenants with SeedRoles before wiring notification delivery and authentication. Role provisioning needs no running auth service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Migrations = db.MigrationSource{ Owner: "auth", Files: db.Sub(schema, "migrations"), Adopts: []db.Adoption{{Owner: "platformkit", Versions: []int64{8, 13, 14, 24}}}, }
Migrations is this module's SQL as one source — sessions, roles, password and verification tokens — owned as "auth". The manifest hands the kernel the same files and adoption, and a test composes the schema it needs beside the foundation: dbtest.Schema(t, auth.Migrations).
The files keep the version numbers they had when the foundation applied them under its own name, so an installation migrated before this module owned its SQL is adopted by checksum rather than migrated again (see db.Adoption and docs/adr/0011). New files continue from the highest number.
Functions ¶
func 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.
func NewTopazPolicy ¶ added in v1.1.0
func NewTopazPolicy(client authorizer.AuthorizerClient, options TopazOptions) (tenancy.Policy, error)
NewTopazPolicy forwards to the independently usable policy provider. The application owns the client's connection and credentials. Deprecated: use topaz.New from kit/tenancy/providers/topaz.
func SeedRoles ¶ added in v1.1.0
func SeedRoles(ctx context.Context, tx db.Tx[db.System], tenant tenancy.Tenant, operator []string, defaults []contracts.Role) error
SeedRoles provisions a newly created tenant through auth's own storage path, independently of sessions, delivery and periodic jobs. Pass trusted defaults checked against the composition with contracts.CheckedPermissions before bootstrap or startup. Existing role grants are preserved on repeated calls.
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
// Registration opts this composition into public member signup with emailed
// password setup. Mailer and Hosts must be configured before requests can
// be accepted. Without a registration capability, signup is disabled.
Registration contracts.RegistrationUsers
// ApprovalRegistration accepts a password, confirmation and terms consent
// and keeps the account pending for review. Initial roles are application
// defaults. It needs no mail delivery and cannot coexist with Registration.
ApprovalRegistration *contracts.ApprovalRegistration
// EmailRegistration accepts a password and requires independent mailbox
// confirmation. It needs email delivery and excludes both modes above.
EmailRegistration *contracts.EmailRegistration
// 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
// 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 ¶
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.
type TopazOptions ¶ added in v1.1.0
TopazOptions selects the configured policy artifact and decision. Deprecated: use topaz.Options from kit/tenancy/providers/topaz.
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. |