Skip to content

Commit 6cacfbd

Browse files
committed
Adding challengePurpose, challengeContextHash and
challengeContextStructure
1 parent 5c15f4f commit 6cacfbd

4 files changed

Lines changed: 33 additions & 3 deletions

File tree

obp-api/src/main/scala/code/transactionChallenge/ChallengeProvider.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ trait ChallengeProvider {
2020
basketId: Option[String], // Note: basketId, consentId and transactionRequestId are exclusive here.
2121
authenticationMethodId: Option[String],
2222
challengeType: String,
23+
// PSD2 Dynamic Linking fields
24+
challengePurpose: Option[String] = None, // Human-readable description shown to user
25+
challengeContextHash: Option[String] = None, // SHA-256 hash of critical transaction fields
26+
challengeContextStructure: Option[String] = None // Comma-separated list of field names in hash
2327
): Box[ChallengeTrait]
2428

2529
def getChallenge(challengeId: String): Box[ChallengeTrait]

obp-api/src/main/scala/code/transactionChallenge/MappedChallengeProvider.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ object MappedChallengeProvider extends ChallengeProvider {
2828
consentId: Option[String], // Note: consentId and transactionRequestId and basketId are exclusive here.
2929
basketId: Option[String], // Note: consentId and transactionRequestId and basketId are exclusive here.
3030
authenticationMethodId: Option[String],
31-
challengeType: String,
32-
): Box[ChallengeTrait] =
31+
challengeType: String,
32+
// PSD2 Dynamic Linking fields
33+
challengePurpose: Option[String] = None,
34+
challengeContextHash: Option[String] = None,
35+
challengeContextStructure: Option[String] = None
36+
): Box[ChallengeTrait] =
3337
tryo (
3438
MappedExpectedChallengeAnswer
3539
.create
@@ -44,6 +48,10 @@ object MappedChallengeProvider extends ChallengeProvider {
4448
.ConsentId(consentId.getOrElse(""))
4549
.BasketId(basketId.getOrElse(""))
4650
.AuthenticationMethodId(expectedUserId)
51+
// PSD2 Dynamic Linking
52+
.ChallengePurpose(challengePurpose.getOrElse(""))
53+
.ChallengeContextHash(challengeContextHash.getOrElse(""))
54+
.ChallengeContextStructure(challengeContextStructure.getOrElse(""))
4755
.saveMe()
4856
)
4957

obp-api/src/main/scala/code/transactionChallenge/MappedExpectedChallengeAnswer.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class MappedExpectedChallengeAnswer extends ChallengeTrait with LongKeyedMapper[
2929
override def defaultValue = 0
3030
}
3131

32+
// PSD2 Dynamic Linking fields
33+
object ChallengePurpose extends MappedString(this, 2000)
34+
object ChallengeContextHash extends MappedString(this, 64)
35+
object ChallengeContextStructure extends MappedString(this, 500)
36+
3237
override def challengeId: String = ChallengeId.get
3338
override def challengeType: String = ChallengeType.get
3439
override def transactionRequestId: String = TransactionRequestId.get
@@ -42,6 +47,11 @@ class MappedExpectedChallengeAnswer extends ChallengeTrait with LongKeyedMapper[
4247
override def scaStatus: Option[SCAStatus] = Option(StrongCustomerAuthenticationStatus.withName(ScaStatus.get))
4348
override def authenticationMethodId: Option[String] = Option(AuthenticationMethodId.get)
4449
override def attemptCounter: Int = AttemptCounter.get
50+
51+
// PSD2 Dynamic Linking
52+
override def challengePurpose: Option[String] = Option(ChallengePurpose.get).filter(_.nonEmpty)
53+
override def challengeContextHash: Option[String] = Option(ChallengeContextHash.get).filter(_.nonEmpty)
54+
override def challengeContextStructure: Option[String] = Option(ChallengeContextStructure.get).filter(_.nonEmpty)
4555
}
4656

4757
object MappedExpectedChallengeAnswer extends MappedExpectedChallengeAnswer with LongKeyedMetaMapper[MappedExpectedChallengeAnswer] {

obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,16 @@ trait ChallengeTrait {
647647
def scaMethod: Option[SCA]
648648
def scaStatus: Option[SCAStatus]
649649
def authenticationMethodId: Option[String]
650-
650+
651651
def attemptCounter: Int
652+
653+
// PSD2 Dynamic Linking support - these fields ensure the authentication is linked to the transaction details
654+
// challenge_purpose: Human-readable description of what is being authorized (shown to user in SMS/email)
655+
def challengePurpose: Option[String]
656+
// challenge_context_hash: SHA-256 hash of critical transaction fields for tamper detection
657+
def challengeContextHash: Option[String]
658+
// challenge_context_structure: Comma-separated list of field names included in the hash
659+
def challengeContextStructure: Option[String]
652660
}
653661

654662

0 commit comments

Comments
 (0)