Migration: pkg/authn → go/authn¶
The request-authentication primitives have been extracted out of go-tool-base into
the standalone module gitlab.com/phpboyscout/go/authn (v0.1.0). It is
framework-free — its only dependencies are cockroachdb/errors and
golang-jwt/jwt/v5 — so any project can adopt the verifiers without pulling in the
framework.
What changed¶
- The package
gitlab.com/phpboyscout/go-tool-base/pkg/authnno longer exists. It now lives atgitlab.com/phpboyscout/go/authn. - The public API is identical. The package name is still
authn;Verifier,CertVerifier,Identity,AuthorizeFunc,ErrUnauthenticated, theNewAPIKeyVerifier/NewJWTVerifier/NewMTLSVerifierconstructors, theRequireScopes/RequireClaimcombinators, and the context helpers are unchanged. - There is no GTB adapter and no compatibility shim — a clean pre-1.0
import-path change (
pkg/authnhad zero go-tool-base imports). - The unused generated mocks under
mocks/pkg/authn/are removed. If you mockVerifier/CertVerifierdownstream, generate mocks in your own tree (or open an issue on the module to ship them).
How to migrate¶
Repoint the import path — nothing else changes:
Then add the module and tidy:
go get gitlab.com/phpboyscout/go/[email protected]
go mod tidy
A repository-wide substitution is sufficient (the package name and every symbol are unchanged):
grep -rl 'go-tool-base/pkg/authn' --include='*.go' . \
| xargs sed -i 's#gitlab.com/phpboyscout/go-tool-base/pkg/authn#gitlab.com/phpboyscout/go/authn#g'
go mod tidy
Notes¶
- go-tool-base itself now consumes
go/authndirectly: its HTTPAuthMiddleware(pkg/http) and gRPC auth interceptor (pkg/grpc) wrap the module's verifiers. The GTB-side wiring (WithAPIKeyHeader,WithBearerVerifier,WithAuthorize,IdentityFromContext) is unchanged — see How to verify requests. - Full documentation and the security model live at authn.go.phpboyscout.uk; the API reference is on pkg.go.dev.