Skip to content

Commit 8b5101f

Browse files
authored
Merge pull request #1 from pace/alternative-issuer-and-pace-bricks-transport
Alternative issuer and pace bricks transport
2 parents 8d77155 + 7318ffd commit 8b5101f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

oidc.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"strings"
1717
"time"
1818

19+
brickstransport "github.com/pace/bricks/http/transport"
1920
"golang.org/x/oauth2"
2021
jose "gopkg.in/square/go-jose.v2"
2122
)
@@ -60,6 +61,7 @@ func doRequest(ctx context.Context, req *http.Request) (*http.Response, error) {
6061
if c, ok := ctx.Value(oauth2.HTTPClient).(*http.Client); ok {
6162
client = c
6263
}
64+
client.Transport = brickstransport.NewDefaultTransportChain()
6365
return client.Do(req.WithContext(ctx))
6466
}
6567

@@ -110,7 +112,7 @@ var supportedAlgorithms = map[string]bool{
110112
//
111113
// The issuer is the URL identifier for the service. For example: "https://accounts.google.com"
112114
// or "https://login.salesforce.com".
113-
func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
115+
func NewProvider(ctx context.Context, issuer string, alternativeIssuer ...string) (*Provider, error) {
114116
wellKnown := strings.TrimSuffix(issuer, "/") + "/.well-known/openid-configuration"
115117
req, err := http.NewRequest("GET", wellKnown, nil)
116118
if err != nil {
@@ -137,8 +139,10 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
137139
return nil, fmt.Errorf("oidc: failed to decode provider discovery object: %v", err)
138140
}
139141

140-
if p.Issuer != issuer {
141-
return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected %q got %q", issuer, p.Issuer)
142+
alternativeIssuer = append(alternativeIssuer, issuer)
143+
issuerStr := strings.Join(alternativeIssuer, " ")
144+
if !strings.Contains(issuerStr, p.Issuer) {
145+
return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected one of %q got %q", issuerStr, p.Issuer)
142146
}
143147
var algs []string
144148
for _, a := range p.Algorithms {

0 commit comments

Comments
 (0)