fasthttp-server

command
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 14 Imported by: 0

README

fasthttp Server Example

Schnallbert
Schnallbert says: "Raw speed, solid auth — no compromises!"

A minimal fasthttp server demonstrating goAuthly authentication middleware.

What it demonstrates

  • JWT verification — Bearer tokens validated against a local JWKS endpoint.
  • Opaque token verification — Bearer tokens introspected via a local RFC 7662 endpoint.
  • Basic Auth — Username/password verified with bcrypt.
  • Required metadata — The X-User-Sub header must be present on protected routes.

How to run

cd examples/fasthttp-server
go run .

The server starts on :8082 and prints example tokens to the console:

=== Example Tokens ===
JWT: eyJhbGciOi...
Opaque: opaque-good

Routes

Path Auth
/public None
/protected Bearer + X-User-Sub header
/basic Basic

Testing with curl

Replace <JWT> with the token printed at startup.

Public endpoint (no auth)
curl http://localhost:8082/public
Protected endpoint with JWT
curl -H "Authorization: Bearer <JWT>" \
     -H "X-User-Sub: demo-user" \
     http://localhost:8082/protected
Protected endpoint with opaque token
curl -H "Authorization: Bearer opaque-good" \
     -H "X-User-Sub: demo-user" \
     http://localhost:8082/protected
Basic auth endpoint
curl -u demo:password \
     http://localhost:8082/basic
Expected failure (missing X-User-Sub)
curl -H "Authorization: Bearer <JWT>" \
     http://localhost:8082/protected
# Returns 401

Notes

  • RSA keys are generated at startup — tokens are only valid for the current process.
  • Credentials (demo / password) are for demonstration only. Never use them in production.
  • A mock JWKS and introspection server runs on 127.0.0.1:9091 alongside the fasthttp app.

Documentation

Overview

Package main demonstrates goAuthly with a fasthttp server.

It starts a local JWKS + introspection mock, mints a demo JWT, and exposes three routes:

/public      — no authentication required
/protected   — requires Bearer token (JWT or opaque) + X-User-Sub header
/basic       — requires Basic auth credentials

This is demo-only code. Do not use the generated keys or credentials in production.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL