mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-19 05:31:54 +00:00
Clearly indicate insecure mode at startup.
This commit is contained in:
@@ -31,6 +31,10 @@ func IsUnauthorized(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func InsecureMode() bool {
|
||||
return os.Getenv("INSECURE") == "very"
|
||||
}
|
||||
|
||||
func GetHost(r *http.Request) string {
|
||||
// FIXME: handle IDNA
|
||||
host, _, err := net.SplitHostPort(r.Host)
|
||||
@@ -180,7 +184,7 @@ func authorizeWildcardMatch(r *http.Request) ([]string, error) {
|
||||
func authorizeRequest(r *http.Request, allowWildcard bool) ([]string, error) {
|
||||
causes := []error{AuthError{http.StatusUnauthorized, "unauthorized"}}
|
||||
|
||||
if os.Getenv("INSECURE") == "very" {
|
||||
if InsecureMode() {
|
||||
log.Println("auth: INSECURE mode: allow any")
|
||||
return nil, nil // for testing only
|
||||
}
|
||||
|
||||
@@ -100,7 +100,11 @@ func main() {
|
||||
memlimit.WithRatio(0.9),
|
||||
)
|
||||
|
||||
log.Println("ready")
|
||||
if InsecureMode() {
|
||||
log.Println("ready (INSECURE)")
|
||||
} else {
|
||||
log.Println("ready")
|
||||
}
|
||||
|
||||
go serveHandler("pages", config.Listen.Pages, ServePages)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user