A minimal, spec-compliant WebFinger server for account and service discovery.
Implements RFC 7033 for WebFinger discovery, designed to be small, auditable, and easy to deploy.
ℹ️ This project was previously named
asdf. The name was changed to better reflect its purpose.
curl "http://localhost:8080/.well-known/webfinger?resource=acct:alice@example.com"{
"subject": "acct:alice@example.com",
"aliases": [
"https://example.com/users/alice"
],
"links": [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "https://example.com/@alice"
}
]
}A WebFinger server implementation following RFC7033, with optional user management, authentication, caching, monitoring, and administrative capabilities.
- ✅ RFC7033-compliant WebFinger endpoint (
/.well-known/webfinger) - ✅ JSON Resource Descriptor (JRD) responses
- ✅ Subject aliases and properties support
- ✅ Rel-typed links for social media verification
- ✅ HTML frontend for manual lookups
- ✅ JWT-based authentication with session management
- ✅ User registration and login system
- ✅ Password hashing with bcrypt
- ✅ Role-based access control (admin/user)
- ✅ Email verification support
- ✅ Session management with Redis storage
- ✅ Redis caching for WebFinger lookups
- ✅ Rate limiting with configurable limits
- ✅ Database connection pooling
- ✅ Graceful shutdown handling
- ✅ Request/response compression
- ✅ CORS configuration
- ✅ Security headers (CSP, HSTS, X-Frame-Options)
- ✅ HTTPS redirection (production mode)
- ✅ Input validation and sanitization
- ✅ Trusted proxy configuration
- ✅ Prometheus metrics collection
- ✅ Structured JSON logging
- ✅ Health check endpoints
- ✅ Database migration system
- ✅ Admin dashboard with user management
- ✅ System statistics and monitoring
- ✅ Environment-based configuration
- ✅ Docker Compose setup with all dependencies
- ✅ Comprehensive test suite
- ✅ API documentation (OpenAPI/Swagger ready)
- ✅ Development vs production modes
-
Clone and setup:
git clone https://github.com/0dayfall/webfinger-server.git cd webfinger-server cp .env.example .env -
Generate certificates:
openssl genrsa -out server.key 2048 openssl req -new -x509 -sha256 -key server.key -out server.crt -days 365 mkdir -p certs && mv server.* certs/
-
Generate secrets:
# Generate JWT and session secrets echo "WEBFINGER_AUTH_JWT_SECRET=$(openssl rand -base64 32)" >> .env echo "WEBFINGER_AUTH_SESSION_SECRET=$(openssl rand -base64 32)" >> .env
-
Start services:
docker-compose up --build
-
Prerequisites:
- Go 1.23+
- PostgreSQL 16+
- Redis 7+ (optional, for caching)
-
Build and run:
go mod download go build -o webfinger-server ./cmd/webfinger-server ./webfinger-server
Configuration can be provided via:
- Environment variables (prefixed with
WEBFINGER_) - YAML configuration file (
config.yaml) - Command line arguments
server:
port: "8080"
host: "0.0.0.0"
env: "development" # development, production, test
database:
url: "postgres://user:pass@localhost/webfinger"
max_open_conns: 25
redis:
url: "redis://localhost:6379"
password: ""
db: 0
auth:
jwt_secret: "your-secret-key"
session_secret: "your-session-secret"
token_expiry_hours: 24
security:
rate_limit_rps: 10
rate_limit_burst: 20
allowed_origins: ["*"]
enable_csp: true
enable_hsts: true
force_https: trueSee .env.example for all available options.
GET /.well-known/webfinger?resource=acct:user@domain.com- WebFinger lookup
POST /api/auth/login- User loginPOST /api/auth/register- User registrationPOST /api/auth/logout- User logoutPOST /api/auth/refresh- Token refreshGET /api/profile- Get current user profile
GET /api/search?q=query- Search users
GET /api/admin/stats- System statisticsGET /api/admin/users- List usersPOST /api/admin/users- Create userGET /api/admin/users/{id}- Get userPUT /api/admin/users/{id}- Update userDELETE /api/admin/users/{id}- Delete user
GET /health- Health checkGET /metrics- Prometheus metrics
go test ./...# Run migrations
go run cmd/migrate/main.go up
# Rollback last migration
go run cmd/migrate/main.go down
# Create new migration
go run cmd/migrate/main.go create add_new_feature- Development (
WEBFINGER_SERVER_ENV=development): HTTP server, auto-migrations, seed data - Test (
WEBFINGER_SERVER_ENV=test): In-memory database, HTTP server, auto-cleanup - Production (
WEBFINGER_SERVER_ENV=production): HTTPS server, manual migrations, security headers
The server exposes Prometheus metrics at /metrics:
- HTTP request metrics (duration, status codes, paths)
- WebFinger-specific metrics (requests, cache hits/misses)
- Database connection metrics
- Authentication metrics (login attempts, active sessions)
-
Start monitoring stack:
docker-compose up prometheus grafana
-
Access Grafana: http://localhost:3000 (admin/admin)
-
Add Prometheus datasource: http://prometheus:9090
- Change default JWT and session secrets in production
- Use strong TLS certificates in production
- Configure proper CORS origins (not
*) - Set up trusted proxy headers correctly
- Enable security headers (CSP, HSTS)
- Use rate limiting appropriate for your traffic
- Regularly backup your database
- Monitor authentication attempts and failed logins
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
GNU General Public License v3.0 - see LICENSE file for details.
