Merge pull request #1621 from hongwei1/develop

bugfix/for the checkExternalUserViaConnector method
This commit is contained in:
Marko Milić 2020-07-01 13:31:46 +02:00 committed by GitHub
commit 5f2154bca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 494 additions and 483 deletions

View File

@ -35,6 +35,10 @@ object ExampleValue {
lazy val usernameExample = ConnectorField("felixsmith", s"The username the user uses to authenticate.")
glossaryItems += makeGlossaryItem("User.username", usernameExample)
lazy val passwordExample = ConnectorField("password", s"The password the user uses to authenticate.")
glossaryItems += makeGlossaryItem("User.password", passwordExample)
lazy val userNameExample = ConnectorField("felixsmith", s"The userName the user uses to authenticate.")
glossaryItems += makeGlossaryItem("User.userNameExample", userNameExample)
@ -170,7 +174,16 @@ object ExampleValue {
lazy val gitCommitExample = ConnectorField("59623811dd8a41f6ffe67be46954eee11913dc28", "Identifies the code running on the OBP-API (Connector) or Adapter.")
lazy val emailExample = ConnectorField("eveline@example.com", "An email address.")
lazy val subExample = ConnectorField(s"${userNameExample.value}","An identifier for the user, unique among all OBP-API users and never reused")
lazy val issExample = ConnectorField("String","The Issuer Identifier for the Issuer of the response.")
lazy val audExample = ConnectorField("String","Identifies the audience that this ID token is intended for. It must be one of the OBP-API client IDs of your application.")
lazy val jtiExample = ConnectorField("String","(JWT ID) claim provides a unique identifier for the JWT.")
lazy val iatExample = ConnectorField("String","The iat (issued at) claim identifies the time at which the JWT was issued. Represented in Unix time (integer seconds).")
lazy val nbfExample = ConnectorField("String","The nbf (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. Represented in Unix time (integer seconds).")
lazy val expExample = ConnectorField("String","The exp (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. Represented in Unix time (integer seconds).")
lazy val emailVerifiedExample = ConnectorField("String","If the email is verified or not.")
lazy val emailExample = ConnectorField(s"${userNameExample.value}@example.com", "An email address.")
lazy val branchIdExample = ConnectorField("DERBY6", "Uniquely identifies the Branch in combination with the bankId.")
glossaryItems += makeGlossaryItem("Branch.branch_id", branchIdExample)

View File

@ -74,7 +74,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
val connectorName = "stored_procedure_vDec2019"
//---------------- dynamic start -------------------please don't modify this line
// ---------- created on 2020-06-30T21:05:01Z
// ---------- created on 2020-07-01T12:01:48Z
messageDocs += getAdapterInfoDoc
def getAdapterInfoDoc = MessageDoc(
@ -380,12 +380,12 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
inboundTopic = None,
exampleOutboundMessage = (
OutBoundGetUser(name=userNameExample.value,
password="string")
password=passwordExample.value)
),
exampleInboundMessage = (
InBoundGetUser(status=MessageDocsSwaggerDefinitions.inboundStatus,
data= InboundUser(email=emailExample.value,
password="string",
password=passwordExample.value,
displayName="string"))
),
adapterImplementation = Some(AdapterImplementation("- Core", 1))
@ -408,20 +408,20 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
inboundTopic = None,
exampleOutboundMessage = (
OutBoundCheckExternalUserCredentials(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext,
name="string",
password="string")
username=usernameExample.value,
password=passwordExample.value)
),
exampleInboundMessage = (
InBoundCheckExternalUserCredentials(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext,
status=MessageDocsSwaggerDefinitions.inboundStatus,
data= InboundExternalUser(aud="string",
exp="string",
iat="string",
iss="string",
sub="string",
data= InboundExternalUser(aud=audExample.value,
exp=expExample.value,
iat=iatExample.value,
iss=issExample.value,
sub=subExample.value,
azp=Some("string"),
email=Some(emailExample.value),
emailVerified=Some("string"),
emailVerified=Some(emailVerifiedExample.value),
name=Some(userNameExample.value)))
),
adapterImplementation = Some(AdapterImplementation("- Core", 1))
@ -5649,7 +5649,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
response.map(convertToTuple[Boolean](callContext))
}
// ---------- created on 2020-06-30T21:05:01Z
// ---------- created on 2020-07-01T12:01:48Z
//---------------- dynamic end ---------------------please don't modify this line
private val availableOperation = DynamicEntityOperation.values.map(it => s""""$it"""").mkString("[", ", ", "]")

View File

@ -675,6 +675,7 @@ import net.liftweb.util.Helpers._
* 3 if not existing, will create new AuthUser.
* @return Return the authUser
*/
@deprecated("we have @checkExternalUserViaConnector method ","01-07-2020")
def getUserFromConnector(name: String, password: String):Box[AuthUser] = {
Connector.connector.vend.getUser(name, password) match {
case Full(InboundUser(extEmail, extPassword, extUsername)) => {
@ -719,8 +720,8 @@ import net.liftweb.util.Helpers._
* 3 if not existing, will create new AuthUser.
* @return Return the authUser
*/
def checkExternalUserViaConnector(name: String, password: String):Box[AuthUser] = {
Connector.connector.vend.checkExternalUserCredentials(name, password, None) match {
def checkExternalUserViaConnector(username: String, password: String):Box[AuthUser] = {
Connector.connector.vend.checkExternalUserCredentials(username, password, None) match {
case Full(InboundExternalUser(aud, exp, iat, iss, sub, azp, email, emailVerified, name)) =>
val user = findUserByUsernameLocally(sub) match { // Check if the external user is already created locally
case Full(user) if user.validated_? => // Return existing user if found
@ -875,6 +876,7 @@ def restoreSomeSessions(): Unit = {
case _ =>
LoginAttempt.incrementBadLoginAttempts(username.get)
Empty
S.error(Helper.i18n("invalid.login.credentials"))
}
//If there is NO the username, throw the error message.
@ -927,18 +929,14 @@ def restoreSomeSessions(): Unit = {
if (connector.startsWith("kafka") || connector == "obpjvm") {
for {
user <- getUserFromConnector(name, password)
//u <- user.user.foreign // this will be issue when the resource user is in remote side
u <- Users.users.vend.getUserByUserName(name)
v <- Full (updateUserAccountViews(u, None))
} yield {
user
}
} else {
for {
user <- checkExternalUserViaConnector(name, password)
//u <- user.user.foreign // this will be issue when the resource user is in remote side
u <- Users.users.vend.getUserByUserName(name)
v <- Full (updateUserAccountViews(u, None))
} yield {
user
}

View File

@ -1286,6 +1286,6 @@ case class InBoundCreateDirectDebit(inboundAdapterCallContext: InboundAdapterCal
case class OutBoundDeleteCustomerAttribute(outboundAdapterCallContext: OutboundAdapterCallContext, customerAttributeId: String) extends TopicTrait
case class InBoundDeleteCustomerAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: Boolean) extends InBoundTrait[Boolean]
case class OutBoundCheckExternalUserCredentials(outboundAdapterCallContext: OutboundAdapterCallContext, name: String, password: String) extends TopicTrait
case class OutBoundCheckExternalUserCredentials(outboundAdapterCallContext: OutboundAdapterCallContext, username: String, password: String) extends TopicTrait
case class InBoundCheckExternalUserCredentials(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: InboundExternalUser) extends InBoundTrait[InboundExternalUser]
// --------------------- some special connector methods corresponding InBound and OutBound -- end --