mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 18:06:34 +02:00
parent
6ea8d34b8f
commit
4f0ce4bc82
5 changed files with 18 additions and 21 deletions
10
Makefile
10
Makefile
|
@ -102,14 +102,8 @@ spellcheck: # Spellcheck docs
|
|||
|
||||
.PHONY: cover
|
||||
cover: ## Runs go test with coverage
|
||||
@echo "" > coverage.txt
|
||||
@for d in $(shell go list ./... | grep -v vendor); do \
|
||||
$(GO) test -race -coverprofile=profile.out -covermode=atomic "$$d"; \
|
||||
if [ -f profile.out ]; then \
|
||||
cat profile.out >> coverage.txt; \
|
||||
rm profile.out; \
|
||||
fi; \
|
||||
done;
|
||||
@echo "==> $@"
|
||||
$(GO) test -race -coverprofile=coverage.txt -tags "$(BUILDTAGS)" $(shell $(GO) list ./... | grep -v vendor | grep -v github.com/pomerium/pomerium/integration)
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Cleanup any build binaries or packages.
|
||||
|
|
|
@ -224,27 +224,30 @@ func (e *Evaluator) JWTPayload(req *Request) map[string]interface{} {
|
|||
}
|
||||
|
||||
func newSigner(options *config.Options) (jose.Signer, *jose.JSONWebKey, error) {
|
||||
var decodedCert []byte
|
||||
// if we don't have a signing key, generate one
|
||||
if options.SigningKey == "" {
|
||||
key, err := cryptutil.NewSigningKey()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("couldn't generate signing key: %w", err)
|
||||
}
|
||||
generatedKey, err := cryptutil.EncodePrivateKey(key)
|
||||
decodedCert, err = cryptutil.EncodePrivateKey(key)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("bad signing key: %w", err)
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
decodedCert, err = base64.StdEncoding.DecodeString(options.SigningKey)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("bad signing key: %w", err)
|
||||
}
|
||||
options.SigningKey = base64.StdEncoding.EncodeToString(generatedKey)
|
||||
}
|
||||
if options.SigningKeyAlgorithm == "" {
|
||||
options.SigningKeyAlgorithm = string(jose.ES256)
|
||||
signingKeyAlgorithm := options.SigningKeyAlgorithm
|
||||
if signingKeyAlgorithm == "" {
|
||||
signingKeyAlgorithm = string(jose.ES256)
|
||||
}
|
||||
|
||||
decodedCert, err := base64.StdEncoding.DecodeString(options.SigningKey)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("bad signing key: %w", err)
|
||||
}
|
||||
jwk, err := cryptutil.PrivateJWKFromBytes(decodedCert, jose.SignatureAlgorithm(options.SigningKeyAlgorithm))
|
||||
jwk, err := cryptutil.PrivateJWKFromBytes(decodedCert, jose.SignatureAlgorithm(signingKeyAlgorithm))
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("couldn't generate signing key: %w", err)
|
||||
}
|
||||
|
|
|
@ -212,7 +212,6 @@ func Test_Checksum(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOptionsFromViper(t *testing.T) {
|
||||
t.Parallel()
|
||||
opts := []cmp.Option{
|
||||
cmpopts.IgnoreFields(Options{}, "CookieSecret", "GRPCInsecure", "GRPCAddr", "DataBrokerURLString", "DataBrokerURL", "AuthorizeURL", "AuthorizeURLString", "DefaultUpstreamTimeout", "CookieExpire", "Services", "Addr", "RefreshCooldown", "LogLevel", "KeyFile", "CertFile", "SharedKey", "ReadTimeout", "IdleTimeout", "GRPCClientTimeout", "GRPCClientDNSRoundRobin", "TracingSampleRate"),
|
||||
cmpopts.IgnoreFields(Policy{}, "Source", "Destination"),
|
||||
|
|
|
@ -196,8 +196,9 @@ func (tun *Tunnel) run(ctx context.Context, local io.ReadWriter, rawJWT string,
|
|||
_, err := io.Copy(remote, local)
|
||||
errc <- err
|
||||
}()
|
||||
remoteReader := deBuffer(br, remote)
|
||||
go func() {
|
||||
_, err := io.Copy(local, deBuffer(br, remote))
|
||||
_, err := io.Copy(local, remoteReader)
|
||||
errc <- err
|
||||
}()
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestGetGRPC(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
assert.Equal(t, cc1, cc2, "GetGRPCClientConn should return the same connection when there are no changes")
|
||||
assert.Same(t, cc1, cc2, "GetGRPCClientConn should return the same connection when there are no changes")
|
||||
|
||||
cc3, err := GetGRPCClientConn("example", &Options{
|
||||
Addr: mustParseURL("http://localhost.example"),
|
||||
|
@ -101,7 +101,7 @@ func TestGetGRPC(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
assert.NotEqual(t, cc1, cc3, "GetGRPCClientConn should return a new connection when there are changes")
|
||||
assert.NotSame(t, cc1, cc3, "GetGRPCClientConn should return a new connection when there are changes")
|
||||
}
|
||||
|
||||
func mustParseURL(rawurl string) *url.URL {
|
||||
|
|
Loading…
Add table
Reference in a new issue