Skip to content

Commit

Permalink
Merge pull request #2442 from constantine2nd/develop
Browse files Browse the repository at this point in the history
Few tweaks - show User Id on Portal, fix build issue with swagger.
  • Loading branch information
simonredfern authored Nov 11, 2024
2 parents 0d9f303 + ebe3cac commit 9f43f61
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
package code.api.ResourceDocs1_4_0

import java.util.Date

import code.api.Constant._
import code.api.Constant
import code.api.Constant._
import code.api.UKOpenBanking.v2_0_0.JSONFactory_UKOpenBanking_200
import code.api.UKOpenBanking.v2_0_0.JSONFactory_UKOpenBanking_200.{Account, AccountBalancesUKV200, AccountInner, AccountList, Accounts, BalanceJsonUKV200, BalanceUKOpenBankingJson, BankTransactionCodeJson, CreditLineJson, DataJsonUKV200, Links, MetaBisJson, MetaInnerJson, TransactionCodeJson, TransactionInnerJson, TransactionsInnerJson, TransactionsJsonUKV200}
import code.api.berlin.group.v1.JSONFactory_BERLIN_GROUP_1.{AccountBalanceV1, AccountBalances, AmountOfMoneyV1, ClosingBookedBody, ExpectedBody, TransactionJsonV1, TransactionsJsonV1, ViewAccount}
import code.api.dynamic.endpoint.helper.practise.PractiseEndpoint
import code.api.util.APIUtil.{defaultJValue, _}
import code.api.util.ApiRole._
import code.api.util.ExampleValue._
import code.api.util.{APIUtil, ApiRole, ApiTrigger, ConsentJWT, CustomJsonFormats, ExampleValue}
import code.api.util.{ApiRole, ApiTrigger, ExampleValue}
import code.api.v2_2_0.JSONFactory220.{AdapterImplementationJson, MessageDocJson, MessageDocsJson}
import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
import code.api.v3_0_0.custom.JSONFactoryCustom300
import code.api.v3_0_0.{LobbyJsonV330, _}
import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, CustomerWithAttributesJsonV310, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _}
import code.api.v4_0_0.{AccountMinimalJson400, BankAttributeBankResponseJsonV400, CardJsonV400, CustomerMinimalJsonV400, FastFirehoseAccountsJsonV400, PostHistoricalTransactionAtBankJson, _}
import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _}
import code.api.v5_0_0.{AccountResponseJson500, CustomerOverviewFlatJsonV500, _}
import code.api.v3_0_0._
import code.api.v3_1_0._
import code.api.v4_0_0._
import code.api.v5_0_0._
import code.api.v5_1_0._
import code.branches.Branches.{Branch, DriveUpString, LobbyString}
import code.consent.ConsentStatus
import code.connectormethod.{JsonConnectorMethod, JsonConnectorMethodMethodBody}
import code.consent.ConsentStatus
import code.dynamicMessageDoc.JsonDynamicMessageDoc
import code.dynamicResourceDoc.JsonDynamicResourceDoc
import code.sandbox.SandboxData
import com.openbankproject.commons.model.enums.TransactionRequestTypes._
import com.openbankproject.commons.model.enums.PaymentServiceTypes._
import com.github.dwickern.macros.NameOf.nameOf
import com.openbankproject.commons.model
import com.openbankproject.commons.model.PinResetReason.{FORGOT, GOOD_SECURITY_PRACTICE}
import com.openbankproject.commons.model.enums.TransactionRequestTypes._
import com.openbankproject.commons.model.enums.{AttributeCategory, CardAttributeType, ChallengeType}
import com.openbankproject.commons.model.{TransactionRequestSimple, UserAuthContextUpdateStatus, ViewBasic, _}
import com.openbankproject.commons.util.{ApiVersion, FieldNameApiVersions, ReflectUtils, RequiredArgs, RequiredInfo}
import com.openbankproject.commons.model._
import com.openbankproject.commons.util.{ApiVersion, FieldNameApiVersions, ReflectUtils}
import net.liftweb.json
import java.net.URLEncoder

import code.api.v5_1_0.{AtmsJsonV510, CustomViewJsonV510, _}
import code.endpointMapping.EndpointMappingCommons
import net.liftweb.json.{Extraction, parse}

import scala.collection.immutable.List
import java.net.URLEncoder
import java.util.Date

/**
* This object prepare all the JSON case classes for Swagger .
Expand All @@ -55,8 +48,6 @@ object SwaggerDefinitionsJSON {

implicit def convertStringToBoolean(value:String) = value.toBoolean

implicit val formats = CustomJsonFormats.formats

lazy val regulatedEntitiesJsonV510: RegulatedEntitiesJsonV510 = RegulatedEntitiesJsonV510(List(regulatedEntityJsonV510))
lazy val regulatedEntityJsonV510: RegulatedEntityJsonV510 = RegulatedEntityJsonV510(
entity_id = "0af807d7-3c39-43ef-9712-82bcfde1b9ca",
Expand Down Expand Up @@ -4230,29 +4221,7 @@ object SwaggerDefinitionsJSON {
api_standard = "Berlin Group",
api_version = "v1.3",
jwt = "eyJhbGciOiJIUzI1NiJ9.eyJlbnRpdGxlbWVudHMiOltdLCJjcmVhdGVkQnlVc2VySWQiOiIiLCJzdWIiOiJmY2YzNDZkMi0xNTNiLTQ0MzAtOWE4Zi1mMzU3Njg1MzM5ODciLCJhdWQiOiIyNjY0NjUwYy04MDkwLTQ4MWUtOGJkOC0wM2E5MmY5Yzg3ZWEiLCJuYmYiOjE3MzAzNzMyNzEsImFjY2VzcyI6eyJhY2NvdW50cyI6W3siaWJhbiI6IlJTMzUyNjAwMDU2MDEwMDE2MTEzNzkifV19LCJpc3MiOiJodHRwczovLzEyNy4wLjAuMTo4MDgwIiwiZXhwIjoxNzMwOTM3NjAwLCJpYXQiOjE3MzAzNzMyNzEsImp0aSI6ImQzM2Y3NDYzLWVlNDktNGU4YS04YTkyLTYxMzhkYzE4M2QxNiIsInZpZXdzIjpbeyJiYW5rX2lkIjoibmxia2IiLCJhY2NvdW50X2lkIjoiOTUzODkyOTctNDVjNC00MGViLTllZmQtMzMxYmExOTQzZGE0Iiwidmlld19pZCI6IlJlYWRBY2NvdW50c0Jlcmxpbkdyb3VwIn1dfQ.SXE4W34596lrSXqZrA8cvQs_fvhjWYilU8VDpXZ3C3Y",
jwt_payload = parse("""{
"createdByUserId": "",
"sub": "fcf346d2-153b-4430-9a8f-f35768533987",
"iss": "https://127.0.0.1:8080",
"aud": "2664650c-8090-481e-8bd8-03a92f9c87ea",
"jti": "d33f7463-ee49-4e8a-8a92-6138dc183d16",
"iat": 1730373271,
"nbf": 1730373271,
"exp": 1730937600,
"entitlements": [],
"views": [ {
"bank_id": "nlbkb",
"account_id": "95389297-45c4-40eb-9efd-331ba1943da4",
"view_id": "ReadAccountsBerlinGroup"
}
],
"access": {
"accounts": [ {
"iban": "RS35260005601001611379"
}
]
}
}""").extractOpt[ConsentJWT],
jwt_payload = SwaggerDefinitionsJsonUtil.jwtPayload,
)
val consentsJsonV510 = ConsentsJsonV510(List(allConsentJsonV510))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package code.api.ResourceDocs1_4_0

import code.api.util.ConsentJWT
import net.liftweb.json._

object SwaggerDefinitionsJsonUtil {
implicit val formats: Formats = DefaultFormats

// General method to parse JSON into any case class
def parseJsonToCaseClass[T](jsonString: String)(implicit mf: Manifest[T]): Option[T] = {
parse(jsonString).extractOpt[T]
}

// Usage example with ConsentJWT, or replace ConsentJWT with any other case class
val jwtPayload: Option[ConsentJWT] = parseJsonToCaseClass[ConsentJWT](
"""{
"createdByUserId": "",
"sub": "fcf346d2-153b-4430-9a8f-f35768533987",
"iss": "https://127.0.0.1:8080",
"aud": "2664650c-8090-481e-8bd8-03a92f9c87ea",
"jti": "d33f7463-ee49-4e8a-8a92-6138dc183d16",
"iat": 1730373271,
"nbf": 1730373271,
"exp": 1730937600,
"entitlements": [],
"views": [ {
"bank_id": "nlbkb",
"account_id": "95389297-45c4-40eb-9efd-331ba1943da4",
"view_id": "ReadAccountsBerlinGroup"
}],
"access": {
"accounts": [ {
"iban": "RS35260005601001611379"
}]
}
}"""
)
}
2 changes: 1 addition & 1 deletion obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8745,7 +8745,7 @@ trait APIMethods400 extends MdcLoggable {
nameOf(getConsentInfos),
"GET",
"/banks/BANK_ID/my/consent-infos",
"Get Consents Info",
"Get My Consents Info",
s"""
|
|This endpoint gets the Consents that the current User created.
Expand Down
5 changes: 4 additions & 1 deletion obp-api/src/main/scala/code/snippet/UserInformation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class UserInformation extends MdcLoggable {
private object providerVar extends RequestVar("")
private object devEmailVar extends RequestVar("")
private object usernameVar extends RequestVar("")
private object userIdVar extends RequestVar("")

def show: CssSel = {
if(!AuthUser.loggedIn_?) {
Expand All @@ -52,6 +53,7 @@ class UserInformation extends MdcLoggable {
} else {
val user: User = AuthUser.getCurrentUser.openOrThrowException(attemptedToOpenAnEmptyBox)
usernameVar.set(user.name)
userIdVar.set(user.userId)
devEmailVar.set(user.emailAddress)
providerVar.set(user.provider)
idTokenVar.set(AuthUser.getIDTokenOfCurrentUser)
Expand All @@ -61,7 +63,8 @@ class UserInformation extends MdcLoggable {
"#user-info-provider" #> SHtml.text(providerVar.is, providerVar(_)) &
"#user-info-email" #> SHtml.text(devEmailVar, devEmailVar(_)) &
"#user-info-id-token" #> SHtml.text(idTokenVar, idTokenVar(_)) &
"#user-info-access-token" #> SHtml.text(accessTokenVar, accessTokenVar(_))
"#user-info-access-token" #> SHtml.text(accessTokenVar, accessTokenVar(_)) &
"#user-info-user-id" #> SHtml.text(userIdVar, accessTokenVar(_))
} & "#register-consumer-success" #> ""
}
}
Expand Down
4 changes: 4 additions & 0 deletions obp-api/src/main/webapp/user-information.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ <h1>User Information</h1>
<label for="user-info-access-token">Access Token</label>
<input readonly type="text" id="user-info-access-token" class="form-control" aria-describedby="consumer-registration-app-name-error">
</div>
<div class="form-group">
<label for="user-info-user-id">User ID</label>
<input readonly type="text" id="user-info-user-id" class="form-control" aria-describedby="consumer-registration-app-name-error">
</div>

</div>
</div>
Expand Down

0 comments on commit 9f43f61

Please sign in to comment.