only allow admin access via unix socket
This commit is contained in:
parent
39cae64854
commit
13780f1c74
5 changed files with 73 additions and 16 deletions
|
|
@ -5,7 +5,6 @@ package server
|
|||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
|
||||
"git.giftfish.de/ston1th/keyctl/pkg/api/types"
|
||||
"git.giftfish.de/ston1th/keyctl/pkg/api/v1/schema"
|
||||
|
|
@ -14,16 +13,21 @@ import (
|
|||
|
||||
func local(h types.CtxHandler) types.CtxHandler {
|
||||
return func(ctx *types.Context) {
|
||||
addr, err := netip.ParseAddr(ctx.ClientIP())
|
||||
if err != nil {
|
||||
ctx.Err(types.ErrForbidden)
|
||||
ip := ctx.ClientIP()
|
||||
if ip == "@" {
|
||||
h(ctx)
|
||||
return
|
||||
}
|
||||
if !addr.IsLoopback() {
|
||||
ctx.Err(types.ErrForbidden)
|
||||
return
|
||||
}
|
||||
h(ctx)
|
||||
//addr, err := netip.ParseAddr(ip)
|
||||
//if err != nil {
|
||||
// ctx.Err(types.ErrForbidden)
|
||||
// return
|
||||
//}
|
||||
//if addr.IsLoopback() {
|
||||
// h(ctx)
|
||||
// return
|
||||
//}
|
||||
ctx.Err(types.ErrForbidden)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue