mirror of
https://github.com/ditkrg/traefik-users-blocker-plugin.git
synced 2026-01-23 06:56:51 +00:00
remove path
This commit is contained in:
parent
cabcbbb166
commit
7a03599d16
8
main.go
8
main.go
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
type Path struct {
|
type Path struct {
|
||||||
Base string `json:"base,omitempty"`
|
Base string `json:"base,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -71,11 +70,10 @@ func (a *UsersBlocker) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range a.paths {
|
for _, path := range a.paths {
|
||||||
blockedPath := path.Base + path.Path
|
isPathMatched := strings.HasPrefix(req.URL.Path, path.Base)
|
||||||
isPathBlocked := strings.HasPrefix(req.URL.Path, blockedPath)
|
|
||||||
|
|
||||||
if isPathBlocked {
|
if isPathMatched {
|
||||||
message := fmt.Sprintf("blocked path %s (matched with %s) for user %s", req.URL.Path, blockedPath, userId)
|
message := fmt.Sprintf("blocked path %s (matched with %s) for user %s", req.URL.Path, path.Base, userId)
|
||||||
os.Stdout.WriteString(message)
|
os.Stdout.WriteString(message)
|
||||||
http.Error(rw, message, http.StatusForbidden)
|
http.Error(rw, message, http.StatusForbidden)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user