Skip to content

Commit

Permalink
Fix users cannot access public admin HTTP endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesChenX committed Nov 21, 2024
1 parent e887b2f commit d4aa686
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ public Mono<Long> authenticate(
+ HttpHeaderNames.AUTHORIZATION
+ "\"")));
}
return adminService.authenticate(credentials.first(), credentials.second())
.flatMap(id -> adminService
Mono<Long> authenticate =
adminService.authenticate(credentials.first(), credentials.second())
.switchIfEmpty(UNAUTHENTICATED);
return permission == null
? authenticate
: authenticate.flatMap(id -> adminService
.isAdminAuthorized(params, paramValues, id, permission.value())
.flatMap(authorized -> {
if (authorized) {
return Mono.just(id);
}
return Mono.error(new HttpResponseException(
HttpHandlerResult
.unauthorized("Unauthorized to access the resource: "
+ permission.value())));
}))
.switchIfEmpty(UNAUTHENTICATED);
.flatMap(authorized -> authorized
? Mono.just(id)
: Mono.error(new HttpResponseException(
HttpHandlerResult.unauthorized(
"Unauthorized to access the resource: "
+ permission.value())))));
}

@Nullable
Expand Down

0 comments on commit d4aa686

Please sign in to comment.