feat(16.3-01): interactive-only gates, ResolveBackend, last_used stamp
- Refuse g15_ tokens on account/avatar/refresh/logout; gate field-types and markdown - Publish cookie-less ResolveBackend; debounce last_used_at once per minute - Reserve account vendor segment; TestTokenGatesSmoke covers the deny path Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -167,6 +167,14 @@ func Activate(app *backpack.App, plugins []party.Plugin) (*Routes, error) {
|
||||
} else if owner != "summercms.cabana" {
|
||||
return nil, fmt.Errorf("cabana: backend guard: guard %q is already registered by %s; the admin API needs its own audience-checking guard under that name", "backend", owner)
|
||||
}
|
||||
// Cookie-less resolver for plugin routes (Bearer JWT or g15_ token only).
|
||||
if _, published := app.Lookup[*backendResolver](); !published {
|
||||
cookieLessJWT := bouncer.NewBackendJWTGuard(secret, users, bl, writeUnauthenticated)
|
||||
resolverGuard := newCompositeGuard(cookieLessJWT, store, users, reg)
|
||||
if err := app.Publish(&backendResolver{guard: resolverGuard}); err != nil {
|
||||
return nil, fmt.Errorf("cabana: backend resolver: %w", err)
|
||||
}
|
||||
}
|
||||
mw, err := guards.Middleware("backend")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -241,11 +249,11 @@ func (s *service) mount(r pact.Router) {
|
||||
// Login is exempt from the CSRF header: without it the response is a
|
||||
// Bearer body and no cookie is set, so a cross-site post gains nothing.
|
||||
g.Post("/login", s.login, throttle)
|
||||
g.Post("/refresh", requireAjax(s.refresh))
|
||||
g.Post("/refresh", interactiveOnly(requireAjax(s.refresh)))
|
||||
// Logout reads and verifies the token itself (see service.logout), so
|
||||
// it is mounted outside the backend guard, which rejects an expired
|
||||
// access token that is still refreshable.
|
||||
g.Post("/logout", requireAjax(s.logout))
|
||||
g.Post("/logout", interactiveOnly(requireAjax(s.logout)))
|
||||
})
|
||||
// The string bundle is public: the login screen needs it before auth.
|
||||
r.GroupRaw(api, nil, func(g pact.Router) {
|
||||
@@ -254,9 +262,10 @@ func (s *service) mount(r pact.Router) {
|
||||
r.GroupRaw(api, []string{"backend"}, func(g pact.Router) {
|
||||
g.Get("/auth/me", s.me)
|
||||
// My account: the signed-in admin edits their own profile.
|
||||
g.Put("/account", requireAjax(s.accountUpdate))
|
||||
g.Post("/account/avatar", requireAjax(s.avatarUpload))
|
||||
g.Delete("/account/avatar", requireAjax(s.avatarRemove))
|
||||
// interactiveOnly refuses personal API tokens before requireAjax.
|
||||
g.Put("/account", interactiveOnly(requireAjax(s.accountUpdate)))
|
||||
g.Post("/account/avatar", interactiveOnly(requireAjax(s.avatarUpload)))
|
||||
g.Delete("/account/avatar", interactiveOnly(requireAjax(s.avatarRemove)))
|
||||
g.Get("/navigation", s.navigation)
|
||||
// Plugin field types (pact.HasFormFieldTypes): the SPA loads their
|
||||
// scripts and styles once after sign-in.
|
||||
|
||||
Reference in New Issue
Block a user