Skip to content

Commit f7ae7f5

Browse files
coopernetesclaude
andcommitted
fix: skip push permission check when no identity resolver is configured
CheckUserPushPermissionHook was blocking all pushes in open mode (no users configured) because a null identityResolver returned Optional.empty(), which fell through to the "user not registered" error path. Add an early return when identityResolver is null, consistent with DummyUserAuthorizationService's open/permissive behaviour. Fixes the two failing e2eTest cases in StoreForwardModeE2ETest. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5735791 commit f7ae7f5

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
6161
String pushUser = config.getString("gitproxy", null, "pushUser");
6262
String pushToken = config.getString("gitproxy", null, "pushToken");
6363

64+
if (identityResolver == null) {
65+
log.debug("No identity resolver configured (open mode), skipping permission check");
66+
pushContext.addStep(PushStep.builder()
67+
.stepName("checkUserPermission")
68+
.stepOrder(ORDER)
69+
.status(StepStatus.PASS)
70+
.build());
71+
return;
72+
}
73+
6474
if (pushUser == null || pushUser.isEmpty()) {
6575
log.debug("No push user found in repo config, skipping permission check");
6676
pushContext.addStep(PushStep.builder()

jgit-proxy-core/src/test/java/org/finos/gitproxy/git/CheckUserPushPermissionHookTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ void resolvedAndAuthorized_recordsPass() throws Exception {
167167
assertEquals(StepStatus.PASS, pushContext.getSteps().get(0).getStatus());
168168
}
169169

170-
// ---- null resolver (open mode) → treated same as resolver returning empty ----
170+
// ---- null resolver (open mode) → always passes, credentials are ignored ----
171171

172172
@Test
173-
void nullResolver_withPushUser_addsNotRegisteredIssue() throws Exception {
173+
void nullResolver_withPushUser_passesInOpenMode() throws Exception {
174174
repo.getConfig().setString("gitproxy", null, "pushUser", "anyone");
175175
repo.getConfig().save();
176176

@@ -181,11 +181,14 @@ void nullResolver_withPushUser_addsNotRegisteredIssue() throws Exception {
181181
PushContext pushContext = new PushContext();
182182
ValidationContext validationContext = new ValidationContext();
183183

184-
// Explicit null resolver
184+
// Null resolver = open mode: any push passes regardless of credentials
185185
new CheckUserPushPermissionHook(null, authService, validationContext, pushContext)
186186
.onPreReceive(rp, List.of(cmd));
187187

188-
assertTrue(validationContext.hasIssues(), "Null resolver should still block — no way to verify identity");
188+
assertFalse(
189+
validationContext.hasIssues(), "Null resolver (open mode) should pass — no identity check configured");
190+
assertFalse(pushContext.getSteps().isEmpty());
191+
assertEquals(StepStatus.PASS, pushContext.getSteps().get(0).getStatus());
189192
}
190193

191194
// ---- providerName is passed through to resolver ----

0 commit comments

Comments
 (0)