Skip to content

Commit

Permalink
Extract more constants
Browse files Browse the repository at this point in the history
  • Loading branch information
nodh committed Nov 14, 2024
1 parent 0b84df0 commit 8234449
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ object OpenIdConstants {

const val TOKEN_TYPE_BEARER = "bearer"

const val TOKEN_TYPE_DPOP = "dpop"

const val URN_TYPE_JWK_THUMBPRINT = "urn:ietf:params:oauth:jwk-thumbprint"

const val BINDING_METHOD_COSE_KEY = "cose_key"
Expand Down Expand Up @@ -51,6 +53,11 @@ object OpenIdConstants {

const val AUTH_METHOD_ATTEST_JWT_CLIENT_AUTH = "attest_jwt_client_auth"

const val PARAMETER_PROMPT = "prompt"

const val PARAMETER_PROMPT_LOGIN = "login"


@Serializable(with = ProofType.Serializer::class)
sealed class ProofType(val stringRepresentation: String) {
override fun toString(): String = this::class.simpleName + "(" + stringRepresentation + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import at.asitplus.jsonpath.core.NormalizedJsonPath
import at.asitplus.jsonpath.core.NormalizedJsonPathSegment
import at.asitplus.openid.*
import at.asitplus.openid.OpenIdConstants.AUTH_METHOD_ATTEST_JWT_CLIENT_AUTH
import at.asitplus.openid.OpenIdConstants.PARAMETER_PROMPT
import at.asitplus.openid.OpenIdConstants.PARAMETER_PROMPT_LOGIN
import at.asitplus.openid.OpenIdConstants.TOKEN_TYPE_DPOP
import at.asitplus.signum.indispensable.josef.JsonWebAlgorithm
import at.asitplus.wallet.lib.agent.CryptoService
import at.asitplus.wallet.lib.agent.Holder
Expand Down Expand Up @@ -38,8 +41,6 @@ import kotlinx.serialization.json.Json
import kotlin.time.Duration.Companion.minutes




/**
* Implements the client side of [OpenID for Verifiable Credential Issuance - draft 14](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html).
*
Expand Down Expand Up @@ -105,7 +106,7 @@ class OpenId4VciClient(
}
}
}
private val oid4vciService = WalletService(
val oid4vciService = WalletService(
clientId = clientId,
cryptoService = cryptoService,
redirectUrl = redirectUrl
Expand Down Expand Up @@ -305,7 +306,7 @@ class OpenId4VciClient(
credentialIssuer = credentialIssuer,
).getOrThrow()

val dpopHeader = if (tokenResponse.tokenType.lowercase() == "dpop")
val dpopHeader = if (tokenResponse.tokenType.equals(TOKEN_TYPE_DPOP, true))
jwsService.buildDPoPHeader(url = credentialEndpointUrl, accessToken = tokenResponse.accessToken)
else null

Expand Down Expand Up @@ -468,7 +469,7 @@ class OpenId4VciClient(
authRequest.encodeToParameters<AuthenticationRequestParameters>().forEach {
builder.parameters.append(it.key, it.value)
}
builder.parameters.append("prompt", "login")
builder.parameters.append(PARAMETER_PROMPT, PARAMETER_PROMPT_LOGIN)
}.build().toString()
}
Napier.d("Provisioning starts by opening URL $authorizationUrl")
Expand Down Expand Up @@ -497,7 +498,7 @@ class OpenId4VciClient(
url = url,
formParameters = parameters {
authRequest.encodeToParameters().forEach { append(it.key, it.value) }
append("prompt", "login")
append(PARAMETER_PROMPT, PARAMETER_PROMPT_LOGIN)
}
) {
headers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class OpenId4VpWallet(
}
httpClientConfig?.let { apply(it) }
}
private val oidcSiopWallet = OidcSiopWallet(
val oidcSiopWallet = OidcSiopWallet(
holder = holderAgent,
agentPublicKey = cryptoService.keyMaterial.publicKey,
jwsService = DefaultJwsService(cryptoService),
Expand Down

0 comments on commit 8234449

Please sign in to comment.