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,10 +50,14 @@ 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 strings.Contains(remoteHostPort, ":") {
|
||||||
|
var err error
|
||||||
|
remoteHost, _, err = net.SplitHostPort(remoteHostPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.WithStack(err)
|
return false, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
remoteAddr := net.ParseIP(remoteHost)
|
remoteAddr := net.ParseIP(remoteHost)
|
||||||
if remoteAddr == nil {
|
if remoteAddr == nil {
|
||||||
|
|
Loading…
Reference in New Issue