Skip to content

Commit 2bb81bf

Browse files
committed
new common module with base oidc client, reworked jetty authenticators
* New dsf-common-oidc maven module with base oidc client * Reworked bpe server oidc client to be based on common base client * Reworked BackChannelLogoutAuthenticator and BearerTokenAuthenticator to used common oidc client, authenticators now also support tokens sigend with EC keys * New config parameter to set oidc token audience (aud) to validate bearer tokens, default uses oidc client-id
1 parent 2640325 commit 2bb81bf

File tree

32 files changed

+987
-743
lines changed

32 files changed

+987
-743
lines changed

dsf-bpe/dsf-bpe-process-api-v2-impl/src/main/java/dev/dsf/bpe/v2/client/oidc/OidcClientDelegate.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,6 @@ public Jwks getJwks() throws OidcClientException
269269
return jwks == null ? null : new JwksApiDelegate(jwks);
270270
}
271271

272-
@Override
273-
public Jwks getJwks(Configuration configuration) throws OidcClientException
274-
{
275-
var jwks = delegate.getJwks(configuration == null ? null : new ConfigurationV2Delegate(configuration));
276-
return jwks == null ? null : new JwksApiDelegate(jwks);
277-
}
278-
279272
@Override
280273
public char[] getAccessToken() throws OidcClientException
281274
{

dsf-bpe/dsf-bpe-process-api-v2-impl/src/main/java/dev/dsf/bpe/v2/plugin/ProcessPluginImpl.java

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -127,75 +127,40 @@ protected void customizeApplicationContext(AnnotationConfigApplicationContext co
127127
new ProcessPluginApiFactory(processPluginDefinition, parentContext));
128128
}
129129

130-
private ProcessPluginApi getProcessPluginApi()
130+
private <T> T getOrSet(AtomicReference<T> cache, Supplier<T> supplier)
131131
{
132-
ProcessPluginApi entry = processPluginApi.get();
133-
if (entry == null)
132+
T cached = cache.get();
133+
if (cached == null)
134134
{
135-
ProcessPluginApi o = doGetProcessPluginApi();
136-
if (processPluginApi.compareAndSet(entry, o))
137-
return o;
135+
T value = supplier.get();
136+
if (cache.compareAndSet(cached, value))
137+
return value;
138138
else
139-
return processPluginApi.get();
139+
return cache.get();
140140
}
141141
else
142-
return entry;
142+
return cached;
143143
}
144144

145-
private ProcessPluginApi doGetProcessPluginApi()
145+
private ProcessPluginApi getProcessPluginApi()
146146
{
147-
return getApplicationContext().getBean(ProcessPluginApi.class);
147+
return getOrSet(processPluginApi, () -> getApplicationContext().getBean(ProcessPluginApi.class));
148148
}
149149

150150
private FhirContext getFhirContext()
151151
{
152-
FhirContext entry = fhirContext.get();
153-
if (entry == null)
154-
{
155-
FhirContext o = doGetFhirContext();
156-
if (fhirContext.compareAndSet(entry, o))
157-
return o;
158-
else
159-
return fhirContext.get();
160-
}
161-
else
162-
return entry;
163-
}
164-
165-
private FhirContext doGetFhirContext()
166-
{
167-
return getApplicationContext().getBean(FhirContext.class);
152+
return getOrSet(fhirContext, () -> getApplicationContext().getBean(FhirContext.class));
168153
}
169154

170155
private ObjectMapper getObjectMapper()
171156
{
172-
ObjectMapper entry = objectMapper.get();
173-
if (entry == null)
174-
{
175-
ObjectMapper o = doGetObjectMapper();
176-
if (objectMapper.compareAndSet(entry, o))
177-
return o;
178-
else
179-
return objectMapper.get();
180-
}
181-
else
182-
return entry;
183-
}
184-
185-
private ObjectMapper doGetObjectMapper()
186-
{
187-
try
157+
return getOrSet(objectMapper, () ->
188158
{
189159
ObjectMapper objectMapper = getApplicationContext().getBean(ObjectMapper.class).copy();
190160
objectMapper.setTypeFactory(TypeFactory.defaultInstance().withClassLoader(getProcessPluginClassLoader()));
191161

192162
return objectMapper;
193-
194-
}
195-
catch (BeansException e)
196-
{
197-
throw new RuntimeException(e);
198-
}
163+
});
199164
}
200165

201166
@Override

dsf-bpe/dsf-bpe-process-api-v2/src/main/java/dev/dsf/bpe/v2/client/oidc/OidcClient.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ public interface OidcClient
2020
*/
2121
Jwks getJwks() throws OidcClientException;
2222

23-
/**
24-
* @param configuration
25-
* not <code>null</code>
26-
* @return {@link Jwks} resource
27-
* @throws OidcClientException
28-
* if response status not 200 OK
29-
*/
30-
Jwks getJwks(Configuration configuration) throws OidcClientException;
31-
3223
/**
3324
* @return access token
3425
*/

dsf-bpe/dsf-bpe-process-api/src/main/java/dev/dsf/bpe/api/client/oidc/OidcClient.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ public interface OidcClient
1515
* @throws OidcClientException
1616
* if response status not 200 OK
1717
*/
18-
Jwks getJwks() throws OidcClientException;
18+
default Jwks getJwks() throws OidcClientException
19+
{
20+
return getJwks(getConfiguration());
21+
}
1922

2023
/**
24+
* <i>Implementation may ignore the configuration parameter and use value from {@link #getConfiguration()}
25+
* instead.</i>
26+
*
2127
* @param configuration
22-
* not <code>null</code>
28+
* may be <code>null</code>, uses value from {@link #getConfiguration()} if <code>null</code>
2329
* @return {@link Jwks} resource
2430
* @throws OidcClientException
2531
* if response status not 200 OK

dsf-bpe/dsf-bpe-server/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<groupId>dev.dsf</groupId>
4141
<artifactId>dsf-common-documentation</artifactId>
4242
</dependency>
43+
<dependency>
44+
<groupId>dev.dsf</groupId>
45+
<artifactId>dsf-common-oidc</artifactId>
46+
</dependency>
4347
<dependency>
4448
<groupId>dev.dsf</groupId>
4549
<artifactId>dsf-common-status</artifactId>

0 commit comments

Comments
 (0)