-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Named Pipes in gRPC target strings (#198)
Signed-off-by: Agustín Martínez Fayó <[email protected]>
- Loading branch information
1 parent
be346a3
commit fcf03d7
Showing
15 changed files
with
270 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package fakeworkloadapi | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
) | ||
|
||
func newListener() (net.Listener, error) { | ||
return net.Listen("tcp", "localhost:0") | ||
} | ||
|
||
func getTargetName(addr net.Addr) string { | ||
return fmt.Sprintf("%s://%s", addr.Network(), addr.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package spiffetls_test | ||
|
||
import ( | ||
"github.com/spiffe/go-spiffe/v2/spiffetls" | ||
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" | ||
) | ||
|
||
func listenAndDialCasesOS() []listenAndDialCase { | ||
return []listenAndDialCase{ | ||
{ | ||
name: "Wrong workload API server socket", | ||
dialMode: spiffetls.TLSClient(tlsconfig.AuthorizeID(serverID)), | ||
defaultWlAPIAddr: "wrong-socket-path", | ||
dialErr: "spiffetls: cannot create X.509 source: workload endpoint socket URI must have a \"tcp\" or \"unix\" scheme", | ||
listenErr: "spiffetls: cannot create X.509 source: workload endpoint socket URI must have a \"tcp\" or \"unix\" scheme", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package spiffetls_test | ||
|
||
import ( | ||
"github.com/spiffe/go-spiffe/v2/spiffetls" | ||
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig" | ||
) | ||
|
||
func listenAndDialCasesOS() []listenAndDialCase { | ||
return []listenAndDialCase{ | ||
{ | ||
name: "Wrong workload API server socket", | ||
dialMode: spiffetls.TLSClient(tlsconfig.AuthorizeID(serverID)), | ||
defaultWlAPIAddr: "wrong-socket-path", | ||
dialErr: "spiffetls: cannot create X.509 source: workload endpoint socket URI must have a \"tcp\" or \"npipe\" scheme", | ||
listenErr: "spiffetls: cannot create X.509 source: workload endpoint socket URI must have a \"tcp\" or \"npipe\" scheme", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package workloadapi | ||
|
||
import ( | ||
"errors" | ||
"net/url" | ||
) | ||
|
||
var ( | ||
ErrInvalidEndpointScheme = errors.New("workload endpoint socket URI must have a \"tcp\" or \"unix\" scheme") | ||
) | ||
|
||
func parseTargetFromURLAddrOS(u *url.URL) (string, error) { | ||
switch u.Scheme { | ||
case "unix": | ||
switch { | ||
case u.Opaque != "": | ||
return "", errors.New("workload endpoint unix socket URI must not be opaque") | ||
case u.User != nil: | ||
return "", errors.New("workload endpoint unix socket URI must not include user info") | ||
case u.Host == "" && u.Path == "": | ||
return "", errors.New("workload endpoint unix socket URI must include a path") | ||
case u.RawQuery != "": | ||
return "", errors.New("workload endpoint unix socket URI must not include query values") | ||
case u.Fragment != "": | ||
return "", errors.New("workload endpoint unix socket URI must not include a fragment") | ||
} | ||
return u.String(), nil | ||
default: | ||
return "", ErrInvalidEndpointScheme | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package workloadapi | ||
|
||
func validateAddressCasesOS() []validateAddressCase { | ||
return []validateAddressCase{ | ||
{ | ||
addr: "unix:opaque", | ||
err: "workload endpoint unix socket URI must not be opaque", | ||
}, | ||
{ | ||
addr: "unix://", | ||
err: "workload endpoint unix socket URI must include a path", | ||
}, | ||
{ | ||
addr: "unix://foo?whatever", | ||
err: "workload endpoint unix socket URI must not include query values", | ||
}, | ||
{ | ||
addr: "unix://foo#whatever", | ||
err: "workload endpoint unix socket URI must not include a fragment", | ||
}, | ||
{ | ||
addr: "unix://john:doe@foo/path", | ||
err: "workload endpoint unix socket URI must not include user info", | ||
}, | ||
{ | ||
addr: "unix://foo", | ||
err: "", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.