A runnable HTTP server that wires AuthCore into Fiber v3. Register, login, access a protected route, rotate tokens.
This example is its own Go module (separate
go.mod) so the root library has no runtime dependency on Fiber. Run it from this directory.
cd examples/fiber
go run .Server listens on :3000.
| Method | Path | Auth | Purpose |
|---|---|---|---|
POST |
/register |
none | Hash + store the new user's password |
POST |
/login |
none | Verify password, issue an access + refresh pair |
GET |
/me |
Authorization: Bearer <access> |
Verify the access token, return claims |
POST |
/refresh |
refresh token in body | Rotate the pair, replace the stored hash |
# 1. Register
curl -X POST localhost:3000/register \
-H 'content-type: application/json' \
-d '{"email":"ana@example.com","password":"Str0ng-P@ssword!"}'
# 2. Login: capture the tokens
curl -X POST localhost:3000/login \
-H 'content-type: application/json' \
-d '{"email":"ana@example.com","password":"Str0ng-P@ssword!"}'
# 3. Protected route
curl localhost:3000/me -H 'authorization: Bearer <access-token>'
# 4. Rotate
curl -X POST localhost:3000/refresh \
-H 'content-type: application/json' \
-d '{"refresh_token":"<refresh-token>"}'Providerpassed to multiple modules once at startup.pwdMod.Hash/pwdMod.Verifyfor registration + login.jwtMod.CreateTokenswith typedUserClaims.jwtMod.VerifyAccessTokenin a Fiber middleware for/me.jwtMod.HashRefreshToken→ DB lookup →jwtMod.VerifyRefreshTokenHash→jwtMod.RotateTokens: the full anti-reuse rotation pattern.
User storage is an in-memory map for brevity. Swap it for your real database.