Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fd6eddc16 | ||
|
|
402525d572 |
No files matched your search
@@ -13,6 +13,16 @@ data:
|
|||||||
interval: 5m
|
interval: 5m
|
||||||
conditions:
|
conditions:
|
||||||
- "[STATUS] == 200"
|
- "[STATUS] == 200"
|
||||||
|
- name: cat-fact
|
||||||
|
url: "https://cat-fact.herokuapp.com/facts/random"
|
||||||
|
interval: 5m
|
||||||
|
conditions:
|
||||||
|
- "[STATUS] == 200"
|
||||||
|
- "[BODY].deleted == false"
|
||||||
|
- "len([BODY].text) > 0"
|
||||||
|
- "[BODY].text == pat(*cat*)"
|
||||||
|
- "[STATUS] == pat(2*)"
|
||||||
|
- "[CONNECTED] == true"
|
||||||
- name: Example
|
- name: Example
|
||||||
url: https://example.com/
|
url: https://example.com/
|
||||||
conditions:
|
conditions:
|
||||||
|
|||||||
+2
-1
@@ -2,12 +2,13 @@ package security
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Handler(handler http.HandlerFunc, security *Config) http.HandlerFunc {
|
func Handler(handler http.HandlerFunc, security *Config) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
usernameEntered, passwordEntered, ok := r.BasicAuth()
|
usernameEntered, passwordEntered, ok := r.BasicAuth()
|
||||||
if !ok || usernameEntered != security.Basic.Username || Sha512(passwordEntered) != security.Basic.PasswordSha512Hash {
|
if !ok || usernameEntered != security.Basic.Username || Sha512(passwordEntered) != strings.ToLower(security.Basic.PasswordSha512Hash) {
|
||||||
w.Header().Set("WWW-Authenticate", "Basic")
|
w.Header().Set("WWW-Authenticate", "Basic")
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
_, _ = w.Write([]byte("Unauthorized"))
|
_, _ = w.Write([]byte("Unauthorized"))
|
||||||
|
|||||||
Reference in new issue
Block a user