-
Notifications
You must be signed in to change notification settings - Fork 9
Prepare 1.5.0 #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Prepare 1.5.0 #84
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,14 +77,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) | |||||||||||||
| @Override | ||||||||||||||
| public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException | ||||||||||||||
| { | ||||||||||||||
| // Only response.body() is available in OkHttp; ensure it is closed and consumed only once to prevent resource leaks. | ||||||||||||||
| // The body of the response can be in `body()` for success cases or in `errorBody()` for error cases. | ||||||||||||||
| // We need to handle both and ensure the body is closed to prevent resource leaks. | ||||||||||||||
| // The body can only be consumed once. | ||||||||||||||
|
Comment on lines
+80
to
82
|
||||||||||||||
| // The body of the response can be in `body()` for success cases or in `errorBody()` for error cases. | |
| // We need to handle both and ensure the body is closed to prevent resource leaks. | |
| // The body can only be consumed once. | |
| // For OkHttp, the response body is always available via `body()`, regardless of HTTP status. | |
| // We must ensure the body is closed to prevent resource leaks, and it can only be consumed once. | |
| // Using try-with-resources guarantees the body is properly closed after reading. |
Copilot
AI
Mar 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will log the full response body for all endpoints not in logExcludedEndpoints(). Since /auth is not excluded by default (and returns JWT/token material), this can leak sensitive credentials into logs. Please re-add an explicit /auth exclusion (or add it to the default excluded list) and/or redact tokens before logging.
| if (!privacyIDEA.logExcludedEndpoints().contains(path)) | |
| if (!privacyIDEA.logExcludedEndpoints().contains(path) && !ENDPOINT_AUTH.equals(path)) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,11 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.Gson; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.GsonBuilder; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.JsonDeserializationContext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.JsonDeserializer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.JsonElement; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.google.gson.JsonObject; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.lang.reflect.Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.ArrayList; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.function.Predicate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -84,10 +89,11 @@ public boolean authenticationSuccessful() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public boolean pushAvailable() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return multiChallenge.stream().anyMatch(c -> isPushOrSmartphoneContainer(c.getType())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return multiChallenge.stream().anyMatch(c -> isPushOrSmartphoneContainer(c.getType()) && "poll".equals(c.getClientMode())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return multiChallenge.stream().anyMatch(c -> isPushOrSmartphoneContainer(c.getType()) && "poll".equals(c.getClientMode())); | |
| if (multiChallenge == null || multiChallenge.isEmpty()) | |
| { | |
| return false; | |
| } | |
| return multiChallenge.stream().anyMatch(c -> { | |
| if (!isPushOrSmartphoneContainer(c.getType())) | |
| { | |
| return false; | |
| } | |
| String clientMode = c.getClientMode(); | |
| if (clientMode == null || clientMode.isEmpty()) | |
| { | |
| // Fall back to the response's preferred client mode when per-challenge clientMode is missing | |
| return "poll".equals(preferredClientMode); | |
| } | |
| return "poll".equals(clientMode); | |
| }); |
Copilot
AI
Mar 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otpMessage() now filters challenges by clientMode == "interactive". In existing responses/fixtures, client_mode is often absent for OTP challenges (parsed as empty string), which would make otpMessage() return an empty message even when OTP challenges exist. Consider keeping the previous logic (exclude push/smartphone/webauthn) or falling back to preferredClientMode / treating missing client_mode as interactive for OTP challenges.
| String cm = c.getClientMode(); | |
| System.out.println( | |
| "challenge for " + c.getType() + " " + c.getSerial() + " with mode: " + cm); | |
| boolean yes = "interactive".equals(cm); | |
| return yes; | |
| String clientMode = c.getClientMode(); | |
| String type = c.getType(); | |
| // If client_mode is explicitly "interactive", this is an OTP-style interactive challenge. | |
| if ("interactive".equals(clientMode)) | |
| { | |
| return true; | |
| } | |
| // For legacy responses where client_mode is missing or empty, fall back to the | |
| // previous behavior: include all non-push / non-smartphone / non-webauthn challenges. | |
| if (clientMode == null || clientMode.trim().isEmpty()) | |
| { | |
| if (isPushOrSmartphoneContainer(type) || TOKEN_TYPE_WEBAUTHN.equals(type)) | |
| { | |
| return false; | |
| } | |
| return true; | |
| } | |
| // Any other explicit client_mode is not considered an OTP-input challenge. | |
| return false; |
Copilot
AI
Mar 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Library code should not write directly to stdout. The System.out.println(...) debug output in otpMessage() will spam application logs and may leak token/challenge details; please remove it or route it through the configured logger behind a debug flag.
| return reduceChallengeMessagesWhere(c -> | |
| { | |
| String cm = c.getClientMode(); | |
| System.out.println( | |
| "challenge for " + c.getType() + " " + c.getSerial() + " with mode: " + cm); | |
| boolean yes = "interactive".equals(cm); | |
| return yes; | |
| }); | |
| return reduceChallengeMessagesWhere(c -> "interactive".equals(c.getClientMode())); |
Copilot
AI
Mar 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder in Java 14 (per pom.xml) does not have an isEmpty() method, so this will not compile. Use sb.length() > 0 (or check the appended string) before deleting the trailing separator.
| if (!sb.isEmpty()) | |
| if (sb.length() > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting Surefire’s
<skipTests>totruedisables unit tests for all builds, which makes it easy to ship regressions (especially for a release bump). If the intent is only to speed up local packaging, consider removing this change or gating it behind a Maven profile / CI property instead of committing it as the default.