Skip to content

Commit

Permalink
feature/Improve BG createConsent endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
constantine2nd committed Aug 2, 2024
1 parent 9805835 commit 8754bcf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ As a last option, an ASPSP might in addition accept a command with access rights
createdConsent.consentId,
callContext.flatMap(_.consumer).map(_.consumerId.get),
Some(validUntil)
)
) map {
i => connectorEmptyResponse(i, callContext)
}
_ <- Future(Consents.consentProvider.vend.setJsonWebToken(createdConsent.consentId, consentJWT)) map {
i => connectorEmptyResponse(i, callContext)
}
Expand Down
14 changes: 9 additions & 5 deletions obp-api/src/main/scala/code/api/util/ConsentUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ object Consent extends MdcLoggable {
secret: String,
consentId: String,
consumerId: Option[String],
validUntil: Option[Date]): Future[String] = {
validUntil: Option[Date]): Future[Box[String]] = {

val currentTimeInSeconds = System.currentTimeMillis / 1000
val validUntilTimeInSeconds = validUntil match {
Expand Down Expand Up @@ -725,10 +725,14 @@ object Consent extends MdcLoggable {
views = views,
access = Some(consent.access)
)
implicit val formats = CustomJsonFormats.formats
val jwtPayloadAsJson = compactRender(Extraction.decompose(json))
val jwtClaims: JWTClaimsSet = JWTClaimsSet.parse(jwtPayloadAsJson)
CertificateUtil.jwtWithHmacProtection(jwtClaims, secret)
if(views.isEmpty) {
Empty
} else {
implicit val formats = CustomJsonFormats.formats
val jwtPayloadAsJson = compactRender(Extraction.decompose(json))
val jwtClaims: JWTClaimsSet = JWTClaimsSet.parse(jwtPayloadAsJson)
Full(CertificateUtil.jwtWithHmacProtection(jwtClaims, secret))
}
}
}

Expand Down

0 comments on commit 8754bcf

Please sign in to comment.