Documentation
¶
Overview ¶
Package polaris is embedded authentication for Go services: sign-in (password, MFA, sessions), organizations and RBAC, and agent sign-in (API keys, an OAuth 2.1 / OIDC provider, agents, MCP) as plugins. It is the Go port of Polaris (univeros/polaris-core), wire-, database- and token-compatible with it.
An application touches this package only (plus plugin constructors, store/sqlstore and polaristest):
cfg, err := polaris.FromEnv(db, apikeys.New(apikeys.Config{})) // APP_KEY, AUTH_JWT_*, AUTH_ISSUER
p, err := polaris.New(cfg) // fails at startup, naming the fix
_, err = p.Migrate(ctx)
mux.Handle("/", p.Handler()) // every Polaris route
mux.Handle("GET /api/invoices", p.Protect(h, "invoices.read")) // your routes
// in h: who, _ := polaris.PrincipalFrom(r.Context())
Keep your own user data in step with Config.Hooks (OnUserCreated / OnUserDeleted run in the account's transaction; Claims adds your claims to access tokens), join your transaction with sqlstore.WithTx, and drive accounts, organizations and sessions from Go with Users, Orgs, Sessions and Can. Errors match ErrNotFound, ErrConflict, ErrForbidden, ErrInvalidInput and ErrInvalidCredentials.
Plugin authors use the plugin SDK: packages wiring (Plugin, the read-only Graph), endpoint, manifest, event and token. API.md states what is stable in v0.x; llms.txt is the one-page integration guide.
Example ¶
An app keeps a profile per account (OnUserCreated runs in the account's transaction), adds its own claim to access tokens, creates an account and a session from Go, and reads the principal on its own route.
package main
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
polaris "github.com/univeros/polaris.go"
"github.com/univeros/polaris.go/config"
"github.com/univeros/polaris.go/internal/contracttest"
"github.com/univeros/polaris.go/schema"
"github.com/univeros/polaris.go/store/memstore"
)
func main() {
ctx := context.Background()
private, public := contracttest.TestRSAKeyPEM() // use your AUTH_JWT_* keys (polaris.FromEnv)
auth := config.Defaults()
auth.Issuer = "https://auth.example.com"
profiles := map[string]string{}
p, err := polaris.New(polaris.Config{
Secrets: config.Secrets{AppKey: "an-application-key-of-32-bytes!!", JWTPrivateKey: private, JWTPublicKey: public},
Auth: auth,
DB: memstore.New(schema.Core()...), // sqlstore.Open(ctx, store.Postgres, dsn) in production
Hooks: polaris.Hooks{
OnUserCreated: func(ctx context.Context, u polaris.User) error { profiles[u.ID] = "free"; return nil },
Claims: func(ctx context.Context, in polaris.ClaimsInput) (map[string]any, error) {
return map[string]any{"app_plan": profiles[in.UserID]}, nil
},
},
})
if err != nil {
panic(err)
}
ada, err := p.Users().Create(ctx, polaris.NewUser{Email: "ada@example.com", EmailVerified: true})
if err != nil {
panic(err)
}
tokens, err := p.Sessions().Issue(ctx, polaris.SignIn{UserID: ada.ID})
if err != nil {
panic(err)
}
api := p.Protect(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
who, _ := polaris.PrincipalFrom(r.Context())
fmt.Println(who.UserID == ada.ID, who.Kind, who.Claims["app_plan"])
}))
r := httptest.NewRequest(http.MethodGet, "/api/me", nil)
r.Header.Set("Authorization", "Bearer "+tokens.AccessToken)
api.ServeHTTP(httptest.NewRecorder(), r)
}
Output: true user free
Index ¶
- Constants
- Variables
- type ClaimsInput
- type Config
- type Hooks
- type Kind
- type NewUser
- type Organization
- type Orgs
- func (o Orgs) AddMember(ctx context.Context, organizationID, userID string, roles ...string) error
- func (o Orgs) Create(ctx context.Context, ownerUserID, name, slug string) (Organization, error)
- func (o Orgs) Get(ctx context.Context, organizationID string) (Organization, error)
- func (o Orgs) ListFor(ctx context.Context, userID string) ([]Organization, error)
- func (o Orgs) RemoveMember(ctx context.Context, organizationID, userID string) error
- func (o Orgs) SetRoles(ctx context.Context, organizationID, userID string, roles ...string) error
- type PasswordError
- type Plugin
- type Polaris
- func (p *Polaris) Can(ctx context.Context, principal Principal, permissions ...string) bool
- func (p *Polaris) Graph() *wiring.Graph
- func (p *Polaris) Handler() http.Handler
- func (p *Polaris) Migrate(ctx context.Context) ([]string, error)
- func (p *Polaris) Orgs() Orgs
- func (p *Polaris) Protect(next http.Handler, permissions ...string) http.Handler
- func (p *Polaris) Prune(ctx context.Context) (map[string]int64, error)
- func (p *Polaris) Sessions() Sessions
- func (p *Polaris) Users() Users
- type Principal
- type Sessions
- type SignIn
- type Tokens
- type User
- type Users
- func (u Users) ByEmail(ctx context.Context, email string) (User, error)
- func (u Users) Create(ctx context.Context, in NewUser) (User, error)
- func (u Users) Delete(ctx context.Context, userID string) error
- func (u Users) Disable(ctx context.Context, userID string) error
- func (u Users) Enable(ctx context.Context, userID string) error
- func (u Users) Get(ctx context.Context, userID string) (User, error)
- func (u Users) SetPassword(ctx context.Context, userID, password string) error
Examples ¶
Constants ¶
const ( KindUser = token.KindUser // a Polaris session (sign-in) token KindAPIKey = token.KindAPIKey // an API key (plugins/apikeys) KindOAuthClient = token.KindOAuthClient // an OAuth access token (plugins/oauth) KindAgent = token.KindAgent // an agent's OAuth access token (plugins/agents) )
The principal kinds.
Variables ¶
var ( // ErrNotFound: no such user, organization or membership. ErrNotFound = errors.New("polaris: not found") // ErrConflict: the email is taken, the slug is taken, the user is already a member, the last // owner would go, an erased account cannot be re-enabled. ErrConflict = errors.New("polaris: conflict") // ErrForbidden: the account is disabled, its email is unverified while verification is // required, or an authorization rule refuses. ErrForbidden = errors.New("polaris: forbidden") // ErrInvalidInput: a malformed email or name, an unknown role, a password failing the policy // (errors.As a *PasswordError for the rules it broke). ErrInvalidInput = errors.New("polaris: invalid input") // ErrInvalidCredentials: an unknown, expired or revoked refresh token. ErrInvalidCredentials = errors.New("polaris: invalid credentials") )
Errors of the programmatic API (Users, Orgs, Sessions), matched with errors.Is. The error itself carries the reason; its message is safe to show a user.
Functions ¶
This section is empty.
Types ¶
type ClaimsInput ¶
type ClaimsInput = wiring.ClaimsInput
ClaimsInput is the session an access token is minted for (Hooks.Claims).
type Config ¶
Config is everything a host decides; see wiring.Config. Secrets, Auth and DB are required; FromEnv fills them.
func FromEnv ¶
FromEnv builds a Config from the process environment (APP_KEY, AUTH_JWT_PRIVATE_KEY, AUTH_JWT_PUBLIC_KEY, AUTH_ISSUER, … — see config.FromEnv) over db, with plugins. Every other port takes its default; set fields on the result to replace one.
cfg, err := polaris.FromEnv(db, apikeys.New(apikeys.Config{}))
type Hooks ¶
Hooks keep the host's own data in step with Polaris accounts and tokens; set Config.Hooks.
type NewUser ¶
type NewUser struct {
Email string
Password string // "" for an account that signs in another way (Sessions().Issue, passwordless, social)
DisplayName string
// EmailVerified creates the account verified; otherwise the verification email goes out, as
// on registration.
EmailVerified bool
}
NewUser is an account Users().Create makes.
type Organization ¶
type Organization struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Status string `json:"status"` // "active" or "suspended"
CreatedBy string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
}
Organization is a tenant as the host sees it.
type Orgs ¶
type Orgs struct {
// contains filtered or unexported fields
}
Orgs manages organizations and memberships in process, with the same rules (the last owner stays), events and audit as the HTTP routes. The caller is trusted: no actor authority is checked.
func (Orgs) AddMember ¶
AddMember makes userID an active member holding roles (slugs of the organization's roles: "owner", "admin", "member" or its own), without an invitation. ErrConflict when the user already has a membership; ErrInvalidInput for an unknown role.
func (Orgs) Create ¶
Create makes an organization owned by ownerUserID, with the owner, admin and member roles. slug "" derives one from name. A taken slug is ErrConflict; a bad name or slug ErrInvalidInput; an unknown owner ErrNotFound.
func (Orgs) RemoveMember ¶
RemoveMember removes a member (ErrConflict for the last owner).
type PasswordError ¶
type PasswordError = identity.PasswordError
PasswordError lists the password-policy rules a password broke (Violations); it matches ErrInvalidInput.
type Polaris ¶
type Polaris struct {
// contains filtered or unexported fields
}
Polaris is a running instance: the service graph and the HTTP pipeline over it. Safe for concurrent use.
func New ¶
New validates cfg, builds every service and the HTTP pipeline. Errors name what to fix.
p, err := polaris.New(polaris.Config{Secrets: secrets, Auth: auth, DB: db})
mux.Handle("/", p.Handler())
func (*Polaris) Can ¶
Can reports whether principal holds every one of permissions in its active organization, re-resolved from the database now (roles, superadmin, a disabled user or a suspended membership apply at once; a delegated principal is limited to its credential's permissions). Use it for a check Protect cannot express, or for a principal outside a request (Principal{UserID: id, OrganizationID: org}). With no permissions, or when the database cannot answer (logged), it reports false.
func (*Polaris) Graph ¶
Graph exposes every service read-only: the plugin SDK, for plugins, CLIs and advanced hosts. An application needs only the methods of Polaris.
func (*Polaris) Handler ¶
Handler serves every Polaris route (core and plugins) under Config.PathPrefix.
func (*Polaris) Migrate ¶
Migrate creates every table core and the plugins need that the database lacks (never altering or dropping an existing one) and seeds the permission catalog and system roles. Idempotent: run it at every boot. It returns the tables it created.
func (*Polaris) Protect ¶
Protect guards a host handler with Polaris principals (session JWTs, and API keys, OAuth tokens or agent requests when those plugins are installed): 401 without one. With permissions, the caller's authority in the active organization must hold every one (403 otherwise); without, any authenticated principal passes and no authority is resolved until next calls PrincipalFrom (then once per request). next reads the complete principal with PrincipalFrom.
func (*Polaris) Prune ¶
Prune deletes the expired transient rows Polaris accumulates (refresh tokens past their grace, used or expired verification, reset, OTP and invitation rows) and returns how many it deleted per table. Schedule it (a cron, a time.Ticker); it is idempotent and safe to run on every replica.
type Principal ¶
type Principal struct {
// UserID is the account acting: the user, the owner of an API key, the user an OAuth client
// or agent acts for. "" for an OAuth client acting for itself (client credentials).
UserID string `json:"user_id"`
// OrganizationID is the active organization, "" when none.
OrganizationID string `json:"organization_id"`
// Roles and Permissions are the caller's effective authority in OrganizationID, resolved from
// the database for this request (a delegated credential's permissions are already intersected
// with what it may use). Never nil.
Roles []string `json:"roles"`
Permissions []string `json:"permissions"`
Kind Kind `json:"kind"`
// Delegated is true for an API key, OAuth client or agent acting with a subset of its owner's
// permissions; such a credential may not self-serve (create organizations, keys, factors).
Delegated bool `json:"delegated"`
// ClientID is the OAuth client (KindOAuthClient, KindAgent); AgentID the agent (KindAgent);
// KeyID the API key (KindAPIKey). "" otherwise.
ClientID string `json:"client_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
KeyID string `json:"key_id,omitempty"`
// Claims are every claim of the credential, including the app's own (Hooks.Claims).
Claims map[string]any `json:"claims,omitempty"`
// contains filtered or unexported fields
}
Principal is who is calling: the authenticated user, API key, OAuth client or agent of a request that Protect (or a Polaris route) let through. Read it with PrincipalFrom. It is a plain value: keep it, log it, pass it to Can.
func PrincipalFrom ¶
PrincipalFrom returns the principal of a request Protect or a Polaris route authenticated. ok is false on an unauthenticated request, and when the caller's authority cannot be resolved (the database failed; Polaris logs it): treat both as "no principal".
Behind Protect without permissions, the first call resolves the authority (one query) and the request keeps it; a handler that never calls PrincipalFrom costs no query. Behind Protect with permissions it was resolved already.
mux.Handle("GET /api/invoices", p.Protect(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
who, _ := polaris.PrincipalFrom(r.Context())
list(w, who.UserID, who.OrganizationID)
}), "invoices.read"))
type Sessions ¶
type Sessions struct {
// contains filtered or unexported fields
}
Sessions opens, refreshes and ends sessions in process, with the same rules, events and audit as the HTTP routes.
func (Sessions) Issue ¶
Issue opens a session for a sign-in the host verified: the account checks of sign-in apply (a disabled account, or an unverified email when verification is required, is ErrForbidden) but not the password or the MFA gate. Access tokens carry Hooks.Claims.
func (Sessions) Refresh ¶
Refresh exchanges a refresh token for new tokens, rotating it. An unknown, expired, revoked or reused one is ErrInvalidCredentials (reuse also ends the whole session).
type SignIn ¶
type SignIn struct {
UserID string
// AMR says how the user authenticated, RFC 8176 values ("pwd", "otp", "hwk", …); empty is
// ["custom"].
AMR []string
IP string // recorded on the session; optional
UserAgent string // recorded on the session; optional
}
SignIn is a sign-in the host verified itself (its own SSO, a magic link of its own, a device it trusts).
type Tokens ¶
type Tokens struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
TokenType string `json:"token_type"` // "Bearer"
ExpiresIn int `json:"expires_in"` // access-token lifetime, seconds
RefreshExpiresAt time.Time `json:"refresh_expires_at"`
SessionID string `json:"session_id"`
}
Tokens are a session's credentials, as the sign-in route answers them.
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
Users manages accounts in process, with the same rules, events and audit as the HTTP routes. The caller is trusted: no permission is checked (the actor recorded is "system").
func (Users) ByEmail ¶
ByEmail returns the account holding email, matched as sign-in matches it (ErrNotFound).
func (Users) Create ¶
Create makes an account, running Hooks.OnUserCreated in its transaction. A taken email is ErrConflict; a bad email, name or password ErrInvalidInput (*PasswordError lists the rules).
func (Users) Delete ¶
Delete erases the account (right to erasure): the row stays as an anonymized tombstone so references hold, personal data and credentials go, every session ends, and Hooks.OnUserDeleted runs in the erasing transaction.
func (Users) Disable ¶
Disable disables the account and ends every session; sign-in then refuses it. Disabling a disabled account is a no-op.
func (Users) Enable ¶
Enable re-enables a disabled or locked account (ErrConflict for an erased one).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent is the Go agent SDK of Polaris: how a Go program signs in to a Polaris server as an AI agent (the plugins/agents protocol).
|
Package agent is the Go agent SDK of Polaris: how a Go program signs in to a Polaris server as an AI agent (the plugins/agents protocol). |
|
Package authz is Polaris's role-based authorization (upstream docs/auth/rbac.md): the code-defined permission catalog and its seeder, the resolver that turns a user and an active organization into an Authority (role slugs and permission keys), the Gate that checks it, the escalation guard and the session-principal resolver that puts roles into access tokens.
|
Package authz is Polaris's role-based authorization (upstream docs/auth/rbac.md): the code-defined permission catalog and its seeder, the resolver that turns a user and an active organization into an Authority (role slugs and permission keys), the Gate that checks it, the escalation guard and the session-principal resolver that puts roles into access tokens. |
|
Package cache is the short-lived key/value port Polaris uses for rate-limit counters, replay guards, flow state and the access-token denylist.
|
Package cache is the short-lived key/value port Polaris uses for rate-limit counters, replay guards, flow state and the access-token denylist. |
|
Package cli is the polaris command line as a library: schema export, creation, diff and drop, migrations, the manifest, a doctor, key generation, `.env` scaffolding, the MCP stdio server and the plugins' maintenance commands (audit, admin, anonymous).
|
Package cli is the polaris command line as a library: schema export, creation, diff and drop, migrations, the manifest, a doctor, key generation, `.env` scaffolding, the MCP stdio server and the plugins' maintenance commands (audit, admin, anonymous). |
|
Package clock is the time port.
|
Package clock is the time port. |
|
cmd
|
|
|
polaris
command
Command polaris is the standalone Polaris command line: the instance comes from the environment and .env, the database from DATABASE_URL or --dsn, the plugins from --plugins.
|
Command polaris is the standalone Polaris command line: the instance comes from the environment and .env, the database from DATABASE_URL or --dsn, the plugins from --plugins. |
|
Package config holds Polaris configuration: the boot secrets (Secrets) and the auth settings (Auth), with the defaults, environment variables and validation rules of upstream `docs/auth/configuration.md`.
|
Package config holds Polaris configuration: the boot secrets (Secrets) and the auth settings (Auth), with the defaults, environment variables and validation rules of upstream `docs/auth/configuration.md`. |
|
Package endpoint is the contract between the request pipeline and the code that serves one route: an Endpoint receives the request's Input and returns a Result.
|
Package endpoint is the contract between the request pipeline and the code that serves one route: an Endpoint receives the request's Input and returns a Result. |
|
Package event is the domain-event port, the Go form of PSR-14 in PHP Polaris.
|
Package event is the domain-event port, the Go form of PSR-14 in PHP Polaris. |
|
examples
|
|
|
api-keys
command
Command api-keys adds user and organization API keys to Polaris: a key (`Authorization: Bearer pk_live_…` or `x-api-key`) authenticates every Polaris route and every host route behind Protect as its owner, limited to the key's permissions.
|
Command api-keys adds user and organization API keys to Polaris: a key (`Authorization: Bearer pk_live_…` or `x-api-key`) authenticates every Polaris route and every host route behind Protect as its owner, limited to the key's permissions. |
|
minimal
command
Command minimal is the smallest complete Polaris host: core authentication (register, verify, login, refresh, MFA, organizations, RBAC) on SQLite, plus one host route protected by Polaris.
|
Command minimal is the smallest complete Polaris host: core authentication (register, verify, login, refresh, MFA, organizations, RBAC) on SQLite, plus one host route protected by Polaris. |
|
Package identity runs the account flows of docs/auth/flows.md §1–3, §8 and §10 (upstream Polaris\Identity): registration and email verification, password login with windowed lockout and the MFA hand-off, password forgot/reset/change, and user administration (read, update, disable, enable, erase).
|
Package identity runs the account flows of docs/auth/flows.md §1–3, §8 and §10 (upstream Polaris\Identity): registration and email verification, password login with windowed lockout and the MFA hand-off, password forgot/reset/change, and user administration (read, update, disable, enable, erase). |
|
internal
|
|
|
apispec
Package apispec embeds the route specs every Polaris endpoint is built from: api/<package>/**/*.yaml (method, path, input rules, output, errors, events) and api/core/schema.json.
|
Package apispec embeds the route specs every Polaris endpoint is built from: api/<package>/**/*.yaml (method, path, input rules, output, errors, events) and api/core/schema.json. |
|
contracttest
Package contracttest replays the upstream contract fixtures against a Go http.Handler.
|
Package contracttest replays the upstream contract fixtures against a Go http.Handler. |
|
httpapi
Package httpapi holds core's endpoints: one endpoint.Endpoint per route in upstream/api/core, registered by route name.
|
Package httpapi holds core's endpoints: one endpoint.Endpoint per route in upstream/api/core, registered by route name. |
|
maintenance
Package maintenance holds the housekeeping jobs a host schedules (a cron, a ticker).
|
Package maintenance holds the housekeeping jobs a host schedules (a cron, a ticker). |
|
netguard
Package netguard is the outbound-request guard plugins use when a URL comes from a tenant or a client (OIDC issuers, client metadata documents, jwks_uri, domain-verification files): connect only to public unicast addresses, decided after DNS resolution, so a public name that resolves to an internal address (cloud metadata, internal services) is refused too.
|
Package netguard is the outbound-request guard plugins use when a URL comes from a tenant or a client (OIDC issuers, client metadata documents, jwks_uri, domain-verification files): connect only to public unicast addresses, decided after DNS resolution, so a public name that resolves to an internal address (cloud metadata, internal services) is refused too. |
|
observe
Package observe has the observability listeners of the core events (docs/auth/events.md): the audit trail written to auth_audit_log and the event counter.
|
Package observe has the observability listeners of the core events (docs/auth/events.md): the audit trail written to auth_audit_log and the event counter. |
|
services
Package services hands core (package polaris, internal/httpapi, polaristest, cli) the concrete services of a wiring.Graph.
|
Package services hands core (package polaris, internal/httpapi, polaristest, cli) the concrete services of a wiring.Graph. |
|
version
Package version reports which release of Polaris is running, from the build information the Go toolchain records: the version of github.com/univeros/polaris.go a host's go.mod requires, or of this module when it is the one being built.
|
Package version reports which release of Polaris is running, from the build information the Go toolchain records: the version of github.com/univeros/polaris.go a host's go.mod requires, or of this module when it is the one being built. |
|
Package manifest loads the endpoint specs (api/**/*.yaml) that declare every Polaris route, checks request input against their field rules, and exports them as upstream does: the JSON manifest and an OpenAPI 3.1 document.
|
Package manifest loads the endpoint specs (api/**/*.yaml) that declare every Polaris route, checks request input against their field rules, and exports them as upstream does: the JSON manifest and an OpenAPI 3.1 document. |
|
Package metrics is where Polaris counts its domain events.
|
Package metrics is where Polaris counts its domain events. |
|
Package mfa holds multi-factor authentication (upstream docs/auth/mfa-otp.md).
|
Package mfa holds multi-factor authentication (upstream docs/auth/mfa-otp.md). |
|
Package model holds core's records as plain Go values, one struct per table of schema.Core() (PHP Polaris\Model).
|
Package model holds core's records as plain Go values, one struct per table of schema.Core() (PHP Polaris\Model). |
|
Package notify delivers one-time codes and account notifications by email and SMS.
|
Package notify delivers one-time codes and account notifications by email and SMS. |
|
notifytest
Package notifytest has recording notify drivers for tests: they keep what they were asked to send so a test can assert the recipient and read the one-time code.
|
Package notifytest has recording notify drivers for tests: they keep what they were asked to send so a test can assert the recipient and read the one-time code. |
|
Package orgs manages organizations, their members, invitations and roles (upstream OrganizationService, MembershipService, InvitationService and RoleService; docs/auth/rbac.md §3, §6–§8), enforcing the multi-tenant invariants a permission check alone cannot express:
|
Package orgs manages organizations, their members, invitations and roles (upstream OrganizationService, MembershipService, InvitationService and RoleService; docs/auth/rbac.md §3, §6–§8), enforcing the multi-tenant invariants a permission check alone cannot express: |
|
Package pipeline is the HTTP face of Polaris: it routes requests by the endpoint manifest and runs them through the contractual middleware order (docs/history/port-spec.md §4.3) to the registered endpoint:
|
Package pipeline is the HTTP face of Polaris: it routes requests by the endpoint manifest and runs them through the contractual middleware order (docs/history/port-spec.md §4.3) to the registered endpoint: |
|
plugins
|
|
|
admin
Package admin is the admin plugin: the operator API under /admin over users, sessions, MFA, organizations, audit drains and statistics, for admin users and operator API keys, every action recorded in the audit trail as admin.<action>.
|
Package admin is the admin plugin: the operator API under /admin over users, sessions, MFA, organizations, audit drains and statistics, for admin users and operator API keys, every action recorded in the audit trail as admin.<action>. |
|
agents
Package agents makes AI agents Polaris principals (the port of upstream's polaris/agents, plugin id "agents"): agents registered by their owners or enrolled by hosts, each an OAuth client of the oauth plugin (client credentials for an autonomous agent, token exchange with act for a delegated one; private_key_jwt, a pcs_ secret or the user's token), signed request JWTs (typ agent+jwt: aud the exact URL, jti once, exp - iat at most 5 min, htm/htu/body_hash binding), capability grants with constraints and budgets approved by a person (device code, CIBA push, in-app) with the strength the risk needs or by policy, one execution path with a signed receipt hash chain, and a kill switch.
|
Package agents makes AI agents Polaris principals (the port of upstream's polaris/agents, plugin id "agents"): agents registered by their owners or enrolled by hosts, each an OAuth client of the oauth plugin (client credentials for an autonomous agent, token exchange with act for a delegated one; private_key_jwt, a pcs_ secret or the user's token), signed request JWTs (typ agent+jwt: aud the exact URL, jti once, exp - iat at most 5 min, htm/htu/body_hash binding), capability grants with constraints and budgets approved by a person (device code, CIBA push, in-app) with the strength the risk needs or by policy, one execution path with a signed receipt hash chain, and a kill switch. |
|
anonymous
Package anonymous is the guest-session plugin: a visitor gets a session before having an account, and once they sign up or in by any method the guest is converted into that account through a host hook that moves what the host kept under the guest's id.
|
Package anonymous is the guest-session plugin: a visitor gets a session before having an account, and once they sign up or in by any method the guest is converted into that account through a host hook that moves what the host kept under the guest's id. |
|
apikeys
Package apikeys is the API-keys plugin: keys owned by users and by organizations (pk_live_…, pk_test_…), each with a subset of its owner's permissions, an optional rate limit of its own, an expiry, rotation with a grace window and revocation.
|
Package apikeys is the API-keys plugin: keys owned by users and by organizations (pk_live_…, pk_test_…), each with a subset of its owner's permissions, an optional rate limit of its own, an expiry, rotation with a grace window and revocation. |
|
audit
Package audit is the audit plugin: every Polaris event becomes a catalogued, redacted, append-only record in polaris_audit_event that callers query per user (GET /audit/me) and per organization (GET /audit/organization/{id}, audit.read), streamed to extra sinks and to each organization's drains, pruned by a retention policy and, optionally, chained by SHA-256 for tamper evidence.
|
Package audit is the audit plugin: every Polaris event becomes a catalogued, redacted, append-only record in polaris_audit_event that callers query per user (GET /audit/me) and per organization (GET /audit/organization/{id}, audit.read), streamed to extra sinks and to each organization's drains, pruned by a retention policy and, optionally, chained by SHA-256 for tamper evidence. |
|
mcp
Package mcp is Polaris and the Model Context Protocol, two halves sharing token verification.
|
Package mcp is Polaris and the Model Context Protocol, two halves sharing token verification. |
|
messaging
Package messaging is the messaging plugin: core's verification, reset, invitation, one-time-code and security messages rendered from templates you can override per instance and per organization, translated (en, es, de, fr, pt bundled), capped per recipient, and sent through the channels you choose (SMTP, Twilio, Vonage, any HTTP SMS API, a log, memory in tests).
|
Package messaging is the messaging plugin: core's verification, reset, invitation, one-time-code and security messages rendered from templates you can override per instance and per organization, translated (en, es, de, fr, pt bundled), capped per recipient, and sent through the channels you choose (SMTP, Twilio, Vonage, any HTTP SMS API, a log, memory in tests). |
|
multisession
Package multisession is the multi-session plugin: several accounts signed in on one device (one browser), a switch between them without signing in again, signing one out, and the device's last sign-in method for the client to pre-select its button.
|
Package multisession is the multi-session plugin: several accounts signed in on one device (one browser), a switch between them without signing in again, signing one out, and the device's last sign-in method for the client to pre-select its button. |
|
oauth
Package oauth makes Polaris an OAuth 2.1 and OpenID Connect provider (the port of upstream's polaris/oauth-provider, plugin id "oauth"): authorization code with PKCE (S256 only) and consent, rotating refresh tokens, client credentials, the device flow (RFC 8628), backchannel authentication (OpenID CIBA, poll mode), token exchange (RFC 8693, with act), DPoP (RFC 9449), dynamic registration (RFC 7591, off by default), client ID metadata documents (an https client_id fetched, validated and cached), introspection, revocation, userinfo and the discovery documents.
|
Package oauth makes Polaris an OAuth 2.1 and OpenID Connect provider (the port of upstream's polaris/oauth-provider, plugin id "oauth"): authorization code with PKCE (S256 only) and consent, rotating refresh tokens, client credentials, the device flow (RFC 8628), backchannel authentication (OpenID CIBA, poll mode), token exchange (RFC 8693, with act), DPoP (RFC 9449), dynamic registration (RFC 7591, off by default), client ID metadata documents (an https client_id fetched, validated and cached), introspection, revocation, userinfo and the discovery documents. |
|
passkey
Package passkey is the passkey plugin: WebAuthn registration from a session, discoverable sign-in with conditional UI (the browser offers the user's passkeys, autofill included) ending in core's login envelope with amr ["passkey"], naming and removal; and, by default, every passkey is also a core MFA factor of type "passkey", verified through core's own /auth/mfa/verify and /auth/mfa/step-up with the assertion JSON as the code.
|
Package passkey is the passkey plugin: WebAuthn registration from a session, discoverable sign-in with conditional UI (the browser offers the user's passkeys, autofill included) ending in core's login envelope with amr ["passkey"], naming and removal; and, by default, every passkey is also a core MFA factor of type "passkey", verified through core's own /auth/mfa/verify and /auth/mfa/step-up with the assertion JSON as the code. |
|
passwordless
Package passwordless is the passwordless plugin: four ways to sign in without a password, each ending in core's login envelope behind core's MFA gate.
|
Package passwordless is the passwordless plugin: four ways to sign in without a password, each ending in core's login envelope behind core's MFA gate. |
|
scim
Package scim is the SCIM plugin: a SCIM 2.0 server (RFC 7643, 7644) per organization.
|
Package scim is the SCIM plugin: a SCIM 2.0 server (RFC 7643, 7644) per organization. |
|
sentinel
Package sentinel is the sentinel plugin: a local risk engine in front of sign-up, sign-in, password reset and code sends.
|
Package sentinel is the sentinel plugin: a local risk engine in front of sign-up, sign-in, password reset and code sends. |
|
social
Package social is the social sign-in plugin: OAuth 2.0 and OpenID Connect sign-in and sign-up through Google, Apple, Microsoft, GitHub and fifteen more providers, or any other OAuth 2 server; account linking under a policy; Google One Tap; provider tokens on the user's behalf (stored encrypted, refreshed when expiring); and an OAuth proxy so preview and local origins sign in through the stable origin registered at the providers.
|
Package social is the social sign-in plugin: OAuth 2.0 and OpenID Connect sign-in and sign-up through Google, Apple, Microsoft, GitHub and fifteen more providers, or any other OAuth 2 server; account linking under a policy; Google One Tap; provider tokens on the user's behalf (stored encrypted, refreshed when expiring); and an OAuth proxy so preview and local origins sign in through the stable origin registered at the providers. |
|
sso
Package sso is the SSO plugin: per-organization SAML 2.0 and OpenID Connect identity providers, verified domains that route an email to its organization's provider, just-in-time users and memberships, single logout in both directions, the organization's own self-service routes and the operators' view.
|
Package sso is the SSO plugin: per-organization SAML 2.0 and OpenID Connect identity providers, verified domains that route an email to its organization's provider, just-in-time users and memberships, single logout in both directions, the organization's own self-service routes and the operators' view. |
|
username
Package username is the username plugin: a user sets a username (PATCH /username) and signs in with it or with the email (POST /username/sign-in) through core's password path, so lockout, timing parity, the email-verification rule, the MFA gate and the login envelope are core's.
|
Package username is the username plugin: a user sets a username (PATCH /username) and signs in with it or with the email (POST /username/sign-in) through core's password path, so lockout, timing parity, the email-verification rule, the MFA gate and the login envelope are core's. |
|
Package polaristest boots a complete Polaris server for tests: a fresh database (SQLite in a temp file by default; see WithDialect and EnvDB) with the schema and permission catalog installed, test RSA keys, recording mailer, SMS sender and event log, and a frozen rate-limit clock — the environment upstream's functional suite uses, so the contract fixtures replay.
|
Package polaristest boots a complete Polaris server for tests: a fresh database (SQLite in a temp file by default; see WithDialect and EnvDB) with the schema and permission catalog installed, test RSA keys, recording mailer, SMS sender and event log, and a frozen rate-limit clock — the environment upstream's functional suite uses, so the contract fixtures replay. |
|
Package ratelimit counts requests in fixed windows and computes the rate-limit headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset and, when refused, Retry-After).
|
Package ratelimit counts requests in fixed windows and computes the rate-limit headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset and, when refused, Retry-After). |
|
Package repository reads and writes core's records (package model) through a store.Adapter, one typed repository per table with explicit row mapping.
|
Package repository reads and writes core's records (package model) through a store.Adapter, one typed repository per table with explicit row mapping. |
|
Package schema is the database schema as data, the Go form of PHP Polaris\Schema.
|
Package schema is the database schema as data, the Go form of PHP Polaris\Schema. |
|
Package security holds Polaris's secret-handling primitives: password hashing (Argon2id, PHC strings), keyed hashing of verifiable secrets (Pepper), authenticated encryption of secrets at rest (XChaCha20-Poly1305) and breached-password screening (HIBP k-anonymity).
|
Package security holds Polaris's secret-handling primitives: password hashing (Argon2id, PHC strings), keyed hashing of verifiable secrets (Pepper), authenticated encryption of secrets at rest (XChaCha20-Poly1305) and breached-password screening (HIBP k-anonymity). |
|
Package session runs the refresh-token session lifecycle (upstream TokenService and SessionService, docs/auth/flows.md §3, §5, §7): issuing a short-lived access JWT plus a rotating, opaque refresh token; refreshing with reuse detection; step-up and organization switches that re-mint without rotating; listing and revoking sessions.
|
Package session runs the refresh-token session lifecycle (upstream TokenService and SessionService, docs/auth/flows.md §3, §5, §7): issuing a short-lived access JWT plus a rotating, opaque refresh token; refreshing with reuse detection; step-up and organization switches that re-mint without rotating; listing and revoking sessions. |
|
Package store is the persistence port: a row-level adapter over any database, the Go form of PHP Polaris\Contract\DatabaseAdapter.
|
Package store is the persistence port: a row-level adapter over any database, the Go form of PHP Polaris\Contract\DatabaseAdapter. |
|
memstore
Package memstore is an in-memory store.Adapter (port of PHP Polaris\Testing\InMemoryAdapter) for tests and prototypes.
|
Package memstore is an in-memory store.Adapter (port of PHP Polaris\Testing\InMemoryAdapter) for tests and prototypes. |
|
sqlstore
Package sqlstore is the store.Adapter over database/sql for PostgreSQL (pgx), MySQL and SQLite (modernc, no cgo), the Go form of PHP polaris/pdo: prepared statements only, nested transactions as savepoints, unique-constraint violations as store.ErrDuplicate.
|
Package sqlstore is the store.Adapter over database/sql for PostgreSQL (pgx), MySQL and SQLite (modernc, no cgo), the Go form of PHP polaris/pdo: prepared statements only, nested transactions as savepoints, unique-constraint violations as store.ErrDuplicate. |
|
storetest
Package storetest is the store.Adapter conformance suite (port of PHP AdapterConformanceTests): every criteria form, ordering, paging, Increment, transactions with savepoints, duplicate keys and concurrent use, over core's tables.
|
Package storetest is the store.Adapter conformance suite (port of PHP AdapterConformanceTests): every criteria form, ordering, paging, Increment, transactions with savepoints, duplicate keys and concurrent use, over core's tables. |
|
telemetry
|
|
|
otel
Package otel instruments Polaris with OpenTelemetry: a span and a duration measurement per HTTP request (Middleware), a span per database call (Store) and a counter of authentication outcomes (Listener).
|
Package otel instruments Polaris with OpenTelemetry: a span and a duration measurement per HTTP request (Middleware), a span per database call (Store) and a counter of authentication outcomes (Listener). |
|
Package token mints and verifies Polaris access tokens: asymmetric JWTs (RS256 or EdDSA) with a kid header, managed iss/aud/iat/nbf/exp claims and the Polaris claim set, plus the JWK Set that publishes the verification keys.
|
Package token mints and verifies Polaris access tokens: asymmetric JWTs (RS256 or EdDSA) with a kid header, managed iss/aud/iat/nbf/exp claims and the Polaris claim set, plus the JWK Set that publishes the verification keys. |
|
Package wiring builds every Polaris service from a Config, explicitly and once: the Go form of upstream's Polaris\Wiring\Graph, without a container.
|
Package wiring builds every Polaris service from a Config, explicitly and once: the Go form of upstream's Polaris\Wiring\Graph, without a container. |