Skip to content

Commit

Permalink
v1.4.1 custom 5-shield html, merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
janusec2 committed Jul 12, 2023
2 parents 6b51b23 + caa4a4b commit 41fe2d0
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 64 deletions.
2 changes: 1 addition & 1 deletion data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
// IsPrimary i.e. Is Primary Node
IsPrimary bool
// Version of JANUSEC
Version = "1.4.0"
Version = "1.4.1"
)

// InitConfig init Data Access Layer
Expand Down
63 changes: 61 additions & 2 deletions data/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var (
<html>
<head>
<title>403 Forbidden</title>
</head>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
Expand All @@ -55,8 +54,8 @@ var (
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<div class="block_div">
<h1 class="text-logo">JANUSEC</h1>
Expand All @@ -66,6 +65,58 @@ var (
</body>
</html>
`

shieldHTML string = `<!DOCTYPE html>
<html>
<head>
<title>Checking</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
.text-logo {
display: block;
width: 260px;
font-size: 48px;
background-color: #F9F9F9;
color: #f5f5f5;
text-decoration: none;
text-shadow: 2px 2px 4px #000000;
box-shadow: 2px 2px 3px #D5D5D5;
padding: 15px;
margin: auto;
}
.block_div {
padding: 10px;
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<div class="block_div">
<h1 class="text-logo">JANUSEC</h1>
<hr>
<p>
Checking your browser, please wait <span id="countdown">5</span> seconds ...
</p>
</div>
<script>
var t=5;
var countdown=setInterval(function(){
t--;
document.getElementById("countdown").innerHTML=t;
if(t<=0) {
clearInterval(countdown);
window.location.href = "/.auth/shield?callback={{ .Callback }}";
}
}, 1000);
</script>
</body>
</html>`
)

// UpdateBackendLastModified ...
Expand Down Expand Up @@ -144,6 +195,10 @@ func InitDefaultSettings() {
if !DAL.ExistsSetting("block_html") {
_ = DAL.SaveStringSetting("block_html", blockHTML)
}
if !DAL.ExistsSetting("shield_html") {
// v1.4.1 added
_ = DAL.SaveStringSetting("shield_html", shieldHTML)
}

// SMTP shared with PrimarySetting
if !DAL.ExistsSetting("smtp_enabled") {
Expand Down Expand Up @@ -313,6 +368,7 @@ func LoadSettings() {
PrimarySetting.SearchEngines = DAL.SelectStringSetting("search_engines")
PrimarySetting.WebSSHEnabled = DAL.SelectBoolSetting("webssh_enabled")
PrimarySetting.BlockHTML = DAL.SelectStringSetting("block_html")
PrimarySetting.ShieldHTML = DAL.SelectStringSetting("shield_html") // v1.4.1 added
// v1.2.0 add SMTP
smtpSetting := &models.SMTPSetting{}
smtpSetting.SMTPEnabled = DAL.SelectBoolSetting("smtp_enabled")
Expand Down Expand Up @@ -340,6 +396,7 @@ func LoadSettings() {
NodeSetting.SkipSEEnabled = PrimarySetting.SkipSEEnabled
NodeSetting.SearchEnginesPattern = UpdateSecondShieldPattern(PrimarySetting.SearchEngines)
NodeSetting.BlockHTML = PrimarySetting.BlockHTML
NodeSetting.ShieldHTML = PrimarySetting.ShieldHTML
// NodeSetting.SMTP and PrimarySetting.SMTP point to the same SMTP setting
NodeSetting.SMTP = smtpSetting
// LoadAuthConfig
Expand Down Expand Up @@ -667,6 +724,8 @@ func UpdatePrimarySetting(r *http.Request, body []byte, clientIP string, authUse
NodeSetting.SearchEnginesPattern = UpdateSecondShieldPattern(PrimarySetting.SearchEngines)
DAL.SaveStringSetting("block_html", PrimarySetting.BlockHTML)
NodeSetting.BlockHTML = PrimarySetting.BlockHTML
DAL.SaveStringSetting("shield_html", PrimarySetting.ShieldHTML)
NodeSetting.ShieldHTML = PrimarySetting.ShieldHTML
DAL.SaveBoolSetting("smtp_enabled", PrimarySetting.SMTP.SMTPEnabled)
DAL.SaveStringSetting("smtp_server", PrimarySetting.SMTP.SMTPServer)
DAL.SaveStringSetting("smtp_port", PrimarySetting.SMTP.SMTPPort)
Expand Down
56 changes: 1 addition & 55 deletions gateway/shield.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func SecondShieldAuthorization(w http.ResponseWriter, r *http.Request) {
// GenerateShieldPage for first access if 5-second shield enabled
func GenerateShieldPage(w http.ResponseWriter, r *http.Request, urlPath string) {
if tmplShieldReq == nil {
tmplShieldReq, _ = template.New("shieldReq").Parse(shieldHTML)
tmplShieldReq, _ = template.New("shieldReq").Parse(data.NodeSetting.ShieldHTML)
}
session, _ := store.Get(r, "janusec-token")
session.Values["timestamp"] = time.Now().Unix()
Expand All @@ -94,57 +94,3 @@ func GenerateShieldPage(w http.ResponseWriter, r *http.Request, urlPath string)
utils.DebugPrintln("GenerateShieldPage tmpl.Execute error", err)
}
}

const shieldHTML = `<!DOCTYPE html>
<html>
<head>
<title>Checking</title>
</head>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
.text-logo {
display: block;
width: 260px;
font-size: 48px;
background-color: #F9F9F9;
color: #f5f5f5;
text-decoration: none;
text-shadow: 2px 2px 4px #000000;
box-shadow: 2px 2px 3px #D5D5D5;
padding: 15px;
margin: auto;
}
.block_div {
padding: 10px;
width: 70%;
margin: auto;
}
</style>
<body>
<div class="block_div">
<h1 class="text-logo">JANUSEC</h1>
<hr>
<p>
Checking your browser, please wait <span id="countdown">5</span> seconds ...
</p>
</div>
<script>
var t=5;
var countdown=setInterval(function(){
t--;
document.getElementById("countdown").innerHTML=t;
if(t<=0) {
clearInterval(countdown);
window.location.href = "/.auth/shield?callback={{ .Callback }}";
}
}, 1000);
</script>
</body>
</html>
`
6 changes: 6 additions & 0 deletions models/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ type PrimarySetting struct {
// BlockHTML, v1.4.0 added
BlockHTML string `json:"block_html"`

// ShieldHTML for 5-second shield, v1.4.1 added
ShieldHTML string `json:"shield_html"`

// WAFLogDays for WAF logs
WAFLogDays int64 `json:"waf_log_days"`

Expand Down Expand Up @@ -175,6 +178,9 @@ type NodeShareSetting struct {
// BlockHTML, v1.4.0 added
BlockHTML string `json:"block_html"`

// ShieldHTML for 5-second shield, v1.4.1 added
ShieldHTML string `json:"shield_html"`

// AuthConfig for authentication
AuthConfig *OAuthConfig `json:"auth_config"`

Expand Down
2 changes: 1 addition & 1 deletion release_batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ printf "Creating installation package\n"
printf "Checklist:\n"
printf "* Angular Admin Version Check. \n"
printf "* Janusec Version Check. \n"
version="1.4.0"
version="1.4.1"
printf "Version: ${version} \n"

read -r -p "Are You Sure? [Y/n] " option
Expand Down
2 changes: 1 addition & 1 deletion static/janusec-admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

<body>
<app-root></app-root>
<script src="/janusec-admin/runtime-es2015.871528d607deca2f7955.js" type="module"></script><script src="/janusec-admin/runtime-es5.871528d607deca2f7955.js" nomodule defer></script><script src="/janusec-admin/polyfills-es5.9eae68ed709714788c31.js" nomodule defer></script><script src="/janusec-admin/polyfills-es2015.1e29effa56bec4fa8b35.js" type="module"></script><script src="/janusec-admin/main-es2015.098172721d6d09a63b25.js" type="module"></script><script src="/janusec-admin/main-es5.098172721d6d09a63b25.js" nomodule defer></script></body>
<script src="/janusec-admin/runtime-es2015.871528d607deca2f7955.js" type="module"></script><script src="/janusec-admin/runtime-es5.871528d607deca2f7955.js" nomodule defer></script><script src="/janusec-admin/polyfills-es5.a6f32ca028f84d9bc10b.js" nomodule defer></script><script src="/janusec-admin/polyfills-es2015.81399a8d584c75814007.js" type="module"></script><script src="/janusec-admin/main-es2015.0c666de6e5ba0fed0aad.js" type="module"></script><script src="/janusec-admin/main-es5.0c666de6e5ba0fed0aad.js" nomodule defer></script></body>

</html>

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion static/janusec-admin/main-es5.098172721d6d09a63b25.js

This file was deleted.

1 change: 1 addition & 0 deletions static/janusec-admin/main-es5.0c666de6e5ba0fed0aad.js

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 41fe2d0

Please sign in to comment.