Skip to content

Commit 39f6887

Browse files
committed
fix: enforce provider ID (type/host) consistently across both proxy modes
Provider IDs must be `type/host` everywhere (e.g. `forgejo/gitea`, `github/github.com`). Previously bare type names (`gitea`, `github`) were accepted in YAML config, stored in rules/permissions, and returned from APIs, causing identity resolution and access rule failures. Changes: - RepositoryUrlRuleHook: replace stub (always-pass) with full deny/allow rule evaluation matching UrlRuleAggregateFilter behaviour; S&F mode now enforces URL rules - StoreAndForwardReceivePackFactory: accept and wire UrlRuleFilter list + RepoRegistry so the hook can evaluate config and DB rules - GitProxyServletRegistrar: build URL rule filters for S&F path and pass alongside registry to the factory - JettyConfigurationBuilder: validate provider IDs in rules, permissions, and scm-identities at startup (crash on unknown ID); use getProviderId() instead of getName() in rule filter construction; cache provider list - UrlRuleFilter: add matchesRepo() for rule evaluation without HttpServletRequest - UrlRuleAggregateFilter: fix recordFetch to store getProviderId() not URI host - ProviderController: add `id` (type/host) field to ProviderInfo response - RepoController: validate provider ID on createRule/updateRule; use stored provider field (not URL hostname) for active repos aggregation - PushController: drop redundant ROLE_SELF_CERTIFY Spring authority check; isBypassReviewAllowed() is sufficient and was already enforcing the grant - AuthController: dynamically add ROLE_SELF_CERTIFY to /api/me response when the user has any SELF_CERTIFY permission grant (fixes UI self-certify) - Frontend dropdowns (Profile, UserDetail, Repos): submit provider ID (p.id) as value, display hostname (p.host) as label - YAML configs: update all provider references to type/host format (gitea → forgejo/gitea, github → github/github.com) - Delete InMemoryFilterConfigurationSource (dead code) - Tests: update RepoControllerTest for new validation; add IdentityVerificationMode coverage tests closes #94
1 parent 0c6222b commit 39f6887

24 files changed

Lines changed: 481 additions & 197 deletions

File tree

docker/git-proxy-docker-default.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ users:
2121
emails:
2222
- testuser@example.com
2323
scm-identities:
24-
- provider: gitea
24+
- provider: forgejo/gitea
2525
username: test-user
2626

2727
- username: user2
2828
password-hash: "{noop}Test1234!"
2929
emails:
3030
- user2@example.com
3131
scm-identities:
32-
- provider: gitea
32+
- provider: forgejo/gitea
3333
username: user2
3434

3535
- username: user3
3636
password-hash: "{noop}Test1234!"
3737
emails:
3838
- user3@example.com
3939
scm-identities:
40-
- provider: gitea
40+
- provider: forgejo/gitea
4141
username: user3
4242

4343
- username: reviewer
@@ -47,51 +47,51 @@ users:
4747
permissions:
4848
# test-user: LITERAL — only /test-owner/test-repo
4949
- username: test-user
50-
provider: gitea
50+
provider: forgejo/gitea
5151
path: /test-owner/test-repo
5252
operations: PUSH
5353

5454
# user2: GLOB — any repo under otherorg
5555
- username: user2
56-
provider: gitea
56+
provider: forgejo/gitea
5757
path: /otherorg/*
5858
path-type: GLOB
5959
operations: PUSH
6060

6161
# user3: REGEX — test-owner repos matching test-repo.*
6262
- username: user3
63-
provider: gitea
63+
provider: forgejo/gitea
6464
path: /test-owner/test-repo.*
6565
path-type: REGEX
6666
operations: PUSH
6767

6868
# reviewer: APPROVE on all the same paths
6969
- username: reviewer
70-
provider: gitea
70+
provider: forgejo/gitea
7171
path: /test-owner/test-repo
7272
operations: REVIEW
7373
- username: reviewer
74-
provider: gitea
74+
provider: forgejo/gitea
7575
path: /otherorg/*
7676
path-type: GLOB
7777
operations: REVIEW
7878

79-
# LDAP testuser (maps to gitea/test-user): same literal grant as test-user above.
79+
# LDAP testuser (maps to forgejo/gitea/test-user): same literal grant as test-user above.
8080
# When docker-default,ldap profiles are combined, GITEA_TESTUSER_TOKEN resolves to
8181
# "testuser" (the LDAP proxy user). Only LITERAL /test-owner/test-repo is granted
8282
# so that push-permission-literal.sh still passes the deny-on-other-repo case.
8383
- username: testuser
84-
provider: gitea
84+
provider: forgejo/gitea
8585
path: /test-owner/test-repo
8686
operations: PUSH
8787

8888
# admin APPROVE grants for LDAP setup (admin approves via dashboard).
8989
- username: admin
90-
provider: gitea
90+
provider: forgejo/gitea
9191
path: /test-owner/test-repo
9292
operations: REVIEW
9393
- username: admin
94-
provider: gitea
94+
provider: forgejo/gitea
9595
path: /otherorg/*
9696
path-type: GLOB
9797
operations: REVIEW
@@ -153,7 +153,7 @@ rules:
153153
- FETCH
154154
- PUSH
155155
providers:
156-
- gitea
156+
- forgejo/gitea
157157
slugs:
158158
- /test-owner/test-repo
159159
- /test-owner/test-repo-2
@@ -163,15 +163,15 @@ rules:
163163
- FETCH
164164
- PUSH
165165
providers:
166-
- gitea
166+
- forgejo/gitea
167167
owners:
168168
- otherorg
169169
- enabled: true
170170
order: 120
171171
operations:
172172
- FETCH
173173
providers:
174-
- github
174+
- github/github.com
175175
owners:
176176
- finos
177177

@@ -185,7 +185,7 @@ rules:
185185
- FETCH
186186
- PUSH
187187
providers:
188-
- gitea
188+
- forgejo/gitea
189189
slugs:
190190
- /otherorg/other-secret
191191

@@ -196,7 +196,7 @@ rules:
196196
operations:
197197
- PUSH
198198
providers:
199-
- gitea
199+
- forgejo/gitea
200200
names:
201201
- "*-readonly"
202202
- "*-archived"
@@ -208,6 +208,6 @@ rules:
208208
operations:
209209
- PUSH
210210
providers:
211-
- gitea
211+
- forgejo/gitea
212212
names:
213213
- "regex:(?i)(^|-)secret(-|$).*"

docker/git-proxy-ldap.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ users:
2929
emails:
3030
- testuser@example.com
3131
scm-identities:
32-
- provider: gitea
32+
- provider: forgejo/gitea
3333
username: test-user
3434
- username: admin
3535
password-hash: "{noop}unused"

docker/git-proxy-local.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ users:
1717
# admin can push and approve on the Gitea test repos.
1818
permissions:
1919
- username: admin
20-
provider: gitea
20+
provider: forgejo/gitea
2121
path: /test-owner/test-repo
2222
operations: PUSH_AND_REVIEW
2323
- username: admin
24-
provider: gitea
24+
provider: forgejo/gitea
2525
path: /otherorg/*
2626
path-type: GLOB
2727
operations: PUSH_AND_REVIEW

docker/git-proxy-oidc.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ users:
4545
emails:
4646
- testuser@example.com
4747
scm-identities:
48-
- provider: gitea
48+
- provider: forgejo/gitea
4949
username: test-user
5050
- username: admin
5151
password-hash: "{noop}unused"
@@ -57,20 +57,20 @@ users:
5757
# Mirrors docker-default: testuser pushes, admin approves via dashboard.
5858
permissions:
5959
- username: testuser
60-
provider: gitea
60+
provider: forgejo/gitea
6161
path: /test-owner/test-repo
6262
operations: PUSH
6363
- username: testuser
64-
provider: gitea
64+
provider: forgejo/gitea
6565
path: /otherorg/*
6666
path-type: GLOB
6767
operations: PUSH
6868
- username: admin
69-
provider: gitea
69+
provider: forgejo/gitea
7070
path: /test-owner/test-repo
7171
operations: REVIEW
7272
- username: admin
73-
provider: gitea
73+
provider: forgejo/gitea
7474
path: /otherorg/*
7575
path-type: GLOB
7676
operations: REVIEW

git-proxy-java-core/src/main/java/org/finos/gitproxy/config/InMemoryFilterConfigurationSource.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

git-proxy-java-core/src/main/java/org/finos/gitproxy/git/GitClientUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public static String formatForOperation(String title, String message, AnsiColor
177177
}
178178

179179
private static String formatTitle(String content) {
180-
return "\n\n" + content + "\n";
180+
return "\n" + content + "\n";
181181
}
182182

183183
private static String formatMessage(String content) {

0 commit comments

Comments
 (0)