feat(16.3-03): journal scopes and ResolveBackend token auth

- Register journal and journal:read via pact.HasTokenScopes
- Switch API auth to cabana.ResolveBackend with golem15.journal.* cover
- Map ErrTokenScope to PHP Insufficient permissions bodies
- Add TestResolveErrorMapping and TestJournalTokenTracer

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-11 02:11:13 +02:00
parent 5eea57fde1
commit 4ec64a3b35
6 changed files with 194 additions and 36 deletions

26
token_scopes.go Normal file
View File

@@ -0,0 +1,26 @@
package journal
import "git.golem15.com/golem15/summercms/modules/pact"
var _ pact.HasTokenScopes = (*Plugin)(nil)
// TokenScopes registers personal API token scopes for the Journal plugin.
func (p *Plugin) TokenScopes() []pact.TokenScope {
all := []string{"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"}
return []pact.TokenScope{
{
Name: "journal",
Label: "golem15.journal::lang.scopes.journal",
Description: "golem15.journal::lang.scopes.journal_description",
Permissions: []string{"golem15.journal.*"},
Methods: all,
},
{
Name: "journal:read",
Label: "golem15.journal::lang.scopes.journal_read",
Description: "golem15.journal::lang.scopes.journal_read_description",
Permissions: []string{"golem15.journal.*"},
Methods: []string{"GET", "HEAD"},
},
}
}