oficina / agent-access Public
Show approved permission labels on /connections
The connections page listed raw scope codes such as docs:read. It now shows the same labels as the consent page, read from the same configured scope map (Config.Scopes, built from connection's scopeDescriptions). A scope with no label keeps its code. Team display is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+35
−0
grant/manage.go+5 −0grant/manage_test.go+30 −0
CI passed — run details
CI log
=== ci === go vet ./... go: downloading github.com/gofrs/flock v0.12.1 go: downloading github.com/zalando/go-keyring v0.2.8 go: downloading golang.org/x/oauth2 v0.35.0 go: downloading github.com/modelcontextprotocol/go-sdk v1.7.0 go: downloading amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060 go: downloading amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 go: downloading github.com/google/uuid v1.6.0 go: downloading github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 go: downloading golang.org/x/sys v0.46.0 go: downloading github.com/godbus/dbus/v5 v5.2.2 go: downloading github.com/google/jsonschema-go v0.4.3 go: downloading github.com/yosida95/uritemplate/v3 v3.0.2 go: downloading golang.org/x/sync v0.21.0 go: downloading golang.org/x/time v0.15.0 go: downloading gorm.io/gorm v1.31.2 go: downloading gorm.io/plugin/dbresolver v1.6.2 go: downloading golang.org/x/text v0.39.0 go: downloading github.com/segmentio/encoding v0.5.4 go: downloading github.com/jinzhu/now v1.1.5 go: downloading modernc.org/libc v1.74.1 go: downloading github.com/jinzhu/inflection v1.0.0 go: downloading github.com/segmentio/asm v1.1.3 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading modernc.org/mathutil v1.7.1 go: downloading modernc.org/memory v1.11.0 go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec go test -race ./... ok amadan.net/oficina/agent-access.git 2.212s ok amadan.net/oficina/agent-access.git/client 1.049s ? amadan.net/oficina/agent-access.git/cmd/oficina [no test files] ok amadan.net/oficina/agent-access.git/cmd/oficina-connect 5.640s ok amadan.net/oficina/agent-access.git/connection 1.376s ok amadan.net/oficina/agent-access.git/grant 1.591s
diff --git a/grant/manage.go b/grant/manage.go| index 8e0345a..c8263f1 100644 |
| --- a/grant/manage.go |
| +++ b/grant/manage.go |
| @@ -61,6 +61,11 @@ func (s *Server) manage(w http.ResponseWriter, r *http.Request) { |
| if client, ok := s.clients[connections[i].Client]; ok { |
| connections[i].Client = client.Name |
| } |
| + for j, scope := range connections[i].Scopes { |
| + if label, ok := s.cfg.Scopes[scope]; ok { |
| + connections[i].Scopes[j] = label |
| + } |
| + } |
| } |
| encoded := "" |
| if len(connections) > 0 { |
diff --git a/grant/manage_test.go b/grant/manage_test.go| index 7fb5c9a..7927e71 100644 |
| --- a/grant/manage_test.go |
| +++ b/grant/manage_test.go |
| @@ -92,3 +92,33 @@ func TestBrowserConnectionsAreSubjectBoundAndRevocationIsSingleUse(t *testing.T) |
| t.Fatal("anonymous management", resp.StatusCode) |
| } |
| } |
| + |
| +func TestConnectionsShowConsentLabelsNotScopeCodes(t *testing.T) { |
| + s, ts, _ := setup(t) |
| + g := Grant{ID: "labelled", Subject: "opaque-person", ClientID: "oficina-cli", Teams: []string{"acme"}, Scopes: []string{"notes:write", "offline_access", "mystery:scope"}} |
| + if _, err := s.cfg.Store.CreateCode(t.Context(), g, Code{}); err != nil { |
| + t.Fatal(err) |
| + } |
| + r, _ := http.NewRequest("GET", ts.URL+"/connections", nil) |
| + r.Header.Set("Test-Session", "signed-in") |
| + resp, err := ts.Client().Do(r) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer resp.Body.Close() |
| + raw, _ := io.ReadAll(resp.Body) |
| + page := string(raw) |
| + for _, label := range []string{"Create and edit notes", "Keep this connection"} { |
| + if !strings.Contains(page, "<li>"+label+"</li>") { |
| + t.Fatalf("missing label %q in %s", label, page) |
| + } |
| + } |
| + for _, code := range []string{"notes:write", "offline_access"} { |
| + if strings.Contains(page, code) { |
| + t.Fatalf("known scope code %q shown", code) |
| + } |
| + } |
| + if !strings.Contains(page, "<li>mystery:scope</li>") { |
| + t.Fatal("unknown scope did not fall back to its code") |
| + } |
| +} |