Browse Source

Fixed cert auto renew logic

Toby Chui 5 months ago
parent
commit
a13fa98f89
3 changed files with 28 additions and 4 deletions
  1. 4 1
      mod/acme/autorenew.go
  2. 2 2
      mod/acme/utils.go
  3. 22 1
      web/components/sso.html

+ 4 - 1
mod/acme/autorenew.go

@@ -88,9 +88,12 @@ func NewAutoRenewer(config string, certFolder string, renewCheckInterval int64,
 		AcmeHandler:       AcmeHandler,
 		RenewerConfig:     &renewerConfig,
 		RenewTickInterval: renewCheckInterval,
+		EarlyRenewDays:    earlyRenewDays,
 		Logger:            logger,
 	}
 
+	thisRenewer.Logf("ACME early renew set to "+fmt.Sprint(earlyRenewDays)+" days and check interval set to "+fmt.Sprint(renewCheckInterval)+" seconds", nil)
+
 	if thisRenewer.RenewerConfig.Enabled {
 		//Start the renew ticker
 		thisRenewer.StartAutoRenewTicker()
@@ -103,7 +106,7 @@ func NewAutoRenewer(config string, certFolder string, renewCheckInterval int64,
 }
 
 func (a *AutoRenewer) Logf(message string, err error) {
-	a.Logger.PrintAndLog("CertRenew", message, err)
+	a.Logger.PrintAndLog("cert-renew", message, err)
 }
 
 func (a *AutoRenewer) StartAutoRenewTicker() {

+ 2 - 2
mod/acme/utils.go

@@ -5,14 +5,14 @@ import (
 	"encoding/pem"
 	"errors"
 	"fmt"
-	"io/ioutil"
+	"os"
 	"time"
 )
 
 // Get the issuer name from pem file
 func ExtractIssuerNameFromPEM(pemFilePath string) (string, error) {
 	// Read the PEM file
-	pemData, err := ioutil.ReadFile(pemFilePath)
+	pemData, err := os.ReadFile(pemFilePath)
 	if err != nil {
 		return "", err
 	}

+ 22 - 1
web/components/sso.html

@@ -13,7 +13,7 @@
             </h4>
         </div>
         <div class="ui form">
-            <h4 class="ui dividing header">Oauth2 Server</h4>
+            <h3 class="ui dividing header">Oauth2 Server Settings</h3>
             <div class="field">
                 <div class="ui toggle checkbox">
                     <input type="checkbox" name="enableOauth2">
@@ -38,6 +38,27 @@
                 <small>The exposed authentication URL of the Oauth2 server, usually <code>https://auth.example.com</code> or <code>https://sso.yourdomain.com</code>. <b>Remember to include the http:// or https:// in your URL.</b></small>
             </div>
         </div>
+        <br>
+        <div class="ui form">
+            <h3 class="ui dividing header">Zoraxy SSO Settings</h3>
+            <div class="field">
+                <label>Default Redirection URL </label>   
+                <div class="ui fluid input">
+                    <input type="text" name="defaultSiteURL" placeholder="https://yourdomain.com">
+                </div>
+                <small>The default URL to redirect to after login if redirection target is not set</small>
+            </div>
+
+            <button class="ui basic button"> <i class="ui green check icon"></i> Apply Changes </button>
+        </div>
+        <div class="ui basic message">
+            <div class="header">
+                <i class="ui yellow exclamation triangle icon"></i> Important Notes about Zoraxy SSO
+            </div>
+            <p>Zoraxy SSO, if enabled in HTTP Proxy rule, will automatically intercept the proxy request and provide an SSO interface on upstreams that do not support OAuth natively.
+                It is basically like basic auth with a login page. <b> The same user credential can be used in OAuth sign-in and Zoraxy SSO sign-in.</b>
+            </p>
+        </div>
         <div class="ui divider"></div>
         <div>
             <h3 class="ui header">