feat(server): role based authentication system (#2434)
- Parse toml configuration file, see https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md#authentication - Retro-compatible with existing AND documented routes, until after v3.41 release - Log a warning if an unprotected-by-default route is accessed unprotected - Authentication methods: none, apikey, basic - `genkey` command to generate API keys - move log middleware to internal/server/middlewares/log Co-authored-by: Joe Jose <45399349+joejose97@users.noreply.github.com>
This commit is contained in:
20
internal/server/middlewares/auth/none.go
Normal file
20
internal/server/middlewares/auth/none.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package auth
|
||||
|
||||
import "net/http"
|
||||
|
||||
type noneMethod struct{}
|
||||
|
||||
func newNoneMethod() *noneMethod {
|
||||
return &noneMethod{}
|
||||
}
|
||||
|
||||
// equal returns true if another auth checker is equal.
|
||||
// This is used to deduplicate checkers for a particular route.
|
||||
func (n *noneMethod) equal(other authorizationChecker) bool {
|
||||
_, ok := other.(*noneMethod)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (n *noneMethod) isAuthorized(_ http.Header, _ *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user