Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit 5160847

Browse files
committed
rebase to latest main
1 parent 5a619a1 commit 5160847

File tree

9 files changed

+37
-19
lines changed

9 files changed

+37
-19
lines changed

config/gen/go/v1/config.pb.go

+6-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/gen/go/v1/mock/config.pb.go

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/gen/go/v1/oidc/config.pb.go

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/boolstr.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
// BoolStrValue returns the bool value of a structpb.Value.
24-
// It expects the input to be a structpb.Value of type string ot bool that
24+
// It expects the input to be a structpb.Value of type string or bool that
2525
// represents a boolean value.
2626
// This method is a convenience method for backwards-compatibility with the
2727
// previous versions of the authservice.

internal/boolstr_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2024 Tetrate
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package internal
216

317
import (

internal/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func TestLoadOIDC(t *testing.T) {
222222
RedisSessionStoreConfig: &oidcv1.RedisConfig{ServerUri: "redis://localhost:6379/0"},
223223
Scopes: []string{scopeOIDC},
224224
Logout: &oidcv1.LogoutConfig{Path: "/logout", RedirectUri: "http://fake"},
225-
SkipVerifyPeerCert: structpb.NewBoolValue(true),
225+
TrustedCaConfig: &oidcv1.OIDCConfig_SkipVerifyPeerCert{SkipVerifyPeerCert: structpb.NewBoolValue(true)},
226226
},
227227
},
228228
},

internal/oidc/jwks_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/stretchr/testify/require"
3131
"github.com/tetratelabs/run"
3232
"github.com/tetratelabs/telemetry"
33+
"google.golang.org/protobuf/types/known/structpb"
3334

3435
oidcv1 "github.com/tetrateio/authservice-go/config/gen/go/v1/oidc"
3536
)
@@ -188,7 +189,7 @@ func TestDynamicJWKSProvider(t *testing.T) {
188189
},
189190
},
190191
TrustedCaConfig: &oidcv1.OIDCConfig_SkipVerifyPeerCert{
191-
SkipVerifyPeerCert: true,
192+
SkipVerifyPeerCert: structpb.NewBoolValue(true),
192193
},
193194
}
194195

internal/tls.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"errors"
2121
"fmt"
2222
"os"
23+
24+
"google.golang.org/protobuf/types/known/structpb"
2325
)
2426

2527
// TLSConfig is an interface for the TLS configuration of the AuthService.
@@ -29,7 +31,7 @@ type TLSConfig interface {
2931
// GetTrustedCertificateAuthorityFile returns the path to the trusted certificate authority file.
3032
GetTrustedCertificateAuthorityFile() string
3133
// GetSkipVerifyPeerCert returns whether to skip verification of the peer certificate.
32-
GetSkipVerifyPeerCert() bool
34+
GetSkipVerifyPeerCert() *structpb.Value
3335
}
3436

3537
// LoadTLSConfig loads a TLS configuration from the given TLSConfig.
@@ -39,20 +41,16 @@ func LoadTLSConfig(config TLSConfig) (*tls.Config, error) {
3941
// Load the trusted CA PEM from the config
4042
var ca []byte
4143
switch {
42-
4344
case config.GetTrustedCertificateAuthority() != "":
4445
ca = []byte(config.GetTrustedCertificateAuthority())
45-
4646
case config.GetTrustedCertificateAuthorityFile() != "":
4747
var err error
4848
ca, err = os.ReadFile(config.GetTrustedCertificateAuthorityFile())
4949
if err != nil {
5050
return nil, fmt.Errorf("error reading trusted CA file: %w", err)
5151
}
52-
53-
case config.GetSkipVerifyPeerCert():
54-
tlsConfig.InsecureSkipVerify = true
55-
52+
case config.GetSkipVerifyPeerCert() != nil:
53+
tlsConfig.InsecureSkipVerify = BoolStrValue(config.GetSkipVerifyPeerCert())
5654
default:
5755
// No CA or skip verification, return nil TLS config
5856
return nil, nil

internal/tls_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"testing"
2020

2121
"github.com/stretchr/testify/require"
22+
"google.golang.org/protobuf/types/known/structpb"
2223

2324
"github.com/tetrateio/authservice-go/config/gen/go/v1/oidc"
2425
)
@@ -65,7 +66,7 @@ func TestLoadTLSConfig(t *testing.T) {
6566
},
6667
{
6768
name: "skip verify config",
68-
config: &oidc.OIDCConfig{TrustedCaConfig: &oidc.OIDCConfig_SkipVerifyPeerCert{SkipVerifyPeerCert: true}},
69+
config: &oidc.OIDCConfig{TrustedCaConfig: &oidc.OIDCConfig_SkipVerifyPeerCert{SkipVerifyPeerCert: structpb.NewBoolValue(true)}},
6970
wantTLS: true,
7071
wantSkip: true,
7172
},

0 commit comments

Comments
 (0)