tweaked the custom_webapp folder added four webui_ props

This commit is contained in:
hongwei 2020-04-26 10:19:05 +02:00
parent 9d3fb042f0
commit 9b40921c1e
6 changed files with 78 additions and 11 deletions

View File

@ -365,6 +365,9 @@ You can obfuscate passwords in the props file the same way as for jetty:
## Code Generation
Please refer to the [Code Generation](https://github.com/OpenBankProject/OBP-API/blob/develop/CONTRIBUTING.md##code-generation) for links
## Customize Portal WebPage
Please refer to the [Custom Webapp](obp-api/src/main/resources/custom_webapp/README.md) for links
## Using jetty password obfuscation with props file
You can obfuscate passwords in the props file the same way as for jetty:

View File

@ -0,0 +1,14 @@
# custom_webapp folder
## Introduction
This folder will contain the customer's front end files, it can not be tracked in the github. So the default is empty.
If you set the props `use_custom_webapp=true`, that means you will use your own design of the frontend web page.
Then you **MUST** copy all the files from the folder `OBP-API/obp-api/src/main/webapp` to here, and customize the HTML, CSS,
or JS files as your requirements.

View File

@ -400,6 +400,9 @@ webui_oauth_2_documentation_url =
oauth2_server_url =
# Link to Privacy Policy on signup page
#webui_signup_form_title_text = Sign Up
#webui_signup_body_password_repeat_text = Repeat
#webui_agree_terms_html=<div id="signup-agree-terms" class="checkbox"><label><input type="checkbox" />I hereby agree to the <a href="$url" title="T &amp; C">Terms and Conditions</a></label></div>
webui_agree_privacy_policy_url = https://openbankproject.com/privacy-policy
webui_agree_privacy_policy_html_text =<div id="signup-agree-privacy-policy"><label>By submitting this information you consent to processing your data by TESOBE GmbH according to our <a href="$url" title="Privacy Policy">Privacy Policy</a>. TESOBE shall use this information to send you emails and provide customer support.</label></div>
@ -470,6 +473,8 @@ webui_show_dummy_user_tokens=false
webui_register_consumer_success_message_webpage = Thanks for registering your consumer with the Open Bank Project API! Here is your developer information. Please save it in a secure location.
webui_register_consumer_success_message_email = Thank you for registering to use the Open Bank Project API.
#Log in page
#webui_login_button_text =
## End of webui_ section ########

View File

@ -29,6 +29,7 @@ package bootstrap.liftweb
import java.io.{File, FileInputStream}
import java.util.{Locale, TimeZone}
import org.apache.commons.io.FileUtils
import code.CustomerDependants.MappedCustomerDependant
import code.DynamicData.DynamicData
import code.DynamicEndpoint.DynamicEndpoint
@ -243,7 +244,31 @@ class Boot extends MdcLoggable {
import java.security.SecureRandom
val rand = new SecureRandom(SecureRandom.getSeed(20))
rand
//If use_custom_webapp=true, this will copy all the files from `OBP-API/obp-api/src/main/webapp` to `OBP-API/obp-api/src/main/resources/custom_webapp`
if (APIUtil.getPropsAsBoolValue("use_custom_webapp", false)){
//this `LiftRules.getResource` will get the path of `OBP-API/obp-api/src/main/webapp`:
LiftRules.getResource("/").map { url =>
// this following will get the path of `OBP-API/obp-api/src/main/resources/custom_webapp`
val source = if (getClass().getClassLoader().getResource("custom_webapp") == null)
throw new RuntimeException("If you set `use_custom_webapp = true`, custom_webapp folder can not be Empty!!")
else
getClass().getClassLoader().getResource("custom_webapp").getPath
val srcDir = new File(source);
// The destination directory to copy to. This directory
// doesn't exists and will be created during the copy
// directory process.
val destDir = new File(url.getPath)
// Copy source directory into destination directory
// including its child directories and files. When
// the destination directory is not exists it will
// be created. This copy process also preserve the
// date information of the file.
FileUtils.copyDirectory(srcDir, destDir)
}
}
// ensure our relational database's tables are created/fit the schema
val connector = APIUtil.getPropsValue("connector").openOrThrowException("no connector set")

View File

@ -89,7 +89,18 @@ class AuthUser extends MegaProtoUser[AuthUser] with MdcLoggable {
override lazy val password = new MyPasswordNew
def signupPasswordRepeatText = getWebUiPropsValue("webui_signup_body_password_repeat_text", S.?("repeat"))
class MyPasswordNew extends MappedPassword(this) {
override def _toForm: Box[NodeSeq] = {
S.fmapFunc({s: List[String] => this.setFromAny(s)}){funcName =>
Full(<span>{appendFieldId(<input type={formInputType} name={funcName}
value={get.toString}/>)}&nbsp;{signupPasswordRepeatText}&nbsp;<input
type={formInputType} name={funcName}
value={get.toString}/></span>)
}
}
override def displayName = fieldOwner.passwordDisplayName
@ -409,12 +420,17 @@ import net.liftweb.util.Helpers._
}
def agreeTerms = {
val url = getWebUiPropsValue("webui_agree_terms_url", "")
if (url.isEmpty) {
s""
} else {
scala.xml.Unparsed(s"""<div id="signup-agree-terms" class="checkbox"><label><input type="checkbox" />I hereby agree to the <a href="$url" title="T &amp; C">Terms and Conditions</a></label></div>""")
def agreeTermsDiv = {
val agreeTermsHtml = getWebUiPropsValue("webui_agree_terms_html", "")
if(agreeTermsHtml.isEmpty){
val url = getWebUiPropsValue("webui_agree_terms_url", "")
if (url.isEmpty) {
s""
} else {
scala.xml.Unparsed(s"""<div id="signup-agree-terms" class="checkbox"><label><input type="checkbox" />I hereby agree to the <a href="$url" title="T &amp; C">Terms and Conditions</a></label></div>""")
}
} else{
scala.xml.Unparsed(s"""$agreeTermsHtml""")
}
}
@ -428,13 +444,15 @@ import net.liftweb.util.Helpers._
}
}
def signupFormTitle = getWebUiPropsValue("webui_signup_form_title_text", S.?("sign.up"))
override def signupXhtml (user:AuthUser) = {
<div id="signup">
<form method="post" action={S.uri}>
<h1>Sign Up</h1>
<h1>{signupFormTitle}</h1>
<div id="signup-error" class="alert alert-danger hide"><span data-lift="Msg?id=error"/></div>
{localForm(user, false, signupFields)}
{agreeTerms}
{agreeTermsDiv}
{agreePrivacyPolicy}
<div id="signup-submit">
<input type="submit" />
@ -773,11 +791,13 @@ def restoreSomeSessions(): Unit = {
}
}
def loginButtonText = getWebUiPropsValue("webui_login_button_text", S.?("log.in"))
// In this function we bind submit button to loginAction function.
// In case that unique token of submit button cannot be paired submit action will be omitted.
// Implemented in order to prevent a CSRF attack
def insertSubmitButton = {
scala.xml.XML.loadString(loginSubmitButton(S.?("Login"), loginAction _).toString().replace("type=\"submit\"","class=\"submit\" type=\"submit\""))
scala.xml.XML.loadString(loginSubmitButton(loginButtonText, loginAction _).toString().replace("type=\"submit\"","class=\"submit\" type=\"submit\""))
}
val bind =

View File

@ -46,7 +46,7 @@ class Login {
".logout [href]" #> {
AuthUser.logoutPath.foldLeft("")(_ + "/" + _)
} &
".logout #username *" #> AuthUser.getCurrentUserUsername
"#loggedIn-username *" #> AuthUser.getCurrentUserUsername
}
}