feat: honor project login requirement in CollabTable
This commit is contained in:
1 parent
ec82a8a8b9
commit
407966fc94
2 files changed
+20
-21
No files matched your search
+4
-6
@@ -69,12 +69,10 @@ const (
|
|||||||
legacySessionCookieName = "collabtable_session"
|
legacySessionCookieName = "collabtable_session"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collabTableAuthStore adapts *DB to sharedauth.ProxyStore. CollabTable never
|
// collabTableAuthStore adapts *DB to sharedauth.ProxyStore. The login
|
||||||
// had an independent "require login" toggle (a session was always required
|
// requirement is runtime-controlled by ProjectConfigurator through
|
||||||
// whenever AUTHGUARD_URL was configured at all) so LoginRequired always
|
// sharedauth.Service's internal endpoint; this store supplies the conservative
|
||||||
// reports true and SetLoginRequired is a no-op -- server.go correspondingly
|
// required-by-default fallback. IsSetupClaimed/TryClaimSetup/UnclaimSetup delegate
|
||||||
// wires sharedauth.Service.Require rather than the *IfLoginRequired
|
|
||||||
// middleware family. IsSetupClaimed/TryClaimSetup/UnclaimSetup delegate
|
|
||||||
// straight through to *DB's existing methods of the same name/signature (see
|
// straight through to *DB's existing methods of the same name/signature (see
|
||||||
// db.go), reusing the collabtable_setup_state table/queries verbatim.
|
// db.go), reusing the collabtable_setup_state table/queries verbatim.
|
||||||
type collabTableAuthStore struct {
|
type collabTableAuthStore struct {
|
||||||
|
|||||||
+16
-15
@@ -175,19 +175,20 @@ func (s *Server) registerRoutes(mux *http.ServeMux, webRoot fs.FS) {
|
|||||||
mux.HandleFunc("GET /api/auth/status", s.auth.Status)
|
mux.HandleFunc("GET /api/auth/status", s.auth.Status)
|
||||||
mux.HandleFunc("POST /api/auth/setup", s.auth.Signup)
|
mux.HandleFunc("POST /api/auth/setup", s.auth.Signup)
|
||||||
mux.HandleFunc("POST /api/auth/login", s.auth.Login)
|
mux.HandleFunc("POST /api/auth/login", s.auth.Login)
|
||||||
mux.Handle("POST /api/auth/logout", s.auth.Require(http.HandlerFunc(s.auth.Logout)))
|
mux.Handle("PUT /api/auth/access/internal", s.auth.SetLoginRequiredInternal(s.internalServiceSecret))
|
||||||
mux.Handle("POST /api/auth/credentials", s.auth.Require(http.HandlerFunc(s.auth.UpdateMe)))
|
mux.Handle("POST /api/auth/logout", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.Logout)))
|
||||||
mux.Handle("GET /api/auth/users", s.auth.Require(http.HandlerFunc(s.auth.ManagedUsers)))
|
mux.Handle("POST /api/auth/credentials", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.UpdateMe)))
|
||||||
mux.Handle("POST /api/auth/users", s.auth.Require(http.HandlerFunc(s.auth.ManagedCreateUser)))
|
mux.Handle("GET /api/auth/users", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.ManagedUsers)))
|
||||||
mux.Handle("PUT /api/auth/users/{id}", s.auth.Require(http.HandlerFunc(s.auth.ManagedUpdateUser)))
|
mux.Handle("POST /api/auth/users", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.ManagedCreateUser)))
|
||||||
mux.Handle("PATCH /api/auth/users/{id}", s.auth.Require(http.HandlerFunc(s.auth.ManagedUpdateUser)))
|
mux.Handle("PUT /api/auth/users/{id}", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.ManagedUpdateUser)))
|
||||||
mux.Handle("DELETE /api/auth/users/{id}", s.auth.Require(http.HandlerFunc(s.auth.ManagedDeleteUser)))
|
mux.Handle("PATCH /api/auth/users/{id}", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.ManagedUpdateUser)))
|
||||||
mux.Handle("GET /api/auth/totp/status", s.auth.Require(http.HandlerFunc(s.auth.TOTPStatus)))
|
mux.Handle("DELETE /api/auth/users/{id}", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.ManagedDeleteUser)))
|
||||||
mux.Handle("POST /api/auth/totp/setup", s.auth.Require(http.HandlerFunc(s.auth.TOTPInitiate)))
|
mux.Handle("GET /api/auth/totp/status", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.TOTPStatus)))
|
||||||
mux.Handle("POST /api/auth/totp/enable", s.auth.Require(http.HandlerFunc(s.auth.TOTPVerify)))
|
mux.Handle("POST /api/auth/totp/setup", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.TOTPInitiate)))
|
||||||
mux.Handle("POST /api/auth/totp/disable", s.auth.Require(http.HandlerFunc(s.auth.TOTPDisable)))
|
mux.Handle("POST /api/auth/totp/enable", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.TOTPVerify)))
|
||||||
mux.Handle("GET /api/auth/token/status", s.auth.Require(http.HandlerFunc(s.handleTokenStatus)))
|
mux.Handle("POST /api/auth/totp/disable", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.auth.TOTPDisable)))
|
||||||
mux.Handle("POST /api/auth/token/regenerate", s.auth.Require(http.HandlerFunc(s.handleTokenRegenerate)))
|
mux.Handle("GET /api/auth/token/status", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.handleTokenStatus)))
|
||||||
|
mux.Handle("POST /api/auth/token/regenerate", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.handleTokenRegenerate)))
|
||||||
|
|
||||||
// Sync/collaboration API routes use a long-lived bearer token shared by the
|
// Sync/collaboration API routes use a long-lived bearer token shared by the
|
||||||
// user's devices. This is deliberately separate from browser sessions.
|
// user's devices. This is deliberately separate from browser sessions.
|
||||||
@@ -217,8 +218,8 @@ func (s *Server) registerRoutes(mux *http.ServeMux, webRoot fs.FS) {
|
|||||||
|
|
||||||
// The dashboard is a public SPA shell, but its data and tech-stack endpoints
|
// The dashboard is a public SPA shell, but its data and tech-stack endpoints
|
||||||
// are protected by the browser session.
|
// are protected by the browser session.
|
||||||
mux.Handle("GET /api/tech-stack", s.auth.Require(http.HandlerFunc(s.handleTechStack)))
|
mux.Handle("GET /api/tech-stack", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.handleTechStack)))
|
||||||
mux.Handle("GET /web/data", s.auth.Require(http.HandlerFunc(s.handleWebData)))
|
mux.Handle("GET /web/data", s.auth.RequireIfLoginRequired(http.HandlerFunc(s.handleWebData)))
|
||||||
mux.Handle("/", spaFileServer(webRoot))
|
mux.Handle("/", spaFileServer(webRoot))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user