Oauth2 support

This commit is contained in:
Jamie Curnow
2024-11-06 20:33:51 +10:00
parent f23299f793
commit 208037946f
25 changed files with 529 additions and 30 deletions

View File

@ -50,6 +50,7 @@ func NewRouter() http.Handler {
middleware.Expansion,
middleware.DecodeAuth(),
middleware.BodyContext(),
middleware.Log,
)
return applyRoutes(r)
@ -61,6 +62,12 @@ func applyRoutes(r chi.Router) chi.Router {
r.NotFound(handler.NotFound())
r.MethodNotAllowed(handler.NotAllowed())
// OAuth endpoints aren't technically API endpoints
r.With(middleware.EnforceSetup()).Route("/oauth", func(r chi.Router) {
r.Get("/login", handler.OAuthLogin())
r.Get("/redirect", handler.OAuthRedirect())
})
// SSE - requires a sse token as the `jwt` get parameter
// Exists inside /api but it's here so that we can skip the Timeout middleware
// that applies to other endpoints.