Skip to content

Commit 8a2ac46

Browse files
authored
feat: unified (target, matchType, value) match shape for rules and permissions (#227)
## Summary Closes #221 - Replaces the old `slug/owner/name` fields on `AccessRule` and `path/pathType` on `RepoPermission` with a single `match:` block (new `MatchTarget` + `MatchType` enums) shared by both rules and permissions - V5 SQL migration migrates existing data; column named `match_value` to avoid H2 reserved keyword - `type` is optional in config — defaults to `GLOB` for both rules and permissions (uniform default, no context-switching) - All YAML fixtures, Docker config files, docs, tests, and the dashboard UI dropdowns updated Config shape is now consistent across rules and permissions: ```yaml match: target: SLUG | OWNER | NAME value: <pattern> type: LITERAL | GLOB | REGEX # optional, defaults to GLOB ``` ## Test plan - [x] `./gradlew test --rerun` passes (all unit + integration tests) - [x] e2e tests pass locally (54/58 — 4 pre-existing `ConfigHotReloadE2ETest` failures unrelated to this change) - [x] `JettyConfigurationBuilderTest` covers null-type default (GLOB) for both rules and permissions - [ ] CI e2e suite
2 parents 40a0e83 + 411faf0 commit 8a2ac46

43 files changed

Lines changed: 1140 additions & 950 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docker/git-proxy-docker-default.yml

Lines changed: 86 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,44 @@ permissions:
4848
# test-user: LITERAL — only /test-owner/test-repo
4949
- username: test-user
5050
provider: gitea
51-
path: /test-owner/test-repo
51+
match:
52+
target: SLUG
53+
value: /test-owner/test-repo
54+
type: LITERAL
5255
operations: PUSH
5356

5457
# user2: GLOB — any repo under otherorg
5558
- username: user2
5659
provider: gitea
57-
path: /otherorg/*
58-
path-type: GLOB
60+
match:
61+
target: OWNER
62+
value: otherorg
63+
type: GLOB
5964
operations: PUSH
6065

6166
# user3: REGEX — test-owner repos matching test-repo.*
6267
- username: user3
6368
provider: gitea
64-
path: /test-owner/test-repo.*
65-
path-type: REGEX
69+
match:
70+
target: SLUG
71+
value: '/test-owner/test-repo.*'
72+
type: REGEX
6673
operations: PUSH
6774

6875
# reviewer: APPROVE on all the same paths
6976
- username: reviewer
7077
provider: gitea
71-
path: /test-owner/test-repo
78+
match:
79+
target: SLUG
80+
value: /test-owner/test-repo
81+
type: LITERAL
7282
operations: REVIEW
7383
- username: reviewer
7484
provider: gitea
75-
path: /otherorg/*
76-
path-type: GLOB
85+
match:
86+
target: OWNER
87+
value: otherorg
88+
type: GLOB
7789
operations: REVIEW
7890

7991
# LDAP testuser (maps to gitea/test-user): same literal grant as test-user above.
@@ -82,18 +94,26 @@ permissions:
8294
# so that push-permission-literal.sh still passes the deny-on-other-repo case.
8395
- username: testuser
8496
provider: gitea
85-
path: /test-owner/test-repo
97+
match:
98+
target: SLUG
99+
value: /test-owner/test-repo
100+
type: LITERAL
86101
operations: PUSH
87102

88103
# admin APPROVE grants for LDAP setup (admin approves via dashboard).
89104
- username: admin
90105
provider: gitea
91-
path: /test-owner/test-repo
106+
match:
107+
target: SLUG
108+
value: /test-owner/test-repo
109+
type: LITERAL
92110
operations: REVIEW
93111
- username: admin
94112
provider: gitea
95-
path: /otherorg/*
96-
path-type: GLOB
113+
match:
114+
target: OWNER
115+
value: otherorg
116+
type: GLOB
97117
operations: REVIEW
98118

99119
providers:
@@ -149,65 +169,70 @@ rules:
149169
allow:
150170
- enabled: true
151171
order: 110
152-
operations:
153-
- FETCH
154-
- PUSH
155-
providers:
156-
- gitea
157-
slugs:
158-
- /test-owner/test-repo
159-
- /test-owner/test-repo-2
172+
operations: BOTH
173+
provider: gitea
174+
match:
175+
target: SLUG
176+
value: '/test-owner/test-repo(-2)?'
177+
type: REGEX
178+
160179
- enabled: true
161180
order: 111
162-
operations:
163-
- FETCH
164-
- PUSH
165-
providers:
166-
- gitea
167-
owners:
168-
- otherorg
181+
operations: BOTH
182+
provider: gitea
183+
match:
184+
target: OWNER
185+
value: otherorg
186+
type: GLOB
187+
169188
- enabled: true
170189
order: 120
171-
operations:
172-
- FETCH
173-
providers:
174-
- github
175-
owners:
176-
- finos
190+
operations: FETCH
191+
provider: github
192+
match:
193+
target: OWNER
194+
value: finos
195+
type: GLOB
177196

178197
deny:
179-
# Deny a specific repo inside the otherwise-allowed otherorg/* owner glob.
180-
# Demonstrates that deny wins: user2 has GLOB permission on /otherorg/* and
198+
# Deny a specific repo inside the otherwise-allowed otherorg owner.
199+
# Demonstrates that deny wins: user2 has permission on otherorg and
181200
# the allow rule covers all of otherorg, but this repo is explicitly off-limits.
182201
- enabled: true
183202
order: 100
184-
operations:
185-
- FETCH
186-
- PUSH
187-
providers:
188-
- gitea
189-
slugs:
190-
- /otherorg/other-secret
191-
192-
# Deny repos whose name ends in -readonly or -archived — these are archival
193-
# copies that should not receive new commits through the proxy.
203+
operations: BOTH
204+
provider: gitea
205+
match:
206+
target: SLUG
207+
value: /otherorg/other-secret
208+
type: LITERAL
209+
210+
# Deny repos whose name ends in -readonly or -archived — archival copies
211+
# that should not receive new commits through the proxy.
212+
- enabled: true
213+
order: 101
214+
operations: PUSH
215+
provider: gitea
216+
match:
217+
target: NAME
218+
value: "*-readonly"
219+
type: GLOB
220+
194221
- enabled: true
195222
order: 101
196-
operations:
197-
- PUSH
198-
providers:
199-
- gitea
200-
names:
201-
- "*-readonly"
202-
- "*-archived"
203-
204-
# Regex deny: block any repo whose name contains the word "secret" as a
205-
# distinct segment (e.g. secret-store, my-secret-keys, not "secretariat").
223+
operations: PUSH
224+
provider: gitea
225+
match:
226+
target: NAME
227+
value: "*-archived"
228+
type: GLOB
229+
230+
# Regex deny: block any repo whose name contains "secret" as a distinct segment.
206231
- enabled: true
207232
order: 102
208-
operations:
209-
- PUSH
210-
providers:
211-
- gitea
212-
names:
213-
- "regex:(?i)(^|-)secret(-|$).*"
233+
operations: PUSH
234+
provider: gitea
235+
match:
236+
target: NAME
237+
value: "(?i)(^|-)secret(-|$).*"
238+
type: REGEX

docker/git-proxy-ldap.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,29 @@ auth:
3030
permissions:
3131
- username: testuser
3232
provider: gitea
33-
path: /test-owner/test-repo
33+
match:
34+
target: SLUG
35+
value: /test-owner/test-repo
36+
type: LITERAL
3437
operations: PUSH
3538
- username: testuser
3639
provider: gitea
37-
path: /otherorg/*
38-
path-type: GLOB
40+
match:
41+
target: OWNER
42+
value: otherorg
43+
type: GLOB
3944
operations: PUSH
4045
- username: admin
4146
provider: gitea
42-
path: /test-owner/test-repo
47+
match:
48+
target: SLUG
49+
value: /test-owner/test-repo
50+
type: LITERAL
4351
operations: REVIEW
4452
- username: admin
4553
provider: gitea
46-
path: /otherorg/*
47-
path-type: GLOB
54+
match:
55+
target: OWNER
56+
value: otherorg
57+
type: GLOB
4858
operations: REVIEW

docker/git-proxy-local.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ users:
1818
permissions:
1919
- username: admin
2020
provider: gitea
21-
path: /test-owner/test-repo
21+
match:
22+
target: SLUG
23+
value: /test-owner/test-repo
24+
type: LITERAL
2225
operations: PUSH_AND_REVIEW
2326
- username: admin
2427
provider: gitea
25-
path: /otherorg/*
26-
path-type: GLOB
28+
match:
29+
target: OWNER
30+
value: otherorg
31+
type: GLOB
2732
operations: PUSH_AND_REVIEW
2833

2934
providers:

docker/git-proxy-oidc.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,29 @@ auth:
3737
permissions:
3838
- username: testuser
3939
provider: gitea
40-
path: /test-owner/test-repo
40+
match:
41+
target: SLUG
42+
value: /test-owner/test-repo
43+
type: LITERAL
4144
operations: PUSH
4245
- username: testuser
4346
provider: gitea
44-
path: /otherorg/*
45-
path-type: GLOB
47+
match:
48+
target: OWNER
49+
value: otherorg
50+
type: GLOB
4651
operations: PUSH
4752
- username: admin
4853
provider: gitea
49-
path: /test-owner/test-repo
54+
match:
55+
target: SLUG
56+
value: /test-owner/test-repo
57+
type: LITERAL
5058
operations: REVIEW
5159
- username: admin
5260
provider: gitea
53-
path: /otherorg/*
54-
path-type: GLOB
61+
match:
62+
target: OWNER
63+
value: otherorg
64+
type: GLOB
5565
operations: REVIEW

0 commit comments

Comments
 (0)