fix(authn-network): handles r.RemoteAddr without port
Cadoles/bouncer/pipeline/head This commit looks good
Details
Cadoles/bouncer/pipeline/head This commit looks good
Details
This commit is contained in:
parent
572093536a
commit
920fc1aeb6
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/authn"
|
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director/layer/authn"
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
||||||
|
@ -49,9 +50,13 @@ func (a *Authenticator) Authenticate(w http.ResponseWriter, r *http.Request, lay
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Authenticator) matchAnyAuthorizedCIDRs(ctx context.Context, remoteHostPort string, CIDRs []string) (bool, error) {
|
func (a *Authenticator) matchAnyAuthorizedCIDRs(ctx context.Context, remoteHostPort string, CIDRs []string) (bool, error) {
|
||||||
remoteHost, _, err := net.SplitHostPort(remoteHostPort)
|
var remoteHost string
|
||||||
if err != nil {
|
if strings.Contains(remoteHostPort, ":") {
|
||||||
return false, errors.WithStack(err)
|
var err error
|
||||||
|
remoteHost, _, err = net.SplitHostPort(remoteHostPort)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.WithStack(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteAddr := net.ParseIP(remoteHost)
|
remoteAddr := net.ParseIP(remoteHost)
|
||||||
|
|
Loading…
Reference in New Issue