Skip to content

Commit d758ecf

Browse files
committed
Remove introspection and revoke
Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
1 parent 89fa073 commit d758ecf

3 files changed

Lines changed: 0 additions & 153 deletions

File tree

impl/core/src/main/java/io/serverlessworkflow/impl/auth/AccessTokenProvider.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,4 @@
2121

2222
public interface AccessTokenProvider {
2323
JWT validateAndGet(WorkflowContext workflow, TaskContext context, WorkflowModel model);
24-
25-
/**
26-
* Introspects the given token against the configured introspection endpoint, as defined by <a
27-
* href="https://www.rfc-editor.org/rfc/rfc7662">RFC 7662</a>.
28-
*
29-
* <p>This is an optional capability. The default implementation throws {@link
30-
* UnsupportedOperationException}; providers backed by an introspection-capable OIDC client should
31-
* override it.
32-
*
33-
* @param tokenTypeHint optional {@code token_type_hint} (e.g. {@code access_token}), may be
34-
* {@code null}
35-
*/
36-
default TokenIntrospection introspect(
37-
WorkflowContext workflow,
38-
TaskContext context,
39-
WorkflowModel model,
40-
String token,
41-
String tokenTypeHint) {
42-
throw new UnsupportedOperationException(
43-
"Token introspection is not supported by this provider");
44-
}
45-
46-
/**
47-
* Revokes the given token against the configured revocation endpoint, as defined by <a
48-
* href="https://www.rfc-editor.org/rfc/rfc7009">RFC 7009</a>.
49-
*
50-
* <p>This is an optional capability. The default implementation throws {@link
51-
* UnsupportedOperationException}; providers backed by a revocation-capable OIDC client should
52-
* override it.
53-
*
54-
* @param tokenTypeHint optional {@code token_type_hint} (e.g. {@code access_token}, {@code
55-
* refresh_token}), may be {@code null}
56-
*/
57-
default void revoke(
58-
WorkflowContext workflow,
59-
TaskContext context,
60-
WorkflowModel model,
61-
String token,
62-
String tokenTypeHint) {
63-
throw new UnsupportedOperationException("Token revocation is not supported by this provider");
64-
}
6524
}

impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/auth/JaxRSAccessTokenProvider.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import io.serverlessworkflow.impl.auth.HttpRequestInfo;
2828
import io.serverlessworkflow.impl.auth.JWT;
2929
import io.serverlessworkflow.impl.auth.JWTConverter;
30-
import io.serverlessworkflow.impl.auth.TokenIntrospection;
3130
import io.serverlessworkflow.impl.executors.http.HttpClientResolver;
3231
import jakarta.ws.rs.ProcessingException;
3332
import jakarta.ws.rs.client.Client;
@@ -74,46 +73,6 @@ public JWT validateAndGet(WorkflowContext workflow, TaskContext context, Workflo
7473
return jwt;
7574
}
7675

77-
@Override
78-
public TokenIntrospection introspect(
79-
WorkflowContext workflow,
80-
TaskContext context,
81-
WorkflowModel model,
82-
String token,
83-
String tokenTypeHint) {
84-
URI uri = endpoint(requestInfo.introspectionUri(), "introspection", workflow, context, model);
85-
return execute(
86-
context,
87-
() -> {
88-
try (Response response =
89-
postManagementRequest(workflow, context, model, uri, token, tokenTypeHint)) {
90-
ensureSuccessful(response, context, "introspect token");
91-
Map<String, Object> body = response.readEntity(new GenericType<>() {});
92-
return new TokenIntrospection(Boolean.TRUE.equals(body.get("active")), body);
93-
}
94-
});
95-
}
96-
97-
@Override
98-
public void revoke(
99-
WorkflowContext workflow,
100-
TaskContext context,
101-
WorkflowModel model,
102-
String token,
103-
String tokenTypeHint) {
104-
URI uri = endpoint(requestInfo.revocationUri(), "revocation", workflow, context, model);
105-
execute(
106-
context,
107-
() -> {
108-
// RFC 7009: a successful revocation responds with HTTP 200 and an empty body.
109-
try (Response response =
110-
postManagementRequest(workflow, context, model, uri, token, tokenTypeHint)) {
111-
ensureSuccessful(response, context, "revoke token");
112-
return null;
113-
}
114-
});
115-
}
116-
11776
private Map<String, Object> invoke(
11877
WorkflowContext workflowContext, TaskContext taskContext, WorkflowModel model) {
11978
return execute(

impl/http/src/test/java/io/serverlessworkflow/impl/executors/http/auth/JaxRSAccessTokenProviderTest.java

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,23 @@
1515
*/
1616
package io.serverlessworkflow.impl.executors.http.auth;
1717

18-
import static org.junit.jupiter.api.Assertions.assertEquals;
19-
import static org.junit.jupiter.api.Assertions.assertFalse;
20-
import static org.junit.jupiter.api.Assertions.assertThrows;
21-
import static org.junit.jupiter.api.Assertions.assertTrue;
2218
import static org.mockito.ArgumentMatchers.any;
2319
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
2420
import static org.mockito.Mockito.mock;
2521
import static org.mockito.Mockito.when;
2622

2723
import io.serverlessworkflow.impl.TaskContext;
2824
import io.serverlessworkflow.impl.WorkflowContext;
29-
import io.serverlessworkflow.impl.WorkflowException;
3025
import io.serverlessworkflow.impl.WorkflowValueResolver;
3126
import io.serverlessworkflow.impl.auth.AccessTokenProvider;
3227
import io.serverlessworkflow.impl.auth.HttpRequestInfo;
3328
import io.serverlessworkflow.impl.auth.JWTConverter;
34-
import io.serverlessworkflow.impl.auth.TokenIntrospection;
3529
import java.util.List;
3630
import java.util.Map;
3731
import java.util.Optional;
38-
import okhttp3.mockwebserver.MockResponse;
3932
import okhttp3.mockwebserver.MockWebServer;
40-
import okhttp3.mockwebserver.RecordedRequest;
4133
import org.junit.jupiter.api.AfterEach;
4234
import org.junit.jupiter.api.BeforeEach;
43-
import org.junit.jupiter.api.Test;
4435

4536
class JaxRSAccessTokenProviderTest {
4637

@@ -63,68 +54,6 @@ void tearDown() throws Exception {
6354
server.shutdown();
6455
}
6556

66-
@Test
67-
void introspectSendsClientAuthAndTokenAndParsesActive() throws Exception {
68-
server.enqueue(
69-
new MockResponse()
70-
.setHeader("Content-Type", "application/json")
71-
.setBody("{\"active\": true, \"scope\": \"read\"}"));
72-
73-
TokenIntrospection result =
74-
provider().introspect(workflow, task, null, "the-access-token", "access_token");
75-
76-
assertTrue(result.active());
77-
assertEquals("read", result.claims().get("scope"));
78-
79-
RecordedRequest request = server.takeRequest();
80-
assertEquals("POST", request.getMethod());
81-
assertEquals("/oauth2/introspect", request.getPath());
82-
assertEquals("application/x-www-form-urlencoded", request.getHeader("Content-Type"));
83-
String body = request.getBody().readUtf8();
84-
assertTrue(body.contains("token=the-access-token"));
85-
assertTrue(body.contains("token_type_hint=access_token"));
86-
assertTrue(body.contains("client_id=serverless-workflow"));
87-
assertTrue(body.contains("client_secret=top-secret"));
88-
}
89-
90-
@Test
91-
void introspectReturnsInactiveForInactiveToken() throws Exception {
92-
server.enqueue(
93-
new MockResponse()
94-
.setHeader("Content-Type", "application/json")
95-
.setBody("{\"active\": false}"));
96-
97-
TokenIntrospection result = provider().introspect(workflow, task, null, "stale-token", null);
98-
99-
assertFalse(result.active());
100-
RecordedRequest request = server.takeRequest();
101-
assertFalse(request.getBody().readUtf8().contains("token_type_hint"));
102-
}
103-
104-
@Test
105-
void revokeSendsClientAuthAndToken() throws Exception {
106-
server.enqueue(new MockResponse().setResponseCode(200));
107-
108-
provider().revoke(workflow, task, null, "the-access-token", "access_token");
109-
110-
RecordedRequest request = server.takeRequest();
111-
assertEquals("POST", request.getMethod());
112-
assertEquals("/oauth2/revoke", request.getPath());
113-
assertEquals("application/x-www-form-urlencoded", request.getHeader("Content-Type"));
114-
String body = request.getBody().readUtf8();
115-
assertTrue(body.contains("token=the-access-token"));
116-
assertTrue(body.contains("token_type_hint=access_token"));
117-
assertTrue(body.contains("client_id=serverless-workflow"));
118-
}
119-
120-
@Test
121-
void revokeRaisesWorkflowExceptionOnErrorResponse() {
122-
server.enqueue(new MockResponse().setResponseCode(400).setBody("unsupported_token_type"));
123-
124-
assertThrows(
125-
WorkflowException.class, () -> provider().revoke(workflow, task, null, "bad-token", null));
126-
}
127-
12857
private AccessTokenProvider provider() {
12958
JWTConverter converter = token -> null;
13059
HttpRequestInfo requestInfo =

0 commit comments

Comments
 (0)