authkit is a Go library for authentication and authorization in Web API services. It provides reusable request authentication, token exchange, principal resolution, and authorization plumbing without becoming an identity provider, hosted login system, or policy framework.
The shared auth path works end to end: a short-lived authkit access JWT authenticates to an internal principal, and an authorizer checks that principal against an action, application resource, and optional caller-supplied facts.
go get github.com/meigma/authkitRun the vertical example:
go run ./testkit/cmd/testkitThe testkit pastebin prints a seed API token and starts http://localhost:8080.
Open /login, paste the seed token, and create a paste. The login form
exchanges the API token for an authkit access JWT carried in the temporary
authkit_testkit_access cookie.
The same exchange path is available to tests and applications through Go APIs:
result, err := apiTokenExchanger.Exchange(ctx, exchange.APITokenRequest{
Plaintext: seedToken,
})
if err != nil {
return err
}
_ = result.AccessToken.PlaintextThe example is also covered by tests:
go test ./testkit/...authkit has two composition layers:
- The root
authkitpackage contains the core contracts andPipeline. - The
composepackage is the standardnet/httphelper for common API service wiring.
For most net/http services, start with
Compose HTTP authentication.
Applications that need full control can use
explicit composition.
Common setup tasks are covered by focused guides for
local roles,
OIDC exchange and auto-provisioning,
and authorization facts.
The architecture and security model explain the request pipeline, credential independence, failure mapping, and security invariants.
- Docs home: authkit.meigma.dev
- Tutorial: Learn authkit with the testkit pastebin
- How-to: Compose HTTP authentication
- Explanation: Architecture
- Reference: Core contracts and extension points
Use the pinned toolchain in .prototools and run checks through Moon:
moon ci --summary minimal
moon run docs:typecheck
moon run docs:buildUse GitHub Discussions for questions and general support. Use GitHub Issues for non-security bug reports. Do not report vulnerabilities in public channels. See SECURITY.md.
See CONTRIBUTING.md for contribution guidelines, local setup expectations, and pull request workflow.
See SECURITY.md for supported versions and the private vulnerability reporting path.
authkit is dual-licensed under the Apache License 2.0 and the MIT License. You may choose either license for your use.