Polaris for Go · 1.1.1
Auth for Go services, agents first.
Users, MFA, sessions, organizations and roles, API keys, an OAuth 2.1 / OpenID Connect
provider, agents as first-class principals and MCP protection, in your database. One
import, a few lines of net/http, on PostgreSQL, MySQL and SQLite.
Any client of the Agent Auth Protocol can sign in.
go get github.com/univeros/polaris.go@v1.1.1 Quick start
Mount it, protect your routes.
db, err := sqlstore.Open(ctx, store.Postgres, os.Getenv("DATABASE_URL"))
cfg, err := polaris.FromEnv(db /*, plugins... */) // APP_KEY, AUTH_JWT_*, AUTH_ISSUER
p, err := polaris.New(cfg) // errors say how to fix
_, err = p.Migrate(ctx) // creates missing tables; idempotent
mux := http.NewServeMux()
mux.Handle("/", p.Handler()) // every Polaris route: /auth/login, /orgs, ...
mux.Handle("GET /api/invoices", p.Protect(invoicesHandler, "org.read"))
// in the handler: who, ok := polaris.PrincipalFrom(r.Context()) The whole integration fits one page, written for coding agents and people alike: llms.txt. What you may rely on between releases: API stability.
Agent Auth Protocol · new in 1.1
Any agent can ask. A person decides.
Polaris for Go serves all 12 endpoints of the Agent Auth Protocol (v1.0-draft). Your users' assistants discover your service, ask for what they need and act within what was granted, with no key to paste and no SDK of ours. Declare what agents may do, and switch it on:
ag := agents.New(agents.Config{
Discovery: agents.DiscoveryAgentAuth,
ApprovalURL: "https://app.example.com/approve", // your page: a person sees who asks for what
Capabilities: []agents.Capability{{
Name: "refund", Description: "Refund an invoice", Permission: "billing.refund",
Risk: agents.RiskHigh, Location: "https://app.example.com/api/refunds",
}},
})
// ag goes to polaris.FromEnv with the oauth and passkey plugins, then:
mux.Handle("POST /api/refunds", ag.Protect("refund", refunds)) // checked before refunds runs Then anyone's client connects, here the protocol's own:
npx -y @auth/agent-cli@0.5.1 --url https://app.example.com --no-browser \
connect --provider https://app.example.com --capabilities refund Clients you did not write
The unmodified @auth/agent 0.6.2 runs against Polaris in CI, from first contact to revocation. Its CLI and MCP server, checked by hand for 1.1, connect the same way.
Nothing before a person says yes
A host the server has never seen leaves no host, agent or OAuth client until somebody signed in approves its code. Above low risk that takes a passkey by default.
Limits on every call
Constraints, budgets and the owner's own permissions are checked before your handler runs. Every execution leaves a signed, hash-chained receipt.
One kill switch
The owner, or the agent's own host, revokes it: the agent, its OAuth client and its tokens stop at once. Optional lifetimes expire the agents nobody uses.
Hosts your server does not know are taken only once you set
Discovery; the Go agent SDK keeps working beside them.
How it works ·
Run the example ·
Design and decisions
Built for Go
Standard library shapes, nothing to learn.
An http.Handler for the auth routes, middleware for yours,
the caller from polaris.PrincipalFrom(r.Context()), your
database through database/sql on PostgreSQL, MySQL and SQLite.
polaristest.New(t) gives your own tests a server,
telemetry/otel traces and measures it.
Every route is replayed by recorded contract tests in CI, the credential parsers are fuzzed,
and the v1 Go API, every exported name outside
internal/, is checked for compatibility on every pull request.
Plugins
Add what your service needs.
Magic links, email and phone codes, one-time hand-off tokens.
plugins/usernameCase-insensitive usernames; sign in with username or email.
plugins/anonymousGuest sessions converted on sign-up.
plugins/multisessionSeveral accounts per device, switch without signing in again.
plugins/social19 OAuth / OIDC providers and a generic one, linking, One Tap.
plugins/passkeyWebAuthn sign-in; a passkey is also an MFA factor.
plugins/apikeysUser and organization API keys, scoped, rate-limited, rotatable.
plugins/oauthOAuth 2.1 / OIDC provider: PKCE, device, CIBA, token exchange, DPoP, DCR.
plugins/mcpPolaris as an MCP server, and mcp.Protect for your own MCP servers.
plugins/agentsAgents as principals: grants, budgets, approvals, signed receipts. Speaks the Agent Auth Protocol.
plugins/ssoSAML 2.0 and OIDC per organization, verified domains, single logout.
plugins/scimSCIM 2.0 provisioning per organization with an org-managed token.
plugins/adminOperator API for users, sessions, MFA, organizations and audit.
plugins/auditAppend-only audit log of every event, sinks, hash chain.
plugins/messagingCore's mailer and SMS sender: templates, translations, send caps.
plugins/sentinelRisk engine on sign-up, sign-in, reset and code sends.
plugins/uiServer-rendered sign-in, sign-up, MFA, reset and consent pages, no JavaScript.