Skip to content

Commit 331fd02

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-rest-openapi-redirect
2 parents 5167096 + e9f7e4a commit 331fd02

28 files changed

Lines changed: 1890 additions & 5561 deletions

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
env:
2727
TL_TEST_DATABASE_URL: postgres://root:for_testing@localhost:5432/tlv2_test?sslmode=disable
2828
TL_TEST_SERVER_DATABASE_URL: postgres://root:for_testing@localhost:5432/tlv2_test_server?sslmode=disable
29-
TL_REDIS_URL: redis://localhost
29+
TL_REDIS_URL: redis://localhost
3030
services:
3131
postgres:
3232
image: postgis/postgis:12-3.4-alpine
@@ -37,7 +37,7 @@ jobs:
3737
POSTGRES_PASSWORD: for_testing
3838
POSTGRES_DB: tlv2_test_server
3939
options: >-
40-
--health-cmd pg_isready
40+
--health-cmd "pg_isready -U root -d tlv2_test_server"
4141
--health-interval 10s
4242
--health-timeout 5s
4343
--health-retries 5
@@ -61,7 +61,7 @@ jobs:
6161
- run: (cd cmd/transitland && go version && go install .)
6262
- run: ./testdata/test_setup.sh
6363
- name: Run tests
64-
run: go test -v -coverprofile c.out ./...
64+
run: go test -coverprofile c.out ./...
6565
- name: Produce coverage report
6666
run: go tool cover -html=c.out -o coverage.html
6767
- name: Save coverage report as artifact

cmds/server_cmd.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (cmd *ServerCommand) Run(ctx context.Context) error {
172172

173173
// Disable auth if requested
174174
if cmd.DisableAuth {
175-
cfg.Checker = &globalAdminChecker{}
175+
cfg.Checker = globalAdminCheckerInstance
176176
}
177177

178178
// Setup router
@@ -250,12 +250,5 @@ func (cmd *ServerCommand) Run(ctx context.Context) error {
250250
return srv.ListenAndServe()
251251
}
252252

253-
// globalAdminChecker is a simple checker that always returns true for CheckGlobalAdmin,
254-
// effectively disabling all feed authorization checks.
255-
type globalAdminChecker struct {
256-
authz.UnimplementedCheckerServer
257-
}
258-
259-
func (c *globalAdminChecker) CheckGlobalAdmin(ctx context.Context) (bool, error) {
260-
return true, nil
261-
}
253+
// globalAdminChecker disables all feed authorization checks.
254+
var globalAdminCheckerInstance = &authz.GlobalAdminChecker{}

doc/admin-api-migration.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Admin REST API Migration Guide
2+
3+
The authorization system internals have been refactored, but the admin REST API response shapes are preserved. All endpoints use the same URL paths, HTTP methods, request bodies, and response JSON shapes as before.
4+
5+
Request bodies use integer enum values for `type` and `relation` fields (e.g., `"type": 5` for user, `"relation": 1` for admin), matching the previous proto3 JSON format.
6+
7+
## Unchanged endpoints
8+
9+
All endpoints retain their existing response shapes:
10+
11+
| Endpoint | Description |
12+
|----------|-------------|
13+
| `GET /me` | Current user info |
14+
| `GET /tenants` | List tenants |
15+
| `GET /tenants/:id` | Tenant permissions |
16+
| `POST /tenants/:id` | Update tenant name |
17+
| `POST /tenants/:id/groups` | Create group under tenant |
18+
| `POST /tenants/:id/permissions` | Add permission to tenant |
19+
| `DELETE /tenants/:id/permissions` | Remove permission from tenant |
20+
| `GET /groups` | List groups |
21+
| `GET /groups/:id` | Group permissions |
22+
| `POST /groups/:id` | Update group name |
23+
| `POST /groups/:id/permissions` | Add permission to group |
24+
| `DELETE /groups/:id/permissions` | Remove permission from group |
25+
| `POST /groups/:id/tenant` | Set group's parent tenant |
26+
| `GET /feeds` | List feeds |
27+
| `GET /feeds/:id` | Feed permissions |
28+
| `POST /feeds/:id/group` | Set feed's parent group |
29+
| `GET /feed_versions` | List feed versions |
30+
| `GET /feed_versions/:id` | Feed version permissions |
31+
| `POST /feed_versions/:id/permissions` | Add permission to feed version |
32+
| `DELETE /feed_versions/:id/permissions` | Remove permission from feed version |
33+
| `GET /users` | List users |
34+
| `GET /users/:id` | Get user |
35+
36+
## Minor behavioral changes
37+
38+
- **Actions map**: Only granted permissions (`true`) are included in the `actions` object. Previously, denied actions could appear as `false` due to proto3 default value behavior; now they are simply absent. Clients that check `actions.can_edit === true` are unaffected. Clients that check `"can_edit" in actions` should verify the value is `true`.
39+
- **Entity existence checks**: Permissions endpoints now return "not found" for non-existent entity IDs, even for global admins. Previously, global admins could query permissions on any ID without an existence check.
40+
- **Parse error handling**: Permission mutation endpoints (`POST/DELETE .../permissions`) now correctly return an error and stop processing if the JSON request body is malformed. Previously, a parse failure could fall through and attempt the operation with zero values.

go.mod

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,26 @@ require (
2626
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
2727
github.com/google/uuid v1.6.0
2828
github.com/graph-gophers/dataloader/v7 v7.1.0
29+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0
2930
github.com/hypirion/go-filecache v0.0.0-20160810125507-e3e6ef6981f0
3031
github.com/iancoleman/orderedmap v0.2.0
3132
github.com/interline-io/log v0.0.0-20260130001517-d932d48db9e4
3233
github.com/irees/squirrel v0.0.0-20250822021440-28034b47d2f4
33-
github.com/jackc/pgx/v5 v5.7.4
34+
github.com/jackc/pgx/v5 v5.8.0
3435
github.com/jellydator/ttlcache/v2 v2.11.1
3536
github.com/jlaffaye/ftp v0.0.0-20220524001917-dfa1e758f3af
3637
github.com/jmoiron/sqlx v1.4.0
3738
github.com/mattn/go-sqlite3 v1.14.22
3839
github.com/mmcloughlin/geohash v0.10.0
40+
github.com/openfga/api/proto v0.0.0-20260122164422-25e22cb1875b
3941
github.com/openfga/go-sdk v0.2.3
42+
github.com/openfga/openfga v1.11.5
4043
github.com/pkg/errors v0.9.1
4144
github.com/rs/zerolog v1.34.0
4245
github.com/sergi/go-diff v1.3.1
4346
github.com/snabb/isoweek v1.0.1
44-
github.com/spf13/cobra v1.8.1
45-
github.com/spf13/pflag v1.0.5
47+
github.com/spf13/cobra v1.10.2
48+
github.com/spf13/pflag v1.0.10
4649
github.com/stretchr/testify v1.11.1
4750
github.com/tidwall/gjson v1.18.0
4851
github.com/tidwall/rtree v1.10.0
@@ -51,16 +54,18 @@ require (
5154
github.com/twpayne/go-polyline v1.1.1
5255
github.com/twpayne/go-shapefile v0.0.6
5356
github.com/vektah/gqlparser/v2 v2.5.30
54-
google.golang.org/grpc v1.79.3
55-
google.golang.org/protobuf v1.36.10
57+
google.golang.org/protobuf v1.36.11
5658
gopkg.in/dnaeon/go-vcr.v2 v2.3.0
5759
)
5860

5961
require (
62+
cel.dev/expr v0.25.1 // indirect
6063
github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0 // indirect
6164
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
6265
github.com/PuerkitoBio/rehttp v1.3.0 // indirect
66+
github.com/Yiling-J/theine-go v0.6.2 // indirect
6367
github.com/agnivade/levenshtein v1.2.1 // indirect
68+
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
6469
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
6570
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
6671
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
@@ -75,18 +80,28 @@ require (
7580
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
7681
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
7782
github.com/aws/smithy-go v1.22.3 // indirect
83+
github.com/beorn7/perks v1.0.1 // indirect
84+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
7885
github.com/cespare/xxhash/v2 v2.3.0 // indirect
7986
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
80-
github.com/davecgh/go-spew v1.1.1 // indirect
87+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
8188
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
89+
github.com/emirpasic/gods v1.18.1 // indirect
90+
github.com/envoyproxy/protoc-gen-validate v1.3.0 // indirect
8291
github.com/flopp/go-coordsparser v0.0.0-20201115094714-8baaeb7062d5 // indirect
8392
github.com/fogleman/gg v1.3.0 // indirect
93+
github.com/fsnotify/fsnotify v1.9.0 // indirect
94+
github.com/go-logr/logr v1.4.3 // indirect
95+
github.com/go-logr/stdr v1.2.2 // indirect
8496
github.com/go-openapi/jsonpointer v0.21.0 // indirect
8597
github.com/go-openapi/swag v0.23.0 // indirect
8698
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
87-
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
99+
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
88100
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
101+
github.com/google/cel-go v0.27.0 // indirect
89102
github.com/gorilla/websocket v1.5.0 // indirect
103+
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
104+
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect
90105
github.com/hashicorp/errwrap v1.1.0 // indirect
91106
github.com/hashicorp/go-multierror v1.1.1 // indirect
92107
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
@@ -95,6 +110,7 @@ require (
95110
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
96111
github.com/jackc/puddle/v2 v2.2.2 // indirect
97112
github.com/josharian/intern v1.0.0 // indirect
113+
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
98114
github.com/kylelemons/godebug v1.1.0 // indirect
99115
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
100116
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
@@ -103,43 +119,72 @@ require (
103119
github.com/mattn/go-colorable v0.1.14 // indirect
104120
github.com/mattn/go-isatty v0.0.20 // indirect
105121
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
122+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
123+
github.com/natefinch/wrap v0.2.0 // indirect
106124
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
107125
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
126+
github.com/oklog/ulid/v2 v2.1.1 // indirect
127+
github.com/openfga/language/pkg/go v0.2.0-beta.2.0.20251027165255-0f8f255e5f6c // indirect
128+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
108129
github.com/perimeterx/marshmallow v1.1.5 // indirect
109130
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
110-
github.com/pmezard/go-difflib v1.0.0 // indirect
131+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
132+
github.com/prometheus/client_golang v1.23.2 // indirect
133+
github.com/prometheus/client_model v0.6.2 // indirect
134+
github.com/prometheus/common v0.66.1 // indirect
135+
github.com/prometheus/procfs v0.16.1 // indirect
111136
github.com/russross/blackfriday/v2 v2.1.0 // indirect
137+
github.com/sagikazarmark/locafero v0.9.0 // indirect
112138
github.com/sosodev/duration v1.3.1 // indirect
139+
github.com/sourcegraph/conc v0.3.0 // indirect
140+
github.com/spf13/afero v1.15.0 // indirect
141+
github.com/spf13/cast v1.10.0 // indirect
142+
github.com/spf13/viper v1.20.1 // indirect
143+
github.com/subosito/gotenv v1.6.0 // indirect
113144
github.com/tidwall/geoindex v1.7.0 // indirect
114145
github.com/tidwall/match v1.1.1 // indirect
115146
github.com/tidwall/pretty v1.2.1 // indirect
116147
github.com/tkrajina/gpxgo v1.1.2 // indirect
117148
github.com/urfave/cli/v2 v2.27.7 // indirect
118149
github.com/woodsbury/decimal128 v1.3.0 // indirect
119150
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
120-
go.uber.org/atomic v1.7.0 // indirect
121-
go.uber.org/goleak v1.3.0 // indirect
122-
golang.org/x/crypto v0.46.0 // indirect
123-
golang.org/x/image v0.18.0 // indirect
124-
golang.org/x/mod v0.30.0 // indirect
125-
golang.org/x/net v0.48.0 // indirect
126-
golang.org/x/oauth2 v0.34.0 // indirect
151+
github.com/zeebo/xxh3 v1.0.2 // indirect
152+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
153+
go.opentelemetry.io/otel v1.40.0 // indirect
154+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect
155+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.40.0 // indirect
156+
go.opentelemetry.io/otel/metric v1.40.0 // indirect
157+
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
158+
go.opentelemetry.io/otel/trace v1.40.0 // indirect
159+
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
160+
go.uber.org/atomic v1.9.0 // indirect
161+
go.uber.org/mock v0.6.0 // indirect
162+
go.uber.org/multierr v1.11.0 // indirect
163+
go.uber.org/zap v1.27.1 // indirect
164+
go.yaml.in/yaml/v2 v2.4.3 // indirect
165+
go.yaml.in/yaml/v3 v3.0.4 // indirect
166+
golang.org/x/crypto v0.47.0 // indirect
167+
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
168+
golang.org/x/image v0.25.0 // indirect
169+
golang.org/x/mod v0.32.0 // indirect
170+
golang.org/x/net v0.49.0 // indirect
171+
golang.org/x/oauth2 v0.35.0 // indirect
127172
golang.org/x/sync v0.19.0 // indirect
128173
golang.org/x/sys v0.40.0 // indirect
129174
golang.org/x/term v0.39.0 // indirect
130-
golang.org/x/text v0.32.0 // indirect
131-
golang.org/x/tools v0.39.0 // indirect
132-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
133-
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect
175+
golang.org/x/text v0.34.0 // indirect
176+
golang.org/x/tools v0.41.0 // indirect
177+
gonum.org/v1/gonum v0.17.0 // indirect
178+
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
179+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect
180+
google.golang.org/grpc v1.79.1 // indirect
134181
gopkg.in/yaml.v3 v3.0.1 // indirect
135182
)
136183

137184
tool github.com/99designs/gqlgen
138185

139186
tool google.golang.org/protobuf/cmd/protoc-gen-go
140187

141-
tool google.golang.org/grpc/cmd/protoc-gen-go-grpc
142-
143188
// Fork to allow exporting x- extensions
144189
replace github.com/getkin/kin-openapi => github.com/irees/kin-openapi v0.0.0-20250915211515-c3bd85109028
145190

0 commit comments

Comments
 (0)