-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: Fix issue where website auth_basic is not effective #8045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1156,21 +1156,23 @@ func GteSiteDir(alias string) string { | |
| } | ||
|
|
||
| const ( | ||
| SiteConf = "SiteConf" | ||
| SiteAccessLog = "access.log" | ||
| SiteErrorLog = "error.log" | ||
| WebsiteRootDir = "WebsiteRootDir" | ||
| SiteDir = "SiteDir" | ||
| SiteIndexDir = "SiteIndexDir" | ||
| SiteProxyDir = "SiteProxyDir" | ||
| SiteSSLDir = "SiteSSLDir" | ||
| SiteReWritePath = "SiteReWritePath" | ||
| SiteRedirectDir = "SiteRedirectDir" | ||
| SiteCacheDir = "SiteCacheDir" | ||
| SiteConfDir = "SiteConfDir" | ||
| SitesRootDir = "SitesRootDir" | ||
| DefaultDir = "DefaultDir" | ||
| DefaultRewriteDir = "DefaultRewriteDir" | ||
| SiteConf = "SiteConf" | ||
| SiteAccessLog = "access.log" | ||
| SiteErrorLog = "error.log" | ||
| WebsiteRootDir = "WebsiteRootDir" | ||
| SiteDir = "SiteDir" | ||
| SiteIndexDir = "SiteIndexDir" | ||
| SiteProxyDir = "SiteProxyDir" | ||
| SiteSSLDir = "SiteSSLDir" | ||
| SiteReWritePath = "SiteReWritePath" | ||
| SiteRedirectDir = "SiteRedirectDir" | ||
| SiteCacheDir = "SiteCacheDir" | ||
| SiteConfDir = "SiteConfDir" | ||
| SitesRootDir = "SitesRootDir" | ||
| DefaultDir = "DefaultDir" | ||
| DefaultRewriteDir = "DefaultRewriteDir" | ||
| SiteRootAuthBasicPath = "SiteRootAuthBasicPath" | ||
| SitePathAuthBasicDir = "SitePathAuthBasicDir" | ||
| ) | ||
|
|
||
| func GetSitePath(website model.Website, confType string) string { | ||
|
|
@@ -1195,6 +1197,10 @@ func GetSitePath(website model.Website, confType string) string { | |
| return path.Join(GteSiteDir(website.Alias), "rewrite", website.Alias+".conf") | ||
| case SiteRedirectDir: | ||
| return path.Join(GteSiteDir(website.Alias), "redirect") | ||
| case SiteRootAuthBasicPath: | ||
| return path.Join(GteSiteDir(website.Alias), "auth_basic", "auth.pass") | ||
| case SitePathAuthBasicDir: | ||
| return path.Join(GteSiteDir(website.Alias), "path_auth") | ||
| } | ||
| return "" | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no known inconsistencies or errors in the provided code, but some improvements could be suggested:
And similarly create similar helpers like this one In general, there isn't an immediate issue here that would require fixing in terms of performance nor style-related issues. All parts seem correct without major flaws apart from minor adjustments needed based on contextual needs mentioned above. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,6 +211,19 @@ const checkSimplePassword = (rule: any, value: any, callback: any) => { | |
| } | ||
| }; | ||
|
|
||
| const checkAuthBasicPassword = (rule: any, value: any, callback: any) => { | ||
| if (value === '' || typeof value === 'undefined' || value == null) { | ||
| callback(new Error(i18n.global.t('commons.rule.authBasicPassword'))); | ||
| } else { | ||
| const reg = /^[a-zA-Z0-9_\-\.@$!%*?&]{1,72}$/; | ||
| if (!reg.test(value)) { | ||
| callback(new Error(i18n.global.t('commons.rule.authBasicPassword'))); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| const checkDBName = (rule: any, value: any, callback: any) => { | ||
| if (value === '' || typeof value === 'undefined' || value == null) { | ||
| callback(new Error(i18n.global.t('commons.rule.dbName'))); | ||
|
|
@@ -622,6 +635,7 @@ interface CommonRule { | |
| phpExtensions: FormItemRule; | ||
| supervisorName: FormItemRule; | ||
| domainOrIP: FormItemRule; | ||
| authBasicPassword: FormItemRule; | ||
|
|
||
| paramCommon: FormItemRule; | ||
| paramComplexity: FormItemRule; | ||
|
|
@@ -865,4 +879,8 @@ export const Rules: CommonRule = { | |
| validator: checkPhone, | ||
| trigger: 'blur', | ||
| }, | ||
| authBasicPassword: { | ||
| validator: checkAuthBasicPassword, | ||
| trigger: 'blur', | ||
| }, | ||
| }; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet appears to be part of an Angular application that defines common form rules for various aspects like passwords, database names, etc. However, due to an update in knowledge cutoff date from September 1st, 2021 to March 3rd, 2025:
Suggestion: Use lodash's string test function instead of regex expressions.
Optimization Suggestions:
Potential Issues: Final advice: |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too long to be checked directly on this platform. You can run it in your local environment and verify manually that there aren’t any issues.
However, here's some guidance:
For further assistance beyond just checking these style violations, you might consider consulting professional software developers who specialize in writing clear, well-formatted Go Code.
I'd also suggest using a tool or editor designed for Go development like IntelliJ IDEA Go, which supports lint and formatting checks including style guides based on Golang standards.
Remember to update the knowledge cutoff date if the question changes since last time I checked.