Skip to content

Commit c7ed008

Browse files
committed
Revert moving issuing fun from constructor
Otherwise it would be too easy to mix up key material for metadata and the key material used to actually sign the credentials
1 parent 3649fe8 commit c7ed008

9 files changed

Lines changed: 5 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ Release 5.8.0:
2020
- List of classes moved: `MobileSecurityObject`, `Document`, `IssuerSigned`, `DeviceResponse`
2121
- Issuer:
2222
- Extract interface `StatusListIssuer` out of `Issuer` to separate credential issuing and status list management
23-
- Extract interface `IssueCredentialFun` to be used in `CredentialIssuer` for OID4VCI
2423
- Rework interface `IssuerCredentialStore`, deprecating methods `storeGetNewIndex` and class `IssuerCredentialStore.Credential`
2524
- In `Issuer.IssuedCredential` add the typed credentials as properties, add property `userInfo`
2625
- In `StatusListIssuer` deprecate methods `revokeCredentials()` and `revokeCredentialsWithId()`, callers should use `revokeCredential()`
2726
- In `CredentialIssuer` deprecate constructor parameter `credentialProvider`, replace with `credentialDataProvider`
2827
- Extend `CredentialToBeIssued` to contain properties `expiration`, `scheme`, `subjectPublicKey`, `userInfo`
29-
- In `CredentialIssuer` move constructor parameters for loading data and issuing credentials to method `credential()`
28+
- In `CredentialIssuer` move constructor parameter for loading data to method `credential()`
3029
- Extract `ProofValidator` out of `CredentialIssuer`
3130
- Extract `CredentialSchemeMapping` out of various top-level methods
3231
- In `SimpleAuthorizationService` deprecate constructor parameter `dataProvider`, use `authorize()` with `OAuth2LoadUserFun` instead

vck-openid-ktor/src/commonTest/kotlin/at/asitplus/wallet/lib/ktor/openid/OpenId4VciClientTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class OpenId4VciClientTest : FunSpec() {
244244
val issuer = IssuerAgent(EphemeralKeyWithSelfSignedCert())
245245
credentialIssuer = CredentialIssuer(
246246
authorizationService = authorizationService,
247+
issuer = issuer,
247248
credentialSchemes = credentialSchemes,
248249
publicContext = publicContext,
249250
credentialEndpointPath = credentialEndpointPath,
@@ -317,7 +318,6 @@ class OpenId4VciClientTest : FunSpec() {
317318
val result = credentialIssuer.credential(
318319
authorizationHeader = authn,
319320
params = params,
320-
issueCredential = { issuer.issueCredential(it) },
321321
credentialDataProvider = credentialDataProvider,
322322
request = request.toRequestInfo(),
323323
).getOrThrow()

vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidvci/CredentialIssuer.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class CredentialIssuer(
5353
/** Used to get the user data, and access tokens. */
5454
private val authorizationService: OAuth2AuthorizationServerAdapter,
5555
/** Used to actually issue the credential. */
56-
@Deprecated("Use `issueCredential` in method `credential, `keyMaterial`, `cryptoAlgorithms`")
5756
private val issuer: Issuer = IssuerAgent(),
5857
/** Key material used to sign credentials in [credential]. */
5958
private val keyMaterial: Set<KeyMaterial> = setOf(issuer.keyMaterial),
@@ -181,7 +180,7 @@ class CredentialIssuer(
181180
* @param request information about the HTTP request the client has made, to validate authentication
182181
*/
183182
@Suppress("DEPRECATION")
184-
@Deprecated("Use `credential` with parameters `credentialDataProvider`, `issueCredential` instead")
183+
@Deprecated("Use `credential` with parameter `credentialDataProvider` instead")
185184
suspend fun credential(
186185
authorizationHeader: String,
187186
params: CredentialRequestParameters,
@@ -190,7 +189,6 @@ class CredentialIssuer(
190189
authorizationHeader = authorizationHeader,
191190
params = params,
192191
credentialDataProvider = CredentialIssuerDataProviderAdapter(credentialProvider),
193-
issueCredential = { issuer.issueCredential(it) },
194192
request = request,
195193
)
196194

@@ -205,18 +203,16 @@ class CredentialIssuer(
205203
* @param authorizationHeader value of HTTP header `Authorization` sent by the client, with all prefixes
206204
* @param params Parameters the client sent JSON-serialized in the HTTP body
207205
* @param request information about the HTTP request the client has made, to validate authentication
208-
* @param issueCredential Used to actually issue the credential, with data provided from [credentialDataProvider]
209-
* @param credentialDataProvider Extract data from the authenticated user and prepares it for [issueCredential]
206+
* @param credentialDataProvider Extract data from the authenticated user and prepares it for issuing
210207
*/
211208
suspend fun credential(
212209
authorizationHeader: String,
213210
params: CredentialRequestParameters,
214211
credentialDataProvider: CredentialDataProviderFun,
215-
issueCredential: IssueCredentialFun,
216212
request: RequestInfo? = null,
217213
): KmmResult<CredentialResponseParameters> = catching {
218214
proofValidator.validateProofExtractSubjectPublicKeys(params).map { subjectPublicKey ->
219-
issueCredential(
215+
issuer.issueCredential(
220216
credentialDataProvider(
221217
with(params.extractCredentialRepresentation()) {
222218
CredentialDataProviderInput(

vck-openid/src/commonMain/kotlin/at/asitplus/wallet/lib/oidvci/IssueCredentialFun.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/OidvciAttestationTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class OidvciAttestationTest : FunSpec({
8989
token.toHttpHeaderValue(),
9090
it,
9191
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
92-
issueCredential = { IssuerAgent().issueCredential(it) }
9392
).getOrThrow()
9493
val serializedCredential = credential.credentials.shouldNotBeEmpty()
9594
.first().credentialString.shouldNotBeNull()
@@ -128,7 +127,6 @@ class OidvciAttestationTest : FunSpec({
128127
token.toHttpHeaderValue(),
129128
it,
130129
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
131-
issueCredential = { IssuerAgent().issueCredential(it) }
132130
).getOrThrow()
133131
}
134132
}

vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/OidvciCodeFlowTest.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ class OidvciCodeFlowTest : FreeSpec({
149149
clientNonce = clientNonce,
150150
).getOrThrow().first(),
151151
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
152-
issueCredential = { IssuerAgent().issueCredential(it) }
153152
).getOrThrow()
154153
val serializedCredential = credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
155154

@@ -182,7 +181,6 @@ class OidvciCodeFlowTest : FreeSpec({
182181
clientNonce = clientNonce,
183182
).getOrThrow().first(),
184183
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
185-
issueCredential = { IssuerAgent().issueCredential(it) }
186184
).getOrThrow().credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
187185
}
188186
}
@@ -212,7 +210,6 @@ class OidvciCodeFlowTest : FreeSpec({
212210
token.toHttpHeaderValue(),
213211
credentialRequest,
214212
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
215-
issueCredential = { IssuerAgent().issueCredential(it) }
216213
).getOrThrow()
217214
.credentials.shouldNotBeEmpty().shouldHaveSize(2)
218215
// subject identifies the key of the client, here the keys of different proofs, so they should be unique
@@ -258,7 +255,6 @@ class OidvciCodeFlowTest : FreeSpec({
258255
clientNonce = clientNonce,
259256
).getOrThrow().first(),
260257
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
261-
issueCredential = { IssuerAgent().issueCredential(it) }
262258
).getOrThrow()
263259
val serializedCredential = credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
264260

@@ -281,7 +277,6 @@ class OidvciCodeFlowTest : FreeSpec({
281277
clientNonce = clientNonce,
282278
).getOrThrow().first(),
283279
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
284-
issueCredential = { IssuerAgent().issueCredential(it) }
285280
).getOrThrow()
286281
val serializedCredential = credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
287282

@@ -337,7 +332,6 @@ class OidvciCodeFlowTest : FreeSpec({
337332
clientNonce = clientNonce,
338333
).getOrThrow().first(),
339334
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
340-
issueCredential = { IssuerAgent().issueCredential(it) }
341335
).getOrThrow()
342336
val serializedCredential = credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
343337

@@ -365,7 +359,6 @@ class OidvciCodeFlowTest : FreeSpec({
365359
clientNonce = clientNonce,
366360
).getOrThrow().first(),
367361
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
368-
issueCredential = { IssuerAgent().issueCredential(it) }
369362
).getOrThrow()
370363
val serializedCredential = credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
371364

@@ -423,7 +416,6 @@ class OidvciCodeFlowTest : FreeSpec({
423416
credentialConfigurationId = null,
424417
),
425418
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
426-
issueCredential = { IssuerAgent().issueCredential(it) }
427419
).getOrThrow()
428420
}
429421
}
@@ -455,7 +447,6 @@ class OidvciCodeFlowTest : FreeSpec({
455447
credentialIdentifier = null
456448
),
457449
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
458-
issueCredential = { IssuerAgent().issueCredential(it) }
459450
).getOrThrow()
460451
}
461452
}
@@ -476,7 +467,6 @@ class OidvciCodeFlowTest : FreeSpec({
476467
clientNonce = clientNonce,
477468
).getOrThrow().first(),
478469
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
479-
issueCredential = { IssuerAgent().issueCredential(it) }
480470
).getOrThrow()
481471
val serializedCredential = credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
482472

vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/OidvciEncryptionTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class OidvciEncryptionTest : FunSpec({
104104
authorizationHeader = token.toHttpHeaderValue(),
105105
params = it,
106106
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
107-
issueCredential = { IssuerAgent().issueCredential(it) }
108107
).getOrThrow()
109108
}
110109
}
@@ -126,7 +125,6 @@ class OidvciEncryptionTest : FunSpec({
126125
token.toHttpHeaderValue(),
127126
it,
128127
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
129-
issueCredential = { IssuerAgent().issueCredential(it) }
130128
).getOrThrow()
131129
val serializedCredential = credential.credentials.shouldNotBeEmpty()
132130
.first().credentialString.shouldNotBeNull()

vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/OidvciOfferCodeTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class OidvciOfferCodeTest : FreeSpec({
103103
authorizationHeader = token.toHttpHeaderValue(),
104104
params = credentialRequest.first(),
105105
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
106-
issueCredential = { IssuerAgent().issueCredential(it) }
107106
).getOrThrow()
108107
credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
109108
}
@@ -151,7 +150,6 @@ class OidvciOfferCodeTest : FreeSpec({
151150
authorizationHeader = token.toHttpHeaderValue(),
152151
params = credentialRequest.first(),
153152
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
154-
issueCredential = { IssuerAgent().issueCredential(it) }
155153
).getOrThrow()
156154
credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
157155
}

vck-openid/src/commonTest/kotlin/at/asitplus/wallet/lib/oidvci/OidvciPreAuthTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class OidvciPreAuthTest : FreeSpec({
8282
authorizationHeader = token.toHttpHeaderValue(),
8383
params = credentialRequest.first(),
8484
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
85-
issueCredential = { IssuerAgent().issueCredential(it) }
8685
).getOrThrow()
8786
credential.credentials.shouldNotBeEmpty().first().credentialString.shouldNotBeNull()
8887
}
@@ -115,7 +114,6 @@ class OidvciPreAuthTest : FreeSpec({
115114
token.toHttpHeaderValue(),
116115
credentialRequest.first(),
117116
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
118-
issueCredential = { IssuerAgent().issueCredential(it) }
119117
).getOrThrow()
120118
.credentials.shouldNotBeEmpty().first()
121119
.credentialString.shouldNotBeNull()
@@ -154,7 +152,6 @@ class OidvciPreAuthTest : FreeSpec({
154152
token.toHttpHeaderValue(),
155153
credentialRequest.first(),
156154
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
157-
issueCredential = { IssuerAgent().issueCredential(it) }
158155
).getOrThrow()
159156
.credentials.shouldNotBeEmpty().first()
160157
.credentialString.shouldNotBeNull()
@@ -191,7 +188,6 @@ class OidvciPreAuthTest : FreeSpec({
191188
token.toHttpHeaderValue(),
192189
credentialRequest,
193190
credentialDataProvider = DummyOAuth2IssuerCredentialDataProvider,
194-
issueCredential = { IssuerAgent().issueCredential(it) }
195191
).getOrThrow()
196192
.credentials.shouldNotBeEmpty()
197193
.shouldHaveSize(2)

0 commit comments

Comments
 (0)