Release v0.0.1 - Initial OAuth2 server implementation
- Add Nostr OAuth2 server with NIP-98 authentication support - Implement OAuth2 authorization and token endpoints - Add .well-known/openid-configuration discovery endpoint - Include Dockerfile for containerized deployment - Add Claude Code release command for version management - Create example configuration file 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
55
internal/handler/routes.go
Normal file
55
internal/handler/routes.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
|
||||
"git.mleku.dev/mleku/gitea-nostr-auth/internal/config"
|
||||
"git.mleku.dev/mleku/gitea-nostr-auth/internal/nostr"
|
||||
"git.mleku.dev/mleku/gitea-nostr-auth/internal/oauth2"
|
||||
)
|
||||
|
||||
func NewRouter(cfg *config.Config, store oauth2.Store, fetcher *nostr.Fetcher) http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
// Middleware
|
||||
r.Use(middleware.Logger)
|
||||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.RealIP)
|
||||
r.Use(cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedMethods: []string{"GET", "POST", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 300,
|
||||
}))
|
||||
|
||||
h := &Handler{
|
||||
cfg: cfg,
|
||||
store: store,
|
||||
fetcher: fetcher,
|
||||
}
|
||||
|
||||
// OIDC Discovery
|
||||
r.Get("/.well-known/openid-configuration", h.OIDCDiscovery)
|
||||
|
||||
// OAuth2 endpoints
|
||||
r.Get("/authorize", h.Authorize)
|
||||
r.Post("/verify", h.Verify)
|
||||
r.Post("/token", h.Token)
|
||||
r.Get("/userinfo", h.UserInfo)
|
||||
|
||||
// JWKS endpoint (required for OIDC)
|
||||
r.Get("/.well-known/jwks.json", h.JWKS)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
type Handler struct {
|
||||
cfg *config.Config
|
||||
store oauth2.Store
|
||||
fetcher *nostr.Fetcher
|
||||
}
|
||||
Reference in New Issue
Block a user