Skip to content

Commit 12e0f6f

Browse files
authored
fix: use id insted of clientId when generating the token (#666)
fix: use client#id insted of client#client_id when generating the token
1 parent f5d9e64 commit 12e0f6f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

extensions/sts/sts-core/src/main/java/org/eclipse/edc/iam/identitytrust/sts/service/StsClientTokenGeneratorServiceImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public ServiceResult<TokenRepresentation> tokenFor(StsAccount client, StsAccount
6060
.map(enrichClaimsWith(accumulator, entity.getKey()))
6161
.orElse(accumulator), (a, b) -> b);
6262

63-
var tokenResult = tokenGenerator.createToken(client.getClientId(), claims, additionalParams.getBearerAccessScope())
63+
var tokenResult = tokenGenerator.createToken(client.getId(), claims, additionalParams.getBearerAccessScope())
6464
.map(this::enrichWithExpiration);
6565

6666
if (tokenResult.failed()) {

extensions/sts/sts-core/src/test/java/org/eclipse/edc/iam/identitytrust/sts/defaults/StsAccountTokenIssuanceIntegrationTest.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.edc.identityhub.sts.accountservice.RandomStringGenerator;
2727
import org.eclipse.edc.identityhub.sts.accountservice.StsAccountServiceImpl;
2828
import org.eclipse.edc.junit.annotations.ComponentTest;
29+
import org.eclipse.edc.junit.assertions.AbstractResultAssert;
2930
import org.eclipse.edc.jwt.validation.jti.JtiValidationStore;
3031
import org.eclipse.edc.keys.KeyParserRegistryImpl;
3132
import org.eclipse.edc.keys.VaultPrivateKeyResolver;
@@ -86,12 +87,13 @@ void setup() {
8687

8788
@Test
8889
void authenticateAndGenerateToken() throws Exception {
90+
var participantId = "participant_id";
8991
var clientId = "client_id";
9092
var secretAlias = "client_secret_alias";
9193
var privateKeyAlias = "client_id";
9294
var audience = "aud";
9395
var did = "did:example:subject";
94-
var client = createClientBuilder(clientId)
96+
var client = createClientBuilder(participantId)
9597
.clientId(clientId)
9698
.privateKeyAlias(privateKeyAlias)
9799
.secretAlias(secretAlias)
@@ -104,7 +106,7 @@ void authenticateAndGenerateToken() throws Exception {
104106
vault.storeSecret(privateKeyAlias, loadResourceFile("ec-privatekey.pem"));
105107

106108
var createResult = clientService.createAccount(ParticipantManifest.Builder.newInstance()
107-
.participantId(clientId)
109+
.participantId(participantId)
108110
.did(did)
109111
.key(KeyDescriptor.Builder.newInstance()
110112
.keyId("public-key")
@@ -114,6 +116,9 @@ void authenticateAndGenerateToken() throws Exception {
114116
assertThat(createResult.succeeded()).isTrue();
115117

116118
var tokenResult = tokenGeneratorService.tokenFor(client, additional);
119+
120+
AbstractResultAssert.assertThat(tokenResult).isSucceeded();
121+
117122
var jwt = SignedJWT.parse(tokenResult.getContent().getToken());
118123

119124
assertThat(jwt.getJWTClaimsSet().getClaims())
@@ -127,13 +132,14 @@ void authenticateAndGenerateToken() throws Exception {
127132

128133
@Test
129134
void authenticateAndGenerateToken_withBearerAccessScope() throws Exception {
135+
var participantId = "participant_id";
130136
var clientId = "client_id";
131137
var secretAlias = "client_secret_alias";
132138
var privateKeyAlias = "client_id";
133139
var did = "did:example:subject";
134140
var audience = "aud";
135141
var scope = "scope:test";
136-
var client = createClientBuilder(clientId)
142+
var client = createClientBuilder(participantId)
137143
.clientId(clientId)
138144
.privateKeyAlias(privateKeyAlias)
139145
.secretAlias(secretAlias)
@@ -146,7 +152,7 @@ void authenticateAndGenerateToken_withBearerAccessScope() throws Exception {
146152
vault.storeSecret(privateKeyAlias, loadResourceFile("ec-privatekey.pem"));
147153

148154
var createResult = clientService.createAccount(ParticipantManifest.Builder.newInstance()
149-
.participantId(clientId)
155+
.participantId(participantId)
150156
.did(did)
151157
.key(KeyDescriptor.Builder.newInstance()
152158
.keyId("public-key")
@@ -169,14 +175,15 @@ void authenticateAndGenerateToken_withBearerAccessScope() throws Exception {
169175

170176
@Test
171177
void authenticateAndGenerateToken_withAccessToken() throws Exception {
178+
var participantId = "participant_id";
172179
var clientId = "client_id";
173180
var secretAlias = "client_secret_alias";
174181
var privateKeyAlias = "client_id";
175182
var audience = "aud";
176183
var accessToken = "tokenTest";
177184
var did = "did:example:subject";
178185

179-
var client = createClientBuilder(clientId)
186+
var client = createClientBuilder(participantId)
180187
.clientId(clientId)
181188
.privateKeyAlias(privateKeyAlias)
182189
.secretAlias(secretAlias)
@@ -189,7 +196,7 @@ void authenticateAndGenerateToken_withAccessToken() throws Exception {
189196
vault.storeSecret(privateKeyAlias, loadResourceFile("ec-privatekey.pem"));
190197

191198
var createResult = clientService.createAccount(ParticipantManifest.Builder.newInstance()
192-
.participantId(clientId)
199+
.participantId(participantId)
193200
.did(did)
194201
.key(KeyDescriptor.Builder.newInstance()
195202
.keyId("public-key")

0 commit comments

Comments
 (0)