Skip to content

Commit 27498d0

Browse files
committed
Consent jwt_expires_at
1 parent b6e4e38 commit 27498d0

6 files changed

Lines changed: 28 additions & 8 deletions

File tree

obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4604,6 +4604,7 @@ object SwaggerDefinitionsJSON {
46044604
jwt_payload = """{"createdByUserId":"user-id","sub":"subject","iss":"issuer","aud":"audience","jti":"jwt-id","iat":1611749820,"nbf":1611749820,"exp":1611753420,"request_headers":[],"name":null,"email":null,"entitlements":[],"views":[],"access":null}""",
46054605
api_standard = "Berlin Group",
46064606
api_version = "v1.3",
4607+
jwt_expires_at = dateTimeExample.value,
46074608
)
46084609

46094610
lazy val consentsInfoJsonV510 = ConsentsInfoJsonV510(

obp-api/src/main/scala/code/api/util/migration/Migration.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ object Migration extends MdcLoggable {
113113
addMetricView(startedBeforeSchemifier)
114114
addConsentView(startedBeforeSchemifier)
115115
updateConsentViewAddJwtPayload(startedBeforeSchemifier)
116+
updateConsentViewAddJwtExpiresAt(startedBeforeSchemifier)
116117
updateAccountAccessWithViewsViewUnionAll(startedBeforeSchemifier)
117118
}
118119

@@ -613,6 +614,18 @@ object Migration extends MdcLoggable {
613614
}
614615
}
615616

617+
private def updateConsentViewAddJwtExpiresAt(startedBeforeSchemifier: Boolean): Boolean = {
618+
if(startedBeforeSchemifier == true) {
619+
logger.warn(s"Migration.database.updateConsentViewAddJwtExpiresAt(true) cannot be run before Schemifier.")
620+
true
621+
} else {
622+
val name = nameOf(updateConsentViewAddJwtExpiresAt(startedBeforeSchemifier))
623+
runOnce(name) {
624+
MigrationOfConsentView.addConsentView(name)
625+
}
626+
}
627+
}
628+
616629
private def addAccountAccessWithViewsView(startedBeforeSchemifier: Boolean): Boolean = {
617630
if(startedBeforeSchemifier == true) {
618631
logger.warn(s"Migration.database.addAccountAccessWithViewsView(true) cannot be run before Schemifier.")

obp-api/src/main/scala/code/api/util/migration/MigrationOfConsentView.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ object MigrationOfConsentView {
3737
| mnote AS note,
3838
| mfrequencyperday AS frequency_per_day,
3939
| musessofartodaycounter AS uses_so_far_today_counter,
40-
| mjsonwebtokenpayload AS jwt_payload
40+
| mjsonwebtokenpayload AS jwt_payload,
41+
| jwt_expires_at AS jwt_expires_at
4142
|FROM mappedconsent;
4243
|""".stripMargin
4344
case _ =>
@@ -60,7 +61,8 @@ object MigrationOfConsentView {
6061
| mnote AS note,
6162
| mfrequencyperday AS frequency_per_day,
6263
| musessofartodaycounter AS uses_so_far_today_counter,
63-
| mjsonwebtokenpayload AS jwt_payload
64+
| mjsonwebtokenpayload AS jwt_payload,
65+
| jwt_expires_at AS jwt_expires_at
6466
|FROM mappedconsent;
6567
|""".stripMargin
6668
}

obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,8 @@ trait APIMethods510 {
19621962
jwt = row.jwt.orNull,
19631963
jwt_payload = row.jwtPayload.orNull,
19641964
api_standard = row.apiStandard.orNull,
1965-
api_version = row.apiVersion.orNull
1965+
api_version = row.apiVersion.orNull,
1966+
jwt_expires_at = row.jwtExpiresAt.map(d => new java.text.SimpleDateFormat(DateWithSeconds).format(d)).orNull
19661967
)
19671968
}
19681969

obp-api/src/main/scala/code/api/v5_1_0/JSONFactory5.1.0.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ case class ConsentInfoJsonV510(consent_reference_id: String,
175175
jwt_payload: String,
176176
api_standard: String,
177177
api_version: String,
178+
jwt_expires_at: String,
178179
)
179180
case class ConsentsInfoJsonV510(consents: List[ConsentInfoJsonV510])
180181

@@ -1020,7 +1021,8 @@ object JSONFactory510 extends CustomJsonFormats with MdcLoggable {
10201021
jwt = c.jsonWebToken,
10211022
jwt_payload = null,
10221023
api_standard = c.apiStandard,
1023-
api_version = c.apiVersion
1024+
api_version = c.apiVersion,
1025+
jwt_expires_at = null
10241026
)
10251027
}
10261028
)

obp-api/src/main/scala/code/consent/DoobieConsentQueries.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ object DoobieConsentQueries {
3939
note: Option[String],
4040
frequencyPerDay: Option[Int],
4141
usesSoFarTodayCounter: Option[Int],
42-
jwtPayload: Option[String]
42+
jwtPayload: Option[String],
43+
jwtExpiresAt: Option[Timestamp]
4344
)
4445

4546
/**
@@ -74,7 +75,7 @@ object DoobieConsentQueries {
7475
fr"""SELECT consent_reference_id, consent_id, created_by_user_id, consumer_id,
7576
status, jwt, consent_request_id, api_standard, api_version,
7677
last_action_date, last_usage_date, created_date,
77-
note, frequency_per_day, uses_so_far_today_counter, jwt_payload
78+
note, frequency_per_day, uses_so_far_today_counter, jwt_payload, jwt_expires_at
7879
FROM v_consent
7980
WHERE created_by_user_id = $userId
8081
ORDER BY created_date DESC, api_standard DESC"""
@@ -113,7 +114,7 @@ object DoobieConsentQueries {
113114
fr"""SELECT consent_reference_id, consent_id, created_by_user_id, consumer_id,
114115
status, jwt, consent_request_id, api_standard, api_version,
115116
last_action_date, last_usage_date, created_date,
116-
note, frequency_per_day, uses_so_far_today_counter, jwt_payload
117+
note, frequency_per_day, uses_so_far_today_counter, jwt_payload, jwt_expires_at
117118
FROM v_consent"""
118119

119120
private def buildStatusCondition(status: Option[String]): Fragment = status match {
@@ -236,7 +237,7 @@ object DoobieConsentQueries {
236237
fr"""SELECT DISTINCT v.consent_reference_id, v.consent_id, v.created_by_user_id, v.consumer_id,
237238
v.status, v.jwt, v.consent_request_id, v.api_standard, v.api_version,
238239
v.last_action_date, v.last_usage_date, v.created_date,
239-
v.note, v.frequency_per_day, v.uses_so_far_today_counter, v.jwt_payload
240+
v.note, v.frequency_per_day, v.uses_so_far_today_counter, v.jwt_payload, v.jwt_expires_at
240241
FROM v_consent v
241242
JOIN consent_items cb ON cb.consent_reference_id = v.consent_reference_id
242243
WHERE v.created_by_user_id = $userId

0 commit comments

Comments
 (0)