Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ LEVEL = Info
;; - <username>.livejournal.com
;;
;; Whether to allow signin in via OpenID
;ENABLE_OPENID_SIGNIN = true
;ENABLE_OPENID_SIGNIN = false
;;
;; Whether to allow registering via OpenID
;; Do not include to rely on rhw DISABLE_REGISTRATION setting
Expand All @@ -1665,8 +1665,8 @@ LEVEL = Info
;; Forbidden URI patterns (POSIX regexp).
;; Space separated.
;; Only used if WHITELISTED_URIS is blank.
;; Example value: loadaverage.org/badguy stackexchange.com/.*spammer
;BLACKLISTED_URIS =
;; Default value blocks localhost and private network IPs to avoid SSRF.
;BLACKLISTED_URIS = localhost 127\.0\.0\.1 10\..* 192\.168\..* 172\.(1[6-9]|2[0-9]|3[0-1])\..* \[::1\] \[f[c-d][0-9a-fA-F]{2}:.*\] \[fe80:.*\]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
16 changes: 15 additions & 1 deletion modules/setting/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,20 @@ func loadServiceFrom(rootCfg ConfigProvider) {
loadQosSetting(rootCfg)
}

var defaultOpenIDBlacklist = []string{
"localhost",
"127\\.0\\.0\\.1",
"10\\..*",
"192\\.168\\..*",
"172\\.(1[6-9]|2[0-9]|3[0-1])\\..*",
"\\[::1\\]",
"\\[f[c-d][0-9a-fA-F]{2}:.*\\]",
"\\[fe80:.*\\]",
}
Comment thread
lunny marked this conversation as resolved.
Outdated
Comment thread
lunny marked this conversation as resolved.
Outdated

func loadOpenIDSetting(rootCfg ConfigProvider) {
sec := rootCfg.Section("openid")
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(false)
Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)
pats := sec.Key("WHITELISTED_URIS").Strings(" ")
if len(pats) != 0 {
Expand All @@ -277,6 +288,9 @@ func loadOpenIDSetting(rootCfg ConfigProvider) {
}
}
pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
if len(pats) == 0 {
pats = defaultOpenIDBlacklist
}
if len(pats) != 0 {
Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
for i, p := range pats {
Expand Down