Skip to content

Commit

Permalink
fix: invoke callback and complete on auth failure
Browse files Browse the repository at this point in the history
  • Loading branch information
phiz71 committed Nov 25, 2024
1 parent f9f3617 commit 121bfeb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/io/gravitee/policy/oauth2/Oauth2Policy.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public Completable authenticate(KafkaConnectionContext ctx) {
extractedToken,
Set.of(), // Scopes are fully managed by Gravitee, it is useless to extract & provide them to the Kafka security context.
(expirationTime == null ? Long.MAX_VALUE : expirationTime),
user,
user != null ? user : "unknown",
issueTime
);

Expand All @@ -189,6 +189,15 @@ public Completable authenticate(KafkaConnectionContext ctx) {
}
})
)
.onErrorResumeNext(throwable -> {
Callback[] callbacks = ctx.callbacks();
for (Callback callback : callbacks) {
if (callback instanceof OAuthBearerValidatorCallback oauthCallback) {
oauthCallback.error("invalid_token", null, null);
}
}
return Completable.complete();
})
.doAfterTerminate(() -> ctx.removeInternalAttribute(ATTR_INTERNAL_TOKEN_INTROSPECTION_RESULT));
}

Expand Down

0 comments on commit 121bfeb

Please sign in to comment.