Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
- Add support for Druid 35.0.1 ([#138]).
- Add support for Druid 34.0.0 (deprecated) ([#134], [#138]).

### Fixed

- Reuse HttpClient instance across authorize() calls ([#143]).

### Removed

- Remove support for Druid 33.0.0 ([#138]).
- Remove support for Druid 31.0.1 ([#134]).

[#134]: https://github.com/stackabletech/druid-opa-authorizer/pull/134
[#138]: https://github.com/stackabletech/druid-opa-authorizer/pull/138
[#143]: https://github.com/stackabletech/druid-opa-authorizer/pull/143

## [0.7.0] - 2025-05-31

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public class OpaAuthorizer implements Authorizer {
private static final Logger LOG = new Logger(OpaAuthorizer.class);
private final String opaUri;
private final ObjectMapper objectMapper;
private final HttpClient httpClient;

@JsonCreator
public OpaAuthorizer(@JsonProperty("name") String name, @JsonProperty("opaUri") String opaUri) {
this.opaUri = opaUri;
this.httpClient = HttpClient.newHttpClient();
objectMapper =
new ObjectMapper()
// https://github.com/stackabletech/druid-opa-authorizer/issues/72
Expand All @@ -53,8 +55,7 @@ public Access authorize(
return new Access(false, "Failed to create the OPA request JSON: " + e);
}

LOG.trace("Creating HTTP Client and executing post.");
var client = HttpClient.newHttpClient();
LOG.trace("Executing OPA post.");
try {
var request =
HttpRequest.newBuilder()
Expand All @@ -63,7 +64,7 @@ public Access authorize(
.POST(HttpRequest.BodyPublishers.ofString(msgJson))
.build();

var response = client.send(request, HttpResponse.BodyHandlers.ofString());
var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());

LOG.debug("OPA Response code: %s - %s", response.statusCode(), response.body());
LOG.trace("Parsing OPA response.");
Expand Down
Loading