diff --git a/impl/README.md b/impl/README.md
index 01dee15b8..1468c9bba 100644
--- a/impl/README.md
+++ b/impl/README.md
@@ -85,23 +85,24 @@ This SDK is modular by design—pull in only what you need:
* **openworkflow-impl-jackson**
👉 **Most users add this one.** Contains implementation of core features using Jackson library, like JQ expressions, JSON Schema validation, and CloudEvents (de)serialization. Internally, it is an aggregation of smaller modules:
+ * **openworkflow-impl-jq** JQ expression implementation
+ * **openworkflow-impl-model** Jackson model implementation and Jackson JWT converter for oauth2 calls.
+ * **openworkflow-impl-validation** Schema validation implementation
+ * **openworkflow-impl-lifecycle-events** Enable publication of lifecycle events as Json cloud events.
+ * **openworkflow-impl-function** Jackson Function support.
+ * **openworkflow-impl-json** Jackson common utilities shared by all modules in this list
+ * **openworkflow-impl-cron** Cron parsing for workflow scheduled execution
+ * **openworkflow-impl-openapi** Deserialization support of OpenAPI schemas using Jackson (required for OpenAPI call task to work)
- * **openworkflow-impl-jq** JQ expression implementation
- * **openworkflow-impl-model** Jackson model implementation
- * **openworkflow-impl-validation** Schema validation implementation
- * **openworkflow-impl-lifecycle-events** Enable publication of lifecycle events as Json cloud events.
- * **openworkflow-impl-function** Jackson Function support.
- * **openworkflow-impl-json** Jackson common utilities shared by all modules in this list
- * **openworkflow-impl-cron** Cron parsing for workflow scheduled execution
- Additionally, The OpenWokflow specification defines a set of [call task](https://github.com/open-workflow-specification/specification/blob/main/dsl-reference.md#call), which requires additional dependencies, with the exception of HTTP (see section below). You might add those ones needed depending on the feature you are using in your definition:
+Additionally, The OpenWokflow specification defines a set of [call task](https://github.com/open-workflow-specification/specification/blob/main/dsl-reference.md#call), which requires additional dependencies, with the exception of HTTP (see section below). You might add those ones needed depending on the feature you are using in your definition:
+
- * **openworkflow-impl-openapi** OpenAPI support using Jackson
- * **openworkflow-impl-openapi-base** Base OpenAPI support intended to be extended for a specific JSON library
* **openworkflow-impl-grpc** gRPC support
* **openworkflow-impl-script-python** Python support
* **openworkflow-impl-script-js** Javascript support
- * **openworkflow-impl-container** Docker container support
+ * **openworkflow-impl-container** Docker container support
+ * **openworkflow-impl-a2a** A2A protocol support.
There are also companion modules/docs for:
@@ -111,12 +112,12 @@ There are also companion modules/docs for:
### Http dependencies
-By default, the SDK reference implementation use `java.net.HttpRequest` to support Http calls. Therefore, no dependency needs to be added for using Http Call task or downloading of http resources, like OpenAPI schemas.
+By default, the SDK reference implementation use `java.net.HttpRequest` to support Http/OpenAPI calls. Therefore, no dependency (besides the jackson modules described above) needs to be added for using Http Call task or downloading http resources.
However, for further configuration of Http functionality, users might include the Jakarta based modules, which will allow customizing `jakarta.ws.rs.client.Client` in Jakarta EE environments.
* **openworkflow-impl-http** HTTP `Call` task handler, based on JAX-RS client
- * **openworkflow-impl-jackson-jwt** Optimized entity converter for Jackson model and OAuth2/OIDC helpers for Jakarta HTTP calls.
+ * **openworkflow-impl-http-jackson** Optimized entity converter for Jackson model
---
@@ -131,25 +132,12 @@ However, for further configuration of Http functionality, users might include th
openworkflow-impl-jackson
-
-
- org.openworkflow.sdk
- openworkflow-impl-http
-
-
-
-
- org.openworkflow.sdk
- openworkflow-impl-jackson-jwt
-
```
### Gradle (Kotlin/Groovy)
```gradle
implementation("org.openworkflow.sdk:openworkflow-impl-jackson")
-implementation("org.openworkflow.sdk:openworkflow-impl-http") // if using HTTP
-implementation("org.openworkflow.sdk:openworkflow-impl-jackson-jwt") // if using OAuth2/OIDC
```
> Requires **Java 21+**.
diff --git a/impl/core/pom.xml b/impl/core/pom.xml
index 1001d74f7..a6fc68270 100644
--- a/impl/core/pom.xml
+++ b/impl/core/pom.xml
@@ -40,4 +40,19 @@
test
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowUtils.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowUtils.java
index 412e6feac..e319f09fa 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowUtils.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/WorkflowUtils.java
@@ -319,7 +319,7 @@ public static WorkflowValueResolver getURISupplier(
return (w, t, n) ->
application
.templateResolver()
- .resolveTemplates(template.getLiteralUriTemplate(), w, t, n);
+ .resolveTemplates(template.getLiteralUriTemplate(), n.asMap().orElse(Map.of()));
}
throw new IllegalArgumentException("Invalid uritemplate definition " + template);
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AbstractAuthRequestBuilder.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AbstractAuthRequestBuilder.java
index 4c5af4b15..bc2e7c8af 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AbstractAuthRequestBuilder.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AbstractAuthRequestBuilder.java
@@ -47,7 +47,7 @@ abstract class AbstractAuthRequestBuilder
implements AuthRequestBuilder {
protected final WorkflowApplication application;
- protected final HttpRequestInfoBuilder requestBuilder = new HttpRequestInfoBuilder();
+ protected final AuthHttpRequestInfoBuilder requestBuilder = new AuthHttpRequestInfoBuilder();
public AbstractAuthRequestBuilder(WorkflowApplication application) {
this.application = application;
@@ -55,6 +55,7 @@ public AbstractAuthRequestBuilder(WorkflowApplication application) {
@Override
public AuthHttpRequestInfo apply(T authenticationData) {
+ requestBuilder.withIssuers(authenticationData.getIssuers());
requestEncoding(authenticationData);
authenticationURI(authenticationData);
audience(authenticationData);
@@ -66,6 +67,7 @@ public AuthHttpRequestInfo apply(T authenticationData) {
@Override
public AuthHttpRequestInfo apply(Map secret) {
+ requestBuilder.withIssuers((String) secret.get("issuers"));
requestEncoding(secret);
authenticationURI(secret);
audience(secret);
@@ -194,10 +196,7 @@ void requestEncoding(T authenticationData) {
void requestEncoding(Map secret) {
Map request = (Map) secret.get(REQUEST);
- String encoding = (String) request.get(ENCODING);
- if (isValid(encoding)) {
- requestBuilder.addHeader("Content-Type", encoding);
- }
+ requestBuilder.withContentType((String) request.get(ENCODING));
}
protected abstract void authenticationURI(T authenticationData);
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java
index 75cc9c9ab..dac605d9d 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProvider.java
@@ -15,10 +15,82 @@
*/
package org.openworkflow.sdk.impl.auth;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
import org.openworkflow.sdk.impl.TaskContext;
+import org.openworkflow.sdk.impl.WorkflowApplication;
import org.openworkflow.sdk.impl.WorkflowContext;
+import org.openworkflow.sdk.impl.http.WorkflowHttpContentType;
+import org.openworkflow.sdk.impl.http.WorkflowHttpRequestHelper;
+import org.openworkflow.sdk.impl.http.WorkflowHttpRequestInfo;
-public interface AccessTokenProvider {
- CompletableFuture validateAndGet(WorkflowContext workflow, TaskContext context);
+class AccessTokenProvider {
+
+ private final WorkflowApplication app;
+ private final Supplier requestInfoSupplier;
+ private final JWTConverter jwtConverter;
+
+ AccessTokenProvider(
+ WorkflowApplication app,
+ Supplier requestInfoSupplier,
+ JWTConverter jwtConverter) {
+ this.app = app;
+ this.requestInfoSupplier = requestInfoSupplier;
+ this.jwtConverter = jwtConverter;
+ }
+
+ public CompletableFuture validateAndGet(WorkflowContext workflow, TaskContext context) {
+ AuthHttpRequestInfo authRequestInfo = requestInfoSupplier.get();
+ WorkflowHttpRequestInfo httpRequestInfo =
+ buildHttpRequestInfo(workflow, context, authRequestInfo);
+ CompletableFuture future =
+ WorkflowHttpRequestHelper.executeRequest(httpRequestInfo, app, workflow, context)
+ .thenApply(bytes -> jwtConverter.fromToken(bytes));
+ List issuers = authRequestInfo.issuers();
+ if (!issuers.isEmpty()) {
+ future =
+ future.whenComplete(
+ (jwt, ex) -> {
+ if (jwt != null) {
+ jwt.issuer()
+ .ifPresent(
+ issuer -> {
+ if (!issuers.contains(issuer)) {
+ throw new IllegalStateException(
+ "Token issuer is not valid: " + issuer);
+ }
+ });
+ }
+ });
+ }
+ return future;
+ }
+
+ private WorkflowHttpRequestInfo buildHttpRequestInfo(
+ WorkflowContext workflow, TaskContext task, AuthHttpRequestInfo requestInfo) {
+ WorkflowHttpRequestInfo.Builder builder = WorkflowHttpRequestInfo.builder("POST");
+ Map headers = new LinkedHashMap<>();
+ headers.put("grant_type", requestInfo.grantType());
+ headers.put("User-Agent", "OAuth2-Client-Credentials/1.0");
+ headers.put("Cache-Control", "no-cache");
+ headers.put("Accept", "application/json");
+ for (var entry : requestInfo.headers().entrySet()) {
+ headers.put(entry.getKey(), entry.getValue().apply(workflow, task));
+ }
+ headers.put(WorkflowHttpContentType.HEADER_NAME, requestInfo.contentType().toString());
+ builder.headers(headers);
+ Map body = new HashMap();
+ body.put("grant_type", requestInfo.grantType());
+ requestInfo.queryParams().forEach((key, value) -> body.put(key, value.apply(workflow, task)));
+ requestInfo
+ .clientAuthParams()
+ .forEach((key, value) -> body.put(key, value.apply(workflow, task)));
+ return builder
+ .body(app.modelFactory().from(body))
+ .build(requestInfo.uri().apply(workflow, task));
+ }
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProviderFactory.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProviderFactory.java
deleted file mode 100644
index a6f24b3b8..000000000
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AccessTokenProviderFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2020-Present The Open Workflow Specification Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openworkflow.sdk.impl.auth;
-
-import java.util.List;
-import org.openworkflow.sdk.impl.ServicePriority;
-import org.openworkflow.sdk.impl.WorkflowApplication;
-
-public interface AccessTokenProviderFactory
- extends ServicePriority, AutoCloseable {
-
- AccessTokenProvider build(
- WorkflowApplication app,
- AuthHttpRequestInfo requestInfo,
- List issuers,
- JWTConverter converter);
-
- default void close() {}
-}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfo.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfo.java
index c3e119eaf..45314f7a0 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfo.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfo.java
@@ -16,9 +16,11 @@
package org.openworkflow.sdk.impl.auth;
import java.net.URI;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.openworkflow.sdk.impl.WorkflowValueResolver;
+import org.openworkflow.sdk.impl.http.WorkflowHttpContentType;
public record AuthHttpRequestInfo(
Map> headers,
@@ -28,4 +30,5 @@ public record AuthHttpRequestInfo(
Optional> revocationUri,
Optional> introspectionUri,
String grantType,
- String contentType) {}
+ WorkflowHttpContentType contentType,
+ List issuers) {}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/HttpRequestInfoBuilder.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfoBuilder.java
similarity index 59%
rename from impl/core/src/main/java/org/openworkflow/sdk/impl/auth/HttpRequestInfoBuilder.java
rename to impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfoBuilder.java
index 740c8cd16..8e50d70ec 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/HttpRequestInfoBuilder.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/AuthHttpRequestInfoBuilder.java
@@ -15,17 +15,18 @@
*/
package org.openworkflow.sdk.impl.auth;
-import static org.openworkflow.sdk.api.types.OAuth2TokenRequest.Oauth2TokenRequestEncoding.APPLICATION_X_WWW_FORM_URLENCODED;
-
import java.net.URI;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import org.openworkflow.sdk.api.types.OAuth2TokenRequest;
import org.openworkflow.sdk.impl.WorkflowValueResolver;
+import org.openworkflow.sdk.impl.http.WorkflowHttpContentType;
-class HttpRequestInfoBuilder {
+class AuthHttpRequestInfoBuilder {
private Map> headers;
@@ -41,75 +42,85 @@ class HttpRequestInfoBuilder {
private String grantType;
- private String contentType;
+ private WorkflowHttpContentType contentType;
+
+ private List issuers;
- HttpRequestInfoBuilder() {
+ AuthHttpRequestInfoBuilder() {
headers = new HashMap<>();
queryParams = new HashMap<>();
clientAuthParams = new HashMap<>();
}
- HttpRequestInfoBuilder addHeader(String key, String token) {
+ AuthHttpRequestInfoBuilder addHeader(String key, String token) {
headers.put(key, (w, t, m) -> token);
return this;
}
- HttpRequestInfoBuilder addHeader(String key, WorkflowValueResolver token) {
+ AuthHttpRequestInfoBuilder addHeader(String key, WorkflowValueResolver token) {
headers.put(key, token);
return this;
}
- HttpRequestInfoBuilder addQueryParam(String key, String token) {
+ AuthHttpRequestInfoBuilder addQueryParam(String key, String token) {
queryParams.put(key, (w, t, m) -> token);
return this;
}
- HttpRequestInfoBuilder addQueryParam(String key, WorkflowValueResolver token) {
+ AuthHttpRequestInfoBuilder addQueryParam(String key, WorkflowValueResolver token) {
queryParams.put(key, token);
return this;
}
- HttpRequestInfoBuilder addClientAuthParam(String key, String token) {
+ AuthHttpRequestInfoBuilder addClientAuthParam(String key, String token) {
clientAuthParams.put(key, (w, t, m) -> token);
return this;
}
- HttpRequestInfoBuilder addClientAuthParam(String key, WorkflowValueResolver token) {
+ AuthHttpRequestInfoBuilder addClientAuthParam(String key, WorkflowValueResolver token) {
clientAuthParams.put(key, token);
return this;
}
- HttpRequestInfoBuilder withUri(WorkflowValueResolver uri) {
+ AuthHttpRequestInfoBuilder withUri(WorkflowValueResolver uri) {
this.uri = uri;
return this;
}
- HttpRequestInfoBuilder withRevocationUri(Optional> revocationUri) {
+ AuthHttpRequestInfoBuilder withRevocationUri(Optional> revocationUri) {
this.revocationUri = revocationUri;
return this;
}
- HttpRequestInfoBuilder withIntrospectionUri(
+ AuthHttpRequestInfoBuilder withIssuers(List issuers) {
+ this.issuers = issuers;
+ return this;
+ }
+
+ AuthHttpRequestInfoBuilder withIssuers(String issuers) {
+ this.issuers = issuers == null ? null : Arrays.asList(issuers.split(","));
+ return this;
+ }
+
+ AuthHttpRequestInfoBuilder withIntrospectionUri(
Optional> introspectionUri) {
this.introspectionUri = introspectionUri;
return this;
}
- HttpRequestInfoBuilder withContentType(OAuth2TokenRequest oAuth2TokenRequest) {
+ AuthHttpRequestInfoBuilder withContentType(OAuth2TokenRequest oAuth2TokenRequest) {
if (oAuth2TokenRequest != null) {
- this.contentType = oAuth2TokenRequest.getEncoding().value();
+ this.contentType = WorkflowHttpContentType.fromValue(oAuth2TokenRequest.getEncoding());
}
return this;
}
- HttpRequestInfoBuilder withContentType(String contentType) {
- if (contentType != null) {
- this.contentType = contentType;
- }
+ AuthHttpRequestInfoBuilder withContentType(String contentType) {
+ this.contentType = WorkflowHttpContentType.fromValue(contentType);
return this;
}
- HttpRequestInfoBuilder withGrantType(String grantType) {
+ AuthHttpRequestInfoBuilder withGrantType(String grantType) {
this.grantType = grantType;
return this;
}
@@ -117,9 +128,6 @@ HttpRequestInfoBuilder withGrantType(String grantType) {
AuthHttpRequestInfo build() {
Objects.requireNonNull(uri, "URI must be set before building the request");
Objects.requireNonNull(grantType, "Grant type must be set before building the request");
- if (contentType == null) {
- contentType = APPLICATION_X_WWW_FORM_URLENCODED.value();
- }
return new AuthHttpRequestInfo(
headers,
queryParams,
@@ -128,6 +136,9 @@ AuthHttpRequestInfo build() {
revocationUri,
introspectionUri,
grantType,
- contentType);
+ contentType == null
+ ? WorkflowHttpContentType.APPLICATION_X_WWW_FORM_URLENCODED
+ : contentType,
+ issuers == null ? List.of() : issuers);
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretBasic.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretBasic.java
index 3053b5afc..8ed4f2ad8 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretBasic.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretBasic.java
@@ -31,7 +31,7 @@
class ClientSecretBasic extends ClientSecretHandler {
protected ClientSecretBasic(
- WorkflowApplication application, HttpRequestInfoBuilder requestBuilder) {
+ WorkflowApplication application, AuthHttpRequestInfoBuilder requestBuilder) {
super(application, requestBuilder);
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretHandler.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretHandler.java
index c80df8021..3b7f2ab40 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretHandler.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretHandler.java
@@ -28,10 +28,10 @@
abstract class ClientSecretHandler {
protected final WorkflowApplication application;
- protected final HttpRequestInfoBuilder requestBuilder;
+ protected final AuthHttpRequestInfoBuilder requestBuilder;
protected ClientSecretHandler(
- WorkflowApplication application, HttpRequestInfoBuilder requestBuilder) {
+ WorkflowApplication application, AuthHttpRequestInfoBuilder requestBuilder) {
this.application = application;
this.requestBuilder = requestBuilder;
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretPost.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretPost.java
index 8e05722df..9361d7dab 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretPost.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/ClientSecretPost.java
@@ -30,7 +30,7 @@
class ClientSecretPost extends ClientSecretHandler {
protected ClientSecretPost(
- WorkflowApplication application, HttpRequestInfoBuilder requestBuilder) {
+ WorkflowApplication application, AuthHttpRequestInfoBuilder requestBuilder) {
super(application, requestBuilder);
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/CommonOAuthProvider.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/CommonOAuthProvider.java
index 768e23424..fce2cd510 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/CommonOAuthProvider.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/CommonOAuthProvider.java
@@ -19,7 +19,6 @@
import static org.openworkflow.sdk.impl.WorkflowUtils.secret;
import java.net.URI;
-import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import org.openworkflow.sdk.api.types.OAuth2AuthenticationData;
@@ -28,20 +27,19 @@
import org.openworkflow.sdk.impl.TaskContext;
import org.openworkflow.sdk.impl.WorkflowApplication;
import org.openworkflow.sdk.impl.WorkflowContext;
-import org.openworkflow.sdk.impl.WorkflowValueResolver;
public abstract class CommonOAuthProvider implements AuthProvider {
- private final WorkflowValueResolver tokenProvider;
+ private final AccessTokenProvider tokenProvider;
- protected CommonOAuthProvider(WorkflowValueResolver tokenProvider) {
+ protected CommonOAuthProvider(AccessTokenProvider tokenProvider) {
this.tokenProvider = tokenProvider;
}
@Override
public CompletableFuture content(
WorkflowContext workflow, TaskContext task, URI uri, String method) {
- return tokenProvider.apply(workflow, task).validateAndGet(workflow, task).thenApply(JWT::token);
+ return tokenProvider.validateAndGet(workflow, task).thenApply(JWT::token);
}
@Override
@@ -54,7 +52,7 @@ protected static OAuth2AuthenticationData fillFromMap(
return data;
}
- protected static WorkflowValueResolver accessToken(
+ protected static AccessTokenProvider accessToken(
WorkflowApplication app,
Workflow workflow,
OAuth2AuthenticationData authenticationData,
@@ -68,31 +66,20 @@ protected static WorkflowValueResolver accessToken(
throw new IllegalStateException("Both policy and secret are null");
}
- private static WorkflowValueResolver build(
+ private static AccessTokenProvider build(
OAuth2AuthenticationData authenticationData,
- AuthRequestBuilder authBuilder,
+ AuthRequestBuilder authBuilder,
WorkflowApplication app) {
- AccessTokenProvider tokenProvider =
- app.serviceLoadedClass(AccessTokenProviderFactory.class)
- .build(
- app,
- authBuilder.apply(authenticationData),
- authenticationData.getIssuers(),
- app.serviceLoadedClass(JWTConverter.class));
- return (w, t, m) -> tokenProvider;
+ final AuthHttpRequestInfo requestInfo = authBuilder.apply((T) authenticationData);
+ return new AccessTokenProvider(
+ app, () -> requestInfo, app.serviceLoadedClass(JWTConverter.class));
}
- private static WorkflowValueResolver build(
- String secretName, AuthRequestBuilder authBuilder, WorkflowApplication app) {
- return (w, t, m) -> {
- Map secret = secret(app, secretName);
- String issuers = (String) secret.get("issuers");
- return app.serviceLoadedClass(AccessTokenProviderFactory.class)
- .build(
- app,
- authBuilder.apply(secret),
- issuers != null ? Arrays.asList(issuers.split(",")) : null,
- app.serviceLoadedClass(JWTConverter.class));
- };
+ private static AccessTokenProvider build(
+ String secretName, AuthRequestBuilder authBuilder, WorkflowApplication app) {
+ return new AccessTokenProvider(
+ app,
+ () -> authBuilder.apply(secret(app, secretName)),
+ app.serviceLoadedClass(JWTConverter.class));
}
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JWTConverter.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JWTConverter.java
index 30f9a9869..be59aa66c 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JWTConverter.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JWTConverter.java
@@ -20,10 +20,10 @@
public interface JWTConverter extends ServicePriority {
/**
- * Converts a JWT token string into a JWT object.
+ * Converts an Oauth2 Http response into a JWT object.
*
- * @param token the JWT token string
+ * @param token the oauth2 response as byte[]
* @return a JWT object containing the token and its claims
*/
- JWT fromToken(String token) throws IllegalArgumentException;
+ JWT fromToken(byte[] token) throws IllegalArgumentException;
}
diff --git a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JwtClientAssertion.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JwtClientAssertion.java
index 2000f6de5..d17e0d5bb 100644
--- a/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JwtClientAssertion.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/auth/JwtClientAssertion.java
@@ -43,7 +43,7 @@
class JwtClientAssertion extends ClientSecretHandler {
protected JwtClientAssertion(
- WorkflowApplication application, HttpRequestInfoBuilder requestBuilder) {
+ WorkflowApplication application, AuthHttpRequestInfoBuilder requestBuilder) {
super(application, requestBuilder);
}
diff --git a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
similarity index 92%
rename from impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
rename to impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
index d49d154a0..5f10044da 100644
--- a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutor.java
@@ -93,19 +93,20 @@ private void fillHttpBuilder(WorkflowApplication application, OperationDefinitio
Map headers = new HashMap<>();
Map queryMap = new HashMap<>();
Map pathParameters = new HashMap<>();
+ Set mandatoryParameters = new HashSet<>();
Set missingParams = new HashSet<>();
boolean hasBody = operation.getOperation().hasRequestBody();
Map bodyParameters = new HashMap<>(parameters);
for (ParameterDefinition parameter : operation.getParameters()) {
switch (parameter.in()) {
case "header":
- param(parameter, bodyParameters, headers, missingParams);
+ param(parameter, bodyParameters, headers, missingParams, mandatoryParameters);
break;
case "path":
- param(parameter, bodyParameters, pathParameters, missingParams);
+ param(parameter, bodyParameters, pathParameters, missingParams, mandatoryParameters);
break;
case "query":
- param(parameter, bodyParameters, queryMap, missingParams);
+ param(parameter, bodyParameters, queryMap, missingParams, mandatoryParameters);
break;
case "body":
hasBody = true;
@@ -125,18 +126,25 @@ private void fillHttpBuilder(WorkflowApplication application, OperationDefinitio
.withQueryMap(!queryMap.isEmpty() ? queryMap : null)
.withHeaders(!headers.isEmpty() ? headers : null)
.withMethod(operation.getMethod())
- .withPath(new OperationPathResolver(operation.getPath(), application, pathParameters));
+ .withPath(
+ new OperationPathResolver(
+ operation.getPath(), application, pathParameters, mandatoryParameters));
}
private void param(
ParameterDefinition parameter,
Map origMap,
Map collectorMap,
- Set missingParams) {
+ Set missingParams,
+ Set mandatoryParams) {
String name = parameter.name();
+ boolean isRequired = parameter.required();
+ if (isRequired) {
+ mandatoryParams.add(name);
+ }
if (origMap.containsKey(name)) {
collectorMap.put(parameter.name(), origMap.remove(name));
- } else if (parameter.required()) {
+ } else if (isRequired) {
UnifiedOpenAPI.Schema schema = parameter.schema();
Object defaultValue = schema != null ? schema._default() : null;
if (defaultValue != null) {
diff --git a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java
similarity index 100%
rename from impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java
rename to impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIExecutorBuilder.java
diff --git a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java
similarity index 100%
rename from impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java
rename to impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OpenAPIProcessor.java
diff --git a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java
similarity index 100%
rename from impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java
rename to impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationDefinition.java
diff --git a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationPathResolver.java b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationPathResolver.java
similarity index 59%
rename from impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationPathResolver.java
rename to impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationPathResolver.java
index 57a3a5113..33fbb2277 100644
--- a/impl/openapi/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationPathResolver.java
+++ b/impl/core/src/main/java/org/openworkflow/sdk/impl/executors/openapi/OperationPathResolver.java
@@ -15,9 +15,11 @@
*/
package org.openworkflow.sdk.impl.executors.openapi;
-import jakarta.ws.rs.core.UriBuilder;
import java.net.URI;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
import org.openworkflow.sdk.impl.TaskContext;
import org.openworkflow.sdk.impl.WorkflowApplication;
import org.openworkflow.sdk.impl.WorkflowContext;
@@ -28,16 +30,33 @@
class OperationPathResolver implements WorkflowValueResolver {
private final String path;
private final WorkflowValueResolver