Cut user-owned API keys; redesign subject model
Removes the APIKey primitive entirely (Auth.IssueAPIKey/AuthenticateAPIKey/
RevokeAPIKey, APIKeyStore, Deps.APIKeys, Stores.APIKeys, Tables.APIKeys,
ErrAPIKeyInvalid, AuthMethodAPIKey, Principal.{APIKeyID, Abilities, HasAbility},
prefixAPIKey, RequireAPIKey, and the 6 SQL templates). Migration
0003_drop_api_keys.sql hard-drops authkit_api_keys.
The new subject model: *Principal carries identity only (sessions, JWTs);
*ServiceKey is the only abilities-bearing credential and gains a
HasAbility(name) method. RequireAbility now reads *ServiceKey from context
(user principals 403 by design). RequireRole/RequirePermission stay
Principal-only. New RequireServiceKey + ServiceKeyFrom + MustServiceKey,
and a heterogeneous RequireAnyOrServiceKey for routes that accept either.
RequireAny is now Principal-only (default [Session, JWT]).
Adds 7 middleware tests (auth, revoked, ability accept/reject across
subjects, role rejects service key, RequireAnyOrServiceKey both paths) and
1 (*ServiceKey).HasAbility unit test. Existing API-key tests deleted.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4942e4dbdc
commit
7f1db871bc
24 changed files with 773 additions and 496 deletions
11
doc.go
11
doc.go
|
|
@ -1,10 +1,11 @@
|
|||
// Package authkit is an authentication and authorization toolkit for Go web
|
||||
// services. It defines storage interfaces (UserStore, SessionStore, TokenStore,
|
||||
// APIKeyStore, RoleStore, PermissionStore) and a high-level Auth service that
|
||||
// composes them to support registration, password login, opaque server-side
|
||||
// sessions, JWT access plus rotating refresh tokens, email verification,
|
||||
// password resets, magic-link passwordless login, role-based access control,
|
||||
// and API keys with custom abilities.
|
||||
// ServiceKeyStore, RoleStore, PermissionStore) and a high-level Auth service
|
||||
// that composes them to support registration, password login, opaque
|
||||
// server-side sessions, JWT access plus rotating refresh tokens, email
|
||||
// verification, password resets, magic-link passwordless login, role-based
|
||||
// access control, and owner-agnostic service tokens with custom abilities for
|
||||
// server-to-server auth.
|
||||
//
|
||||
// Default Postgres implementations of every store live in the pgstore
|
||||
// subpackage. Argon2id password hashing lives in hasher. Framework-neutral
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue