refactor: ptr.Ptr to ptr.To
Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
parent
137decb1ec
commit
0eec65e230
36
main_test.go
36
main_test.go
|
|
@ -123,26 +123,26 @@ redirect_url="http://localhost:4180/oauth2/callback"
|
||||||
opts.RawRedirectURL = "http://localhost:4180/oauth2/callback"
|
opts.RawRedirectURL = "http://localhost:4180/oauth2/callback"
|
||||||
|
|
||||||
opts.UpstreamServers = options.UpstreamConfig{
|
opts.UpstreamServers = options.UpstreamConfig{
|
||||||
ProxyRawPath: ptr.Ptr(false),
|
ProxyRawPath: ptr.To(false),
|
||||||
Upstreams: []options.Upstream{
|
Upstreams: []options.Upstream{
|
||||||
{
|
{
|
||||||
ID: "/",
|
ID: "/",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
URI: "http://httpbin",
|
URI: "http://httpbin",
|
||||||
FlushInterval: ptr.Ptr(options.DefaultUpstreamFlushInterval),
|
FlushInterval: ptr.To(options.DefaultUpstreamFlushInterval),
|
||||||
PassHostHeader: ptr.Ptr(true),
|
PassHostHeader: ptr.To(true),
|
||||||
ProxyWebSockets: ptr.Ptr(true),
|
ProxyWebSockets: ptr.To(true),
|
||||||
Timeout: ptr.Ptr(options.DefaultUpstreamTimeout),
|
Timeout: ptr.To(options.DefaultUpstreamTimeout),
|
||||||
Static: ptr.Ptr(false),
|
Static: ptr.To(false),
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
DisableKeepAlives: ptr.Ptr(false),
|
DisableKeepAlives: ptr.To(false),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
authHeader := options.Header{
|
authHeader := options.Header{
|
||||||
Name: "Authorization",
|
Name: "Authorization",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []options.HeaderValue{
|
Values: []options.HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &options.ClaimSource{
|
ClaimSource: &options.ClaimSource{
|
||||||
|
|
@ -165,11 +165,11 @@ redirect_url="http://localhost:4180/oauth2/callback"
|
||||||
Type: "google",
|
Type: "google",
|
||||||
ClientSecret: "b2F1dGgyLXByb3h5LWNsaWVudC1zZWNyZXQK",
|
ClientSecret: "b2F1dGgyLXByb3h5LWNsaWVudC1zZWNyZXQK",
|
||||||
ClientID: "oauth2-proxy",
|
ClientID: "oauth2-proxy",
|
||||||
UseSystemTrustStore: ptr.Ptr(false),
|
UseSystemTrustStore: ptr.To(false),
|
||||||
SkipClaimsFromProfileURL: ptr.Ptr(false),
|
SkipClaimsFromProfileURL: ptr.To(false),
|
||||||
GoogleConfig: options.GoogleOptions{
|
GoogleConfig: options.GoogleOptions{
|
||||||
AdminEmail: "admin@example.com",
|
AdminEmail: "admin@example.com",
|
||||||
UseApplicationDefaultCredentials: ptr.Ptr(false),
|
UseApplicationDefaultCredentials: ptr.To(false),
|
||||||
TargetPrincipal: "principal",
|
TargetPrincipal: "principal",
|
||||||
},
|
},
|
||||||
AzureConfig: options.AzureOptions{
|
AzureConfig: options.AzureOptions{
|
||||||
|
|
@ -181,16 +181,16 @@ redirect_url="http://localhost:4180/oauth2/callback"
|
||||||
UserIDClaim: "email",
|
UserIDClaim: "email",
|
||||||
AudienceClaims: []string{"aud"},
|
AudienceClaims: []string{"aud"},
|
||||||
ExtraAudiences: []string{},
|
ExtraAudiences: []string{},
|
||||||
InsecureSkipNonce: ptr.Ptr(true),
|
InsecureSkipNonce: ptr.To(true),
|
||||||
InsecureAllowUnverifiedEmail: ptr.Ptr(false),
|
InsecureAllowUnverifiedEmail: ptr.To(false),
|
||||||
InsecureSkipIssuerVerification: ptr.Ptr(false),
|
InsecureSkipIssuerVerification: ptr.To(false),
|
||||||
SkipDiscovery: ptr.Ptr(false),
|
SkipDiscovery: ptr.To(false),
|
||||||
},
|
},
|
||||||
MicrosoftEntraIDConfig: options.MicrosoftEntraIDOptions{
|
MicrosoftEntraIDConfig: options.MicrosoftEntraIDOptions{
|
||||||
FederatedTokenAuth: ptr.Ptr(false),
|
FederatedTokenAuth: ptr.To(false),
|
||||||
},
|
},
|
||||||
ADFSConfig: options.ADFSOptions{
|
ADFSConfig: options.ADFSOptions{
|
||||||
SkipScope: ptr.Ptr(false),
|
SkipScope: ptr.To(false),
|
||||||
},
|
},
|
||||||
LoginURLParameters: []options.LoginURLParameter{
|
LoginURLParameters: []options.LoginURLParameter{
|
||||||
{Name: "approval_prompt", Default: []string{"force"}},
|
{Name: "approval_prompt", Default: []string{"force"}},
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ func TestStaticProxyUpstream(t *testing.T) {
|
||||||
ProxyUpstream: options.Upstream{
|
ProxyUpstream: options.Upstream{
|
||||||
ID: "static-proxy",
|
ID: "static-proxy",
|
||||||
Path: "/static-proxy",
|
Path: "/static-proxy",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -2224,7 +2224,7 @@ func TestTrustedIPs(t *testing.T) {
|
||||||
{
|
{
|
||||||
ID: "static",
|
ID: "static",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ type ClaimSource struct {
|
||||||
// EnsureDefaults sets any default values for Header fields.
|
// EnsureDefaults sets any default values for Header fields.
|
||||||
func (h *Header) EnsureDefaults() {
|
func (h *Header) EnsureDefaults() {
|
||||||
if h.PreserveRequestValue == nil {
|
if h.PreserveRequestValue == nil {
|
||||||
h.PreserveRequestValue = ptr.Ptr(DefaultHeaderPreserveRequestValue)
|
h.PreserveRequestValue = ptr.To(DefaultHeaderPreserveRequestValue)
|
||||||
}
|
}
|
||||||
for i := range h.Values {
|
for i := range h.Values {
|
||||||
h.Values[i].EnsureDefaults()
|
h.Values[i].EnsureDefaults()
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ func (l *LegacyUpstreams) convert() (UpstreamConfig, error) {
|
||||||
logger.Errorf("unable to convert %q to int, use default \"200\"", u.Host)
|
logger.Errorf("unable to convert %q to int, use default \"200\"", u.Host)
|
||||||
responseCode = 200
|
responseCode = 200
|
||||||
}
|
}
|
||||||
upstream.Static = ptr.Ptr(true)
|
upstream.Static = ptr.To(true)
|
||||||
upstream.StaticCode = &responseCode
|
upstream.StaticCode = &responseCode
|
||||||
|
|
||||||
// This is not allowed to be empty and must be unique
|
// This is not allowed to be empty and must be unique
|
||||||
|
|
@ -177,8 +177,8 @@ func (l *LegacyUpstreams) convert() (UpstreamConfig, error) {
|
||||||
|
|
||||||
// Force defaults compatible with static responses
|
// Force defaults compatible with static responses
|
||||||
upstream.URI = ""
|
upstream.URI = ""
|
||||||
upstream.InsecureSkipTLSVerify = ptr.Ptr(false)
|
upstream.InsecureSkipTLSVerify = ptr.To(false)
|
||||||
upstream.DisableKeepAlives = ptr.Ptr(false)
|
upstream.DisableKeepAlives = ptr.To(false)
|
||||||
upstream.PassHostHeader = nil
|
upstream.PassHostHeader = nil
|
||||||
upstream.ProxyWebSockets = nil
|
upstream.ProxyWebSockets = nil
|
||||||
upstream.FlushInterval = nil
|
upstream.FlushInterval = nil
|
||||||
|
|
@ -255,7 +255,7 @@ func (l *LegacyHeaders) getRequestHeaders() []Header {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range requestHeaders {
|
for i := range requestHeaders {
|
||||||
requestHeaders[i].PreserveRequestValue = ptr.Ptr(!l.SkipAuthStripHeaders)
|
requestHeaders[i].PreserveRequestValue = ptr.To(!l.SkipAuthStripHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestHeaders
|
return requestHeaders
|
||||||
|
|
@ -290,7 +290,7 @@ func getBasicAuthHeader(preferEmailToUser bool, basicAuthPassword string) Header
|
||||||
|
|
||||||
return Header{
|
return Header{
|
||||||
Name: "Authorization",
|
Name: "Authorization",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -309,7 +309,7 @@ func getPassUserHeaders(preferEmailToUser bool) []Header {
|
||||||
headers := []Header{
|
headers := []Header{
|
||||||
{
|
{
|
||||||
Name: "X-Forwarded-Groups",
|
Name: "X-Forwarded-Groups",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -324,7 +324,7 @@ func getPassUserHeaders(preferEmailToUser bool) []Header {
|
||||||
return append(headers,
|
return append(headers,
|
||||||
Header{
|
Header{
|
||||||
Name: "X-Forwarded-User",
|
Name: "X-Forwarded-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -339,7 +339,7 @@ func getPassUserHeaders(preferEmailToUser bool) []Header {
|
||||||
return append(headers,
|
return append(headers,
|
||||||
Header{
|
Header{
|
||||||
Name: "X-Forwarded-User",
|
Name: "X-Forwarded-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -350,7 +350,7 @@ func getPassUserHeaders(preferEmailToUser bool) []Header {
|
||||||
},
|
},
|
||||||
Header{
|
Header{
|
||||||
Name: "X-Forwarded-Email",
|
Name: "X-Forwarded-Email",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -365,7 +365,7 @@ func getPassUserHeaders(preferEmailToUser bool) []Header {
|
||||||
func getPassAccessTokenHeader() Header {
|
func getPassAccessTokenHeader() Header {
|
||||||
return Header{
|
return Header{
|
||||||
Name: "X-Forwarded-Access-Token",
|
Name: "X-Forwarded-Access-Token",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -379,7 +379,7 @@ func getPassAccessTokenHeader() Header {
|
||||||
func getAuthorizationHeader() Header {
|
func getAuthorizationHeader() Header {
|
||||||
return Header{
|
return Header{
|
||||||
Name: "Authorization",
|
Name: "Authorization",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -394,7 +394,7 @@ func getAuthorizationHeader() Header {
|
||||||
func getPreferredUsernameHeader() Header {
|
func getPreferredUsernameHeader() Header {
|
||||||
return Header{
|
return Header{
|
||||||
Name: "X-Forwarded-Preferred-Username",
|
Name: "X-Forwarded-Preferred-Username",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -409,7 +409,7 @@ func getXAuthRequestHeaders() []Header {
|
||||||
headers := []Header{
|
headers := []Header{
|
||||||
{
|
{
|
||||||
Name: "X-Auth-Request-User",
|
Name: "X-Auth-Request-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -420,7 +420,7 @@ func getXAuthRequestHeaders() []Header {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "X-Auth-Request-Email",
|
Name: "X-Auth-Request-Email",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -431,7 +431,7 @@ func getXAuthRequestHeaders() []Header {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "X-Auth-Request-Preferred-Username",
|
Name: "X-Auth-Request-Preferred-Username",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -442,7 +442,7 @@ func getXAuthRequestHeaders() []Header {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "X-Auth-Request-Groups",
|
Name: "X-Auth-Request-Groups",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -459,7 +459,7 @@ func getXAuthRequestHeaders() []Header {
|
||||||
func getXAuthRequestAccessTokenHeader() Header {
|
func getXAuthRequestAccessTokenHeader() Header {
|
||||||
return Header{
|
return Header{
|
||||||
Name: "X-Auth-Request-Access-Token",
|
Name: "X-Auth-Request-Access-Token",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ var _ = Describe("Legacy Options", func() {
|
||||||
Path: "/baz",
|
Path: "/baz",
|
||||||
URI: "http://foo.bar/baz",
|
URI: "http://foo.bar/baz",
|
||||||
FlushInterval: &flushInterval,
|
FlushInterval: &flushInterval,
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(true),
|
InsecureSkipTLSVerify: ptr.To(true),
|
||||||
PassHostHeader: ptr.Ptr(true),
|
PassHostHeader: ptr.To(true),
|
||||||
ProxyWebSockets: ptr.Ptr(true),
|
ProxyWebSockets: ptr.To(true),
|
||||||
Timeout: &timeout,
|
Timeout: &timeout,
|
||||||
DisableKeepAlives: &legacyOpts.LegacyUpstreams.DisableKeepAlives,
|
DisableKeepAlives: &legacyOpts.LegacyUpstreams.DisableKeepAlives,
|
||||||
},
|
},
|
||||||
|
|
@ -47,9 +47,9 @@ var _ = Describe("Legacy Options", func() {
|
||||||
Path: "/bar",
|
Path: "/bar",
|
||||||
URI: "file:///var/lib/website",
|
URI: "file:///var/lib/website",
|
||||||
FlushInterval: &flushInterval,
|
FlushInterval: &flushInterval,
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(true),
|
InsecureSkipTLSVerify: ptr.To(true),
|
||||||
PassHostHeader: ptr.Ptr(true),
|
PassHostHeader: ptr.To(true),
|
||||||
ProxyWebSockets: ptr.Ptr(true),
|
ProxyWebSockets: ptr.To(true),
|
||||||
Timeout: &timeout,
|
Timeout: &timeout,
|
||||||
DisableKeepAlives: &legacyOpts.LegacyUpstreams.DisableKeepAlives,
|
DisableKeepAlives: &legacyOpts.LegacyUpstreams.DisableKeepAlives,
|
||||||
},
|
},
|
||||||
|
|
@ -57,10 +57,10 @@ var _ = Describe("Legacy Options", func() {
|
||||||
ID: "static://204",
|
ID: "static://204",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
URI: "",
|
URI: "",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &staticCode,
|
StaticCode: &staticCode,
|
||||||
FlushInterval: nil,
|
FlushInterval: nil,
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
PassHostHeader: nil,
|
PassHostHeader: nil,
|
||||||
ProxyWebSockets: nil,
|
ProxyWebSockets: nil,
|
||||||
Timeout: nil,
|
Timeout: nil,
|
||||||
|
|
@ -72,7 +72,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
opts.InjectRequestHeaders = []Header{
|
opts.InjectRequestHeaders = []Header{
|
||||||
{
|
{
|
||||||
Name: "X-Forwarded-Groups",
|
Name: "X-Forwarded-Groups",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -83,7 +83,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "X-Forwarded-User",
|
Name: "X-Forwarded-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -94,7 +94,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "X-Forwarded-Email",
|
Name: "X-Forwarded-Email",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -105,7 +105,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "X-Forwarded-Preferred-Username",
|
Name: "X-Forwarded-Preferred-Username",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -126,8 +126,8 @@ var _ = Describe("Legacy Options", func() {
|
||||||
opts.Providers[0].ClientID = "oauth-proxy"
|
opts.Providers[0].ClientID = "oauth-proxy"
|
||||||
opts.Providers[0].OIDCConfig.AudienceClaims = []string{"aud"}
|
opts.Providers[0].OIDCConfig.AudienceClaims = []string{"aud"}
|
||||||
opts.Providers[0].OIDCConfig.ExtraAudiences = []string{}
|
opts.Providers[0].OIDCConfig.ExtraAudiences = []string{}
|
||||||
opts.Providers[0].OIDCConfig.InsecureSkipNonce = ptr.Ptr(true)
|
opts.Providers[0].OIDCConfig.InsecureSkipNonce = ptr.To(true)
|
||||||
opts.Providers[0].OIDCConfig.InsecureSkipIssuerVerification = ptr.Ptr(false)
|
opts.Providers[0].OIDCConfig.InsecureSkipIssuerVerification = ptr.To(false)
|
||||||
opts.Providers[0].LoginURLParameters = []LoginURLParameter{
|
opts.Providers[0].LoginURLParameters = []LoginURLParameter{
|
||||||
{Name: "approval_prompt", Default: []string{"force"}},
|
{Name: "approval_prompt", Default: []string{"force"}},
|
||||||
}
|
}
|
||||||
|
|
@ -202,14 +202,14 @@ var _ = Describe("Legacy Options", func() {
|
||||||
ID: validStatic,
|
ID: validStatic,
|
||||||
Path: "/",
|
Path: "/",
|
||||||
URI: "",
|
URI: "",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &validStaticCode,
|
StaticCode: &validStaticCode,
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
PassHostHeader: nil,
|
PassHostHeader: nil,
|
||||||
ProxyWebSockets: nil,
|
ProxyWebSockets: nil,
|
||||||
FlushInterval: nil,
|
FlushInterval: nil,
|
||||||
Timeout: nil,
|
Timeout: nil,
|
||||||
DisableKeepAlives: ptr.Ptr(false),
|
DisableKeepAlives: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidStatic := "static://abc"
|
invalidStatic := "static://abc"
|
||||||
|
|
@ -218,14 +218,14 @@ var _ = Describe("Legacy Options", func() {
|
||||||
ID: invalidStatic,
|
ID: invalidStatic,
|
||||||
Path: "/",
|
Path: "/",
|
||||||
URI: "",
|
URI: "",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &invalidStaticCode,
|
StaticCode: &invalidStaticCode,
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
PassHostHeader: nil,
|
PassHostHeader: nil,
|
||||||
ProxyWebSockets: nil,
|
ProxyWebSockets: nil,
|
||||||
FlushInterval: nil,
|
FlushInterval: nil,
|
||||||
Timeout: nil,
|
Timeout: nil,
|
||||||
DisableKeepAlives: ptr.Ptr(false),
|
DisableKeepAlives: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidHTTP := ":foo"
|
invalidHTTP := ":foo"
|
||||||
|
|
@ -318,7 +318,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xForwardedUser := Header{
|
xForwardedUser := Header{
|
||||||
Name: "X-Forwarded-User",
|
Name: "X-Forwarded-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -330,7 +330,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xForwardedEmail := Header{
|
xForwardedEmail := Header{
|
||||||
Name: "X-Forwarded-Email",
|
Name: "X-Forwarded-Email",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -342,7 +342,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xForwardedGroups := Header{
|
xForwardedGroups := Header{
|
||||||
Name: "X-Forwarded-Groups",
|
Name: "X-Forwarded-Groups",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -354,7 +354,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xForwardedPreferredUsername := Header{
|
xForwardedPreferredUsername := Header{
|
||||||
Name: "X-Forwarded-Preferred-Username",
|
Name: "X-Forwarded-Preferred-Username",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -366,7 +366,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
basicAuthHeader := Header{
|
basicAuthHeader := Header{
|
||||||
Name: "Authorization",
|
Name: "Authorization",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -382,7 +382,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xForwardedUserWithEmail := Header{
|
xForwardedUserWithEmail := Header{
|
||||||
Name: "X-Forwarded-User",
|
Name: "X-Forwarded-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -394,7 +394,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xForwardedAccessToken := Header{
|
xForwardedAccessToken := Header{
|
||||||
Name: "X-Forwarded-Access-Token",
|
Name: "X-Forwarded-Access-Token",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -406,7 +406,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
basicAuthHeaderWithEmail := Header{
|
basicAuthHeaderWithEmail := Header{
|
||||||
Name: "Authorization",
|
Name: "Authorization",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -422,7 +422,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xAuthRequestUser := Header{
|
xAuthRequestUser := Header{
|
||||||
Name: "X-Auth-Request-User",
|
Name: "X-Auth-Request-User",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -434,7 +434,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xAuthRequestEmail := Header{
|
xAuthRequestEmail := Header{
|
||||||
Name: "X-Auth-Request-Email",
|
Name: "X-Auth-Request-Email",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -446,7 +446,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xAuthRequestGroups := Header{
|
xAuthRequestGroups := Header{
|
||||||
Name: "X-Auth-Request-Groups",
|
Name: "X-Auth-Request-Groups",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -458,7 +458,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xAuthRequestPreferredUsername := Header{
|
xAuthRequestPreferredUsername := Header{
|
||||||
Name: "X-Auth-Request-Preferred-Username",
|
Name: "X-Auth-Request-Preferred-Username",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -470,7 +470,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
xAuthRequestAccessToken := Header{
|
xAuthRequestAccessToken := Header{
|
||||||
Name: "X-Auth-Request-Access-Token",
|
Name: "X-Auth-Request-Access-Token",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -482,7 +482,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
|
|
||||||
authorizationHeader := Header{
|
authorizationHeader := Header{
|
||||||
Name: "Authorization",
|
Name: "Authorization",
|
||||||
PreserveRequestValue: ptr.Ptr(false),
|
PreserveRequestValue: ptr.To(false),
|
||||||
Values: []HeaderValue{
|
Values: []HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &ClaimSource{
|
ClaimSource: &ClaimSource{
|
||||||
|
|
@ -948,14 +948,14 @@ var _ = Describe("Legacy Options", func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultOIDCOptions := OIDCOptions{
|
defaultOIDCOptions := OIDCOptions{
|
||||||
SkipDiscovery: ptr.Ptr(false),
|
SkipDiscovery: ptr.To(false),
|
||||||
InsecureSkipNonce: ptr.Ptr(false),
|
InsecureSkipNonce: ptr.To(false),
|
||||||
InsecureAllowUnverifiedEmail: ptr.Ptr(false),
|
InsecureAllowUnverifiedEmail: ptr.To(false),
|
||||||
InsecureSkipIssuerVerification: ptr.Ptr(false),
|
InsecureSkipIssuerVerification: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultGoogleOptions := GoogleOptions{
|
defaultGoogleOptions := GoogleOptions{
|
||||||
UseApplicationDefaultCredentials: ptr.Ptr(false),
|
UseApplicationDefaultCredentials: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultLegacyProvider := LegacyProvider{
|
defaultLegacyProvider := LegacyProvider{
|
||||||
|
|
@ -970,8 +970,8 @@ var _ = Describe("Legacy Options", func() {
|
||||||
OIDCConfig: defaultOIDCOptions,
|
OIDCConfig: defaultOIDCOptions,
|
||||||
GoogleConfig: defaultGoogleOptions,
|
GoogleConfig: defaultGoogleOptions,
|
||||||
LoginURLParameters: defaultURLParams,
|
LoginURLParameters: defaultURLParams,
|
||||||
UseSystemTrustStore: ptr.Ptr(false),
|
UseSystemTrustStore: ptr.To(false),
|
||||||
SkipClaimsFromProfileURL: ptr.Ptr(false),
|
SkipClaimsFromProfileURL: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultLegacyProviderWithPrompt := LegacyProvider{
|
defaultLegacyProviderWithPrompt := LegacyProvider{
|
||||||
|
|
@ -989,8 +989,8 @@ var _ = Describe("Legacy Options", func() {
|
||||||
LoginURLParameters: []LoginURLParameter{
|
LoginURLParameters: []LoginURLParameter{
|
||||||
{Name: "prompt", Default: []string{"switch_user"}},
|
{Name: "prompt", Default: []string{"switch_user"}},
|
||||||
},
|
},
|
||||||
UseSystemTrustStore: ptr.Ptr(false),
|
UseSystemTrustStore: ptr.To(false),
|
||||||
SkipClaimsFromProfileURL: ptr.Ptr(false),
|
SkipClaimsFromProfileURL: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
displayNameLegacyProvider := LegacyProvider{
|
displayNameLegacyProvider := LegacyProvider{
|
||||||
|
|
@ -1007,8 +1007,8 @@ var _ = Describe("Legacy Options", func() {
|
||||||
OIDCConfig: defaultOIDCOptions,
|
OIDCConfig: defaultOIDCOptions,
|
||||||
GoogleConfig: defaultGoogleOptions,
|
GoogleConfig: defaultGoogleOptions,
|
||||||
LoginURLParameters: defaultURLParams,
|
LoginURLParameters: defaultURLParams,
|
||||||
UseSystemTrustStore: ptr.Ptr(false),
|
UseSystemTrustStore: ptr.To(false),
|
||||||
SkipClaimsFromProfileURL: ptr.Ptr(false),
|
SkipClaimsFromProfileURL: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
internalConfigProvider := Provider{
|
internalConfigProvider := Provider{
|
||||||
|
|
@ -1020,11 +1020,11 @@ var _ = Describe("Legacy Options", func() {
|
||||||
AdminEmail: "email@email.com",
|
AdminEmail: "email@email.com",
|
||||||
ServiceAccountJSON: "test.json",
|
ServiceAccountJSON: "test.json",
|
||||||
Groups: []string{"1", "2"},
|
Groups: []string{"1", "2"},
|
||||||
UseApplicationDefaultCredentials: ptr.Ptr(false),
|
UseApplicationDefaultCredentials: ptr.To(false),
|
||||||
},
|
},
|
||||||
LoginURLParameters: defaultURLParams,
|
LoginURLParameters: defaultURLParams,
|
||||||
UseSystemTrustStore: ptr.Ptr(false),
|
UseSystemTrustStore: ptr.To(false),
|
||||||
SkipClaimsFromProfileURL: ptr.Ptr(false),
|
SkipClaimsFromProfileURL: ptr.To(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
internalConfigLegacyProvider := LegacyProvider{
|
internalConfigLegacyProvider := LegacyProvider{
|
||||||
|
|
|
||||||
|
|
@ -334,9 +334,9 @@ func providerDefaults() Providers {
|
||||||
Tenant: "common",
|
Tenant: "common",
|
||||||
},
|
},
|
||||||
OIDCConfig: OIDCOptions{
|
OIDCConfig: OIDCOptions{
|
||||||
InsecureAllowUnverifiedEmail: ptr.Ptr(DefaultInsecureAllowUnverifiedEmail),
|
InsecureAllowUnverifiedEmail: ptr.To(DefaultInsecureAllowUnverifiedEmail),
|
||||||
InsecureSkipNonce: ptr.Ptr(DefaultInsecureSkipNonce),
|
InsecureSkipNonce: ptr.To(DefaultInsecureSkipNonce),
|
||||||
SkipDiscovery: ptr.Ptr(DefaultSkipDiscovery),
|
SkipDiscovery: ptr.To(DefaultSkipDiscovery),
|
||||||
UserIDClaim: OIDCEmailClaim, // Deprecated: Use OIDCEmailClaim
|
UserIDClaim: OIDCEmailClaim, // Deprecated: Use OIDCEmailClaim
|
||||||
EmailClaim: OIDCEmailClaim,
|
EmailClaim: OIDCEmailClaim,
|
||||||
GroupsClaim: OIDCGroupsClaim,
|
GroupsClaim: OIDCGroupsClaim,
|
||||||
|
|
@ -358,10 +358,10 @@ func (p Providers) EnsureDefaults() {
|
||||||
// EnsureDefaults sets any default values for Provider fields.
|
// EnsureDefaults sets any default values for Provider fields.
|
||||||
func (p *Provider) EnsureDefaults() {
|
func (p *Provider) EnsureDefaults() {
|
||||||
if p.SkipClaimsFromProfileURL == nil {
|
if p.SkipClaimsFromProfileURL == nil {
|
||||||
p.SkipClaimsFromProfileURL = ptr.Ptr(DefaultSkipClaimsFromProfileURL)
|
p.SkipClaimsFromProfileURL = ptr.To(DefaultSkipClaimsFromProfileURL)
|
||||||
}
|
}
|
||||||
if p.UseSystemTrustStore == nil {
|
if p.UseSystemTrustStore == nil {
|
||||||
p.UseSystemTrustStore = ptr.Ptr(DefaultUseSystemTrustStore)
|
p.UseSystemTrustStore = ptr.To(DefaultUseSystemTrustStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.OIDCConfig.EnsureDefaults()
|
p.OIDCConfig.EnsureDefaults()
|
||||||
|
|
@ -374,13 +374,13 @@ func (p *Provider) EnsureDefaults() {
|
||||||
func (o *OIDCOptions) EnsureDefaults() {
|
func (o *OIDCOptions) EnsureDefaults() {
|
||||||
// Ensure OIDC defaults
|
// Ensure OIDC defaults
|
||||||
if o.InsecureAllowUnverifiedEmail == nil {
|
if o.InsecureAllowUnverifiedEmail == nil {
|
||||||
o.InsecureAllowUnverifiedEmail = ptr.Ptr(DefaultInsecureAllowUnverifiedEmail)
|
o.InsecureAllowUnverifiedEmail = ptr.To(DefaultInsecureAllowUnverifiedEmail)
|
||||||
}
|
}
|
||||||
if o.InsecureSkipNonce == nil {
|
if o.InsecureSkipNonce == nil {
|
||||||
o.InsecureSkipNonce = ptr.Ptr(DefaultInsecureSkipNonce)
|
o.InsecureSkipNonce = ptr.To(DefaultInsecureSkipNonce)
|
||||||
}
|
}
|
||||||
if o.SkipDiscovery == nil {
|
if o.SkipDiscovery == nil {
|
||||||
o.SkipDiscovery = ptr.Ptr(DefaultSkipDiscovery)
|
o.SkipDiscovery = ptr.To(DefaultSkipDiscovery)
|
||||||
}
|
}
|
||||||
if o.UserIDClaim == "" {
|
if o.UserIDClaim == "" {
|
||||||
o.UserIDClaim = OIDCEmailClaim
|
o.UserIDClaim = OIDCEmailClaim
|
||||||
|
|
@ -399,20 +399,20 @@ func (o *OIDCOptions) EnsureDefaults() {
|
||||||
// EnsureDefaults sets any default values for MicrosoftEntraIDOptions fields.
|
// EnsureDefaults sets any default values for MicrosoftEntraIDOptions fields.
|
||||||
func (me *MicrosoftEntraIDOptions) EnsureDefaults() {
|
func (me *MicrosoftEntraIDOptions) EnsureDefaults() {
|
||||||
if me.FederatedTokenAuth == nil {
|
if me.FederatedTokenAuth == nil {
|
||||||
me.FederatedTokenAuth = ptr.Ptr(DefaultMicrosoftEntraIDUseFederatedToken)
|
me.FederatedTokenAuth = ptr.To(DefaultMicrosoftEntraIDUseFederatedToken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnsureDefaults sets any default values for ADFSOptions fields.
|
// EnsureDefaults sets any default values for ADFSOptions fields.
|
||||||
func (a *ADFSOptions) EnsureDefaults() {
|
func (a *ADFSOptions) EnsureDefaults() {
|
||||||
if a.SkipScope == nil {
|
if a.SkipScope == nil {
|
||||||
a.SkipScope = ptr.Ptr(DefaultADFSSkipScope)
|
a.SkipScope = ptr.To(DefaultADFSSkipScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnsureDefaults sets any default values for GoogleOptions fields.
|
// EnsureDefaults sets any default values for GoogleOptions fields.
|
||||||
func (g *GoogleOptions) EnsureDefaults() {
|
func (g *GoogleOptions) EnsureDefaults() {
|
||||||
if g.UseApplicationDefaultCredentials == nil {
|
if g.UseApplicationDefaultCredentials == nil {
|
||||||
g.UseApplicationDefaultCredentials = ptr.Ptr(DefaultUseApplicationDefaultCredentials)
|
g.UseApplicationDefaultCredentials = ptr.To(DefaultUseApplicationDefaultCredentials)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ type Upstream struct {
|
||||||
// EnsureDefaults sets any default values for UpstreamConfig fields.
|
// EnsureDefaults sets any default values for UpstreamConfig fields.
|
||||||
func (uc *UpstreamConfig) EnsureDefaults() {
|
func (uc *UpstreamConfig) EnsureDefaults() {
|
||||||
if uc.ProxyRawPath == nil {
|
if uc.ProxyRawPath == nil {
|
||||||
uc.ProxyRawPath = ptr.Ptr(DefaultUpstreamProxyRawPath)
|
uc.ProxyRawPath = ptr.To(DefaultUpstreamProxyRawPath)
|
||||||
}
|
}
|
||||||
for i := range uc.Upstreams {
|
for i := range uc.Upstreams {
|
||||||
uc.Upstreams[i].EnsureDefaults()
|
uc.Upstreams[i].EnsureDefaults()
|
||||||
|
|
@ -138,24 +138,24 @@ func (uc *UpstreamConfig) EnsureDefaults() {
|
||||||
// EnsureDefaults sets any default values for Upstream fields.
|
// EnsureDefaults sets any default values for Upstream fields.
|
||||||
func (u *Upstream) EnsureDefaults() {
|
func (u *Upstream) EnsureDefaults() {
|
||||||
if u.InsecureSkipTLSVerify == nil {
|
if u.InsecureSkipTLSVerify == nil {
|
||||||
u.InsecureSkipTLSVerify = ptr.Ptr(DefaultUpsteamInsecureSkipTLSVerify)
|
u.InsecureSkipTLSVerify = ptr.To(DefaultUpsteamInsecureSkipTLSVerify)
|
||||||
}
|
}
|
||||||
if u.Static == nil {
|
if u.Static == nil {
|
||||||
u.Static = ptr.Ptr(DefaultUpstreamStatic)
|
u.Static = ptr.To(DefaultUpstreamStatic)
|
||||||
}
|
}
|
||||||
if u.FlushInterval == nil {
|
if u.FlushInterval == nil {
|
||||||
u.FlushInterval = ptr.Ptr(DefaultUpstreamFlushInterval)
|
u.FlushInterval = ptr.To(DefaultUpstreamFlushInterval)
|
||||||
}
|
}
|
||||||
if u.PassHostHeader == nil {
|
if u.PassHostHeader == nil {
|
||||||
u.PassHostHeader = ptr.Ptr(DefaultUpstreamPassHostHeader)
|
u.PassHostHeader = ptr.To(DefaultUpstreamPassHostHeader)
|
||||||
}
|
}
|
||||||
if u.ProxyWebSockets == nil {
|
if u.ProxyWebSockets == nil {
|
||||||
u.ProxyWebSockets = ptr.Ptr(DefaultUpstreamProxyWebSockets)
|
u.ProxyWebSockets = ptr.To(DefaultUpstreamProxyWebSockets)
|
||||||
}
|
}
|
||||||
if u.Timeout == nil {
|
if u.Timeout == nil {
|
||||||
u.Timeout = ptr.Ptr(DefaultUpstreamTimeout)
|
u.Timeout = ptr.To(DefaultUpstreamTimeout)
|
||||||
}
|
}
|
||||||
if u.DisableKeepAlives == nil {
|
if u.DisableKeepAlives == nil {
|
||||||
u.DisableKeepAlives = ptr.Ptr(DefaultUpstreamDisableKeepAlives)
|
u.DisableKeepAlives = ptr.To(DefaultUpstreamDisableKeepAlives)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,12 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
|
||||||
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/util/ptr"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func timePtr(t time.Time) *time.Time {
|
|
||||||
return &t
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreatedAtNow(t *testing.T) {
|
func TestCreatedAtNow(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
ss := &SessionState{}
|
ss := &SessionState{}
|
||||||
|
|
@ -137,10 +134,10 @@ func TestString(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsExpired(t *testing.T) {
|
func TestIsExpired(t *testing.T) {
|
||||||
s := &SessionState{ExpiresOn: timePtr(time.Now().Add(time.Duration(-1) * time.Minute))}
|
s := &SessionState{ExpiresOn: ptr.To(time.Now().Add(time.Duration(-1) * time.Minute))}
|
||||||
assert.Equal(t, true, s.IsExpired())
|
assert.Equal(t, true, s.IsExpired())
|
||||||
|
|
||||||
s = &SessionState{ExpiresOn: timePtr(time.Now().Add(time.Duration(1) * time.Minute))}
|
s = &SessionState{ExpiresOn: ptr.To(time.Now().Add(time.Duration(1) * time.Minute))}
|
||||||
assert.Equal(t, false, s.IsExpired())
|
assert.Equal(t, false, s.IsExpired())
|
||||||
|
|
||||||
s = &SessionState{}
|
s = &SessionState{}
|
||||||
|
|
@ -154,7 +151,7 @@ func TestAge(t *testing.T) {
|
||||||
assert.Equal(t, time.Duration(0), ss.Age())
|
assert.Equal(t, time.Duration(0), ss.Age())
|
||||||
|
|
||||||
// Set CreatedAt to 1 hour ago
|
// Set CreatedAt to 1 hour ago
|
||||||
ss.CreatedAt = timePtr(time.Now().Add(-1 * time.Hour))
|
ss.CreatedAt = ptr.To(time.Now().Add(-1 * time.Hour))
|
||||||
assert.Equal(t, time.Hour, ss.Age().Round(time.Minute))
|
assert.Equal(t, time.Hour, ss.Age().Round(time.Minute))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ var _ = Describe("Headers Suite", func() {
|
||||||
headers: []options.Header{
|
headers: []options.Header{
|
||||||
{
|
{
|
||||||
Name: "Claim",
|
Name: "Claim",
|
||||||
PreserveRequestValue: ptr.Ptr(true),
|
PreserveRequestValue: ptr.To(true),
|
||||||
Values: []options.HeaderValue{
|
Values: []options.HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &options.ClaimSource{
|
ClaimSource: &options.ClaimSource{
|
||||||
|
|
@ -161,7 +161,7 @@ var _ = Describe("Headers Suite", func() {
|
||||||
headers: []options.Header{
|
headers: []options.Header{
|
||||||
{
|
{
|
||||||
Name: "Claim",
|
Name: "Claim",
|
||||||
PreserveRequestValue: ptr.Ptr(true),
|
PreserveRequestValue: ptr.To(true),
|
||||||
Values: []options.HeaderValue{
|
Values: []options.HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &options.ClaimSource{
|
ClaimSource: &options.ClaimSource{
|
||||||
|
|
@ -386,7 +386,7 @@ var _ = Describe("Headers Suite", func() {
|
||||||
headers: []options.Header{
|
headers: []options.Header{
|
||||||
{
|
{
|
||||||
Name: "Claim",
|
Name: "Claim",
|
||||||
PreserveRequestValue: ptr.Ptr(true),
|
PreserveRequestValue: ptr.To(true),
|
||||||
Values: []options.HeaderValue{
|
Values: []options.HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &options.ClaimSource{
|
ClaimSource: &options.ClaimSource{
|
||||||
|
|
@ -433,7 +433,7 @@ var _ = Describe("Headers Suite", func() {
|
||||||
headers: []options.Header{
|
headers: []options.Header{
|
||||||
{
|
{
|
||||||
Name: "Claim",
|
Name: "Claim",
|
||||||
PreserveRequestValue: ptr.Ptr(true),
|
PreserveRequestValue: ptr.To(true),
|
||||||
Values: []options.HeaderValue{
|
Values: []options.HeaderValue{
|
||||||
{
|
{
|
||||||
ClaimSource: &options.ClaimSource{
|
ClaimSource: &options.ClaimSource{
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||||
upstream := options.Upstream{
|
upstream := options.Upstream{
|
||||||
ID: in.id,
|
ID: in.id,
|
||||||
PassHostHeader: &in.passUpstreamHostHeader,
|
PassHostHeader: &in.passUpstreamHostHeader,
|
||||||
ProxyWebSockets: ptr.Ptr(false),
|
ProxyWebSockets: ptr.To(false),
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
FlushInterval: &flush,
|
FlushInterval: &flush,
|
||||||
Timeout: &timeout,
|
Timeout: &timeout,
|
||||||
}
|
}
|
||||||
|
|
@ -342,9 +342,9 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||||
|
|
||||||
upstream := options.Upstream{
|
upstream := options.Upstream{
|
||||||
ID: "noPassHost",
|
ID: "noPassHost",
|
||||||
PassHostHeader: ptr.Ptr(false),
|
PassHostHeader: ptr.To(false),
|
||||||
ProxyWebSockets: ptr.Ptr(false),
|
ProxyWebSockets: ptr.To(false),
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
FlushInterval: &defaultFlushInterval,
|
FlushInterval: &defaultFlushInterval,
|
||||||
Timeout: &defaultTimeout,
|
Timeout: &defaultTimeout,
|
||||||
}
|
}
|
||||||
|
|
@ -486,9 +486,9 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||||
timeout := options.DefaultUpstreamTimeout
|
timeout := options.DefaultUpstreamTimeout
|
||||||
upstream := options.Upstream{
|
upstream := options.Upstream{
|
||||||
ID: "websocketProxy",
|
ID: "websocketProxy",
|
||||||
PassHostHeader: ptr.Ptr(true),
|
PassHostHeader: ptr.To(true),
|
||||||
ProxyWebSockets: ptr.Ptr(true),
|
ProxyWebSockets: ptr.To(true),
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(false),
|
InsecureSkipTLSVerify: ptr.To(false),
|
||||||
FlushInterval: &flush,
|
FlushInterval: &flush,
|
||||||
Timeout: &timeout,
|
Timeout: &timeout,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,19 +61,19 @@ var _ = Describe("Proxy Suite", func() {
|
||||||
{
|
{
|
||||||
ID: "static-backend",
|
ID: "static-backend",
|
||||||
Path: "/static/",
|
Path: "/static/",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &ok,
|
StaticCode: &ok,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "static-backend-no-trailing-slash",
|
ID: "static-backend-no-trailing-slash",
|
||||||
Path: "/static",
|
Path: "/static",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &accepted,
|
StaticCode: &accepted,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "static-backend-long",
|
ID: "static-backend-long",
|
||||||
Path: "/static/long",
|
Path: "/static/long",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &accepted,
|
StaticCode: &accepted,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -84,7 +84,7 @@ var _ = Describe("Proxy Suite", func() {
|
||||||
{
|
{
|
||||||
ID: "single-path-backend",
|
ID: "single-path-backend",
|
||||||
Path: "/single-path",
|
Path: "/single-path",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
StaticCode: &ok,
|
StaticCode: &ok,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -347,7 +347,7 @@ var _ = Describe("Proxy Suite", func() {
|
||||||
upstream: "",
|
upstream: "",
|
||||||
}),
|
}),
|
||||||
Entry("containing an escaped '/' with ProxyRawPath", &proxyTableInput{
|
Entry("containing an escaped '/' with ProxyRawPath", &proxyTableInput{
|
||||||
upstreams: options.UpstreamConfig{ProxyRawPath: ptr.Ptr(true)},
|
upstreams: options.UpstreamConfig{ProxyRawPath: ptr.To(true)},
|
||||||
target: "http://example.localhost/%2F/test1/%2F/test2",
|
target: "http://example.localhost/%2F/test1/%2F/test2",
|
||||||
response: testHTTPResponse{
|
response: testHTTPResponse{
|
||||||
code: 404,
|
code: 404,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package ptr
|
package ptr
|
||||||
|
|
||||||
// Ptr generically returns a pointer to the given value.
|
// To generically returns a pointer to the given value.
|
||||||
func Ptr[T any](v T) *T {
|
func To[T any](v T) *T {
|
||||||
return &v
|
return &v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,22 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPtr(t *testing.T) {
|
func TestTo(t *testing.T) {
|
||||||
p := Ptr(42)
|
p := To(42)
|
||||||
assert.NotNil(t, p)
|
assert.NotNil(t, p)
|
||||||
assert.Equal(t, 42, *p)
|
assert.Equal(t, 42, *p)
|
||||||
|
|
||||||
s := Ptr("hello")
|
s := To("hello")
|
||||||
assert.NotNil(t, s)
|
assert.NotNil(t, s)
|
||||||
assert.Equal(t, "hello", *s)
|
assert.Equal(t, "hello", *s)
|
||||||
|
|
||||||
b := Ptr(true)
|
b := To(true)
|
||||||
assert.NotNil(t, b)
|
assert.NotNil(t, b)
|
||||||
assert.True(t, *b)
|
assert.True(t, *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeref(t *testing.T) {
|
func TestDeref(t *testing.T) {
|
||||||
v := Deref(Ptr(99), 0)
|
v := Deref(To(99), 0)
|
||||||
assert.Equal(t, 99, v)
|
assert.Equal(t, 99, v)
|
||||||
|
|
||||||
v = Deref[int](nil, 123)
|
v = Deref[int](nil, 123)
|
||||||
|
|
@ -30,7 +30,7 @@ func TestDeref(t *testing.T) {
|
||||||
s := Deref[string](nil, "default")
|
s := Deref[string](nil, "default")
|
||||||
assert.Equal(t, "default", s)
|
assert.Equal(t, "default", s)
|
||||||
|
|
||||||
b := Deref(Ptr(true), false)
|
b := Deref(To(true), false)
|
||||||
assert.True(t, b)
|
assert.True(t, b)
|
||||||
|
|
||||||
b = Deref[bool](nil, false)
|
b = Deref[bool](nil, false)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ func TestGoogleGroupOptionsWithoutServiceAccountJSON(t *testing.T) {
|
||||||
|
|
||||||
func TestGoogleGroupOptionsWithoutAdminEmail(t *testing.T) {
|
func TestGoogleGroupOptionsWithoutAdminEmail(t *testing.T) {
|
||||||
o := testOptions()
|
o := testOptions()
|
||||||
o.Providers[0].GoogleConfig.UseApplicationDefaultCredentials = ptr.Ptr(true)
|
o.Providers[0].GoogleConfig.UseApplicationDefaultCredentials = ptr.To(true)
|
||||||
err := Validate(o)
|
err := Validate(o)
|
||||||
assert.NotEqual(t, nil, err)
|
assert.NotEqual(t, nil, err)
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ func TestGoogleGroupOptionsWithoutGroups(t *testing.T) {
|
||||||
o := testOptions()
|
o := testOptions()
|
||||||
// Set admin email and application default credentials but no groups - should still require them
|
// Set admin email and application default credentials but no groups - should still require them
|
||||||
o.Providers[0].GoogleConfig.AdminEmail = "admin@example.com"
|
o.Providers[0].GoogleConfig.AdminEmail = "admin@example.com"
|
||||||
o.Providers[0].GoogleConfig.UseApplicationDefaultCredentials = ptr.Ptr(true)
|
o.Providers[0].GoogleConfig.UseApplicationDefaultCredentials = ptr.To(true)
|
||||||
err := Validate(o)
|
err := Validate(o)
|
||||||
// Should pass validation since google-group is now optional
|
// Should pass validation since google-group is now optional
|
||||||
assert.Equal(t, nil, err)
|
assert.Equal(t, nil, err)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ var _ = Describe("Upstreams", func() {
|
||||||
validStaticUpstream := options.Upstream{
|
validStaticUpstream := options.Upstream{
|
||||||
ID: "validStaticUpstream",
|
ID: "validStaticUpstream",
|
||||||
Path: "/validStaticUpstream",
|
Path: "/validStaticUpstream",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
}
|
}
|
||||||
validFileUpstream := options.Upstream{
|
validFileUpstream := options.Upstream{
|
||||||
ID: "validFileUpstream",
|
ID: "validFileUpstream",
|
||||||
|
|
@ -145,11 +145,11 @@ var _ = Describe("Upstreams", func() {
|
||||||
ID: "foo",
|
ID: "foo",
|
||||||
Path: "/foo",
|
Path: "/foo",
|
||||||
URI: "ftp://foo",
|
URI: "ftp://foo",
|
||||||
Static: ptr.Ptr(true),
|
Static: ptr.To(true),
|
||||||
FlushInterval: &flushInterval,
|
FlushInterval: &flushInterval,
|
||||||
PassHostHeader: ptr.Ptr(true),
|
PassHostHeader: ptr.To(true),
|
||||||
ProxyWebSockets: ptr.Ptr(true),
|
ProxyWebSockets: ptr.To(true),
|
||||||
InsecureSkipTLSVerify: ptr.Ptr(true),
|
InsecureSkipTLSVerify: ptr.To(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ var _ = Describe("ADFS Provider Tests", func() {
|
||||||
ProtectedResource: resource,
|
ProtectedResource: resource,
|
||||||
Scope: "",
|
Scope: "",
|
||||||
}, options.Provider{
|
}, options.Provider{
|
||||||
ADFSConfig: options.ADFSOptions{SkipScope: ptr.Ptr(true)},
|
ADFSConfig: options.ADFSOptions{SkipScope: ptr.To(true)},
|
||||||
})
|
})
|
||||||
|
|
||||||
result := p.GetLoginURL("https://example.com/adfs/oauth2/", "", "", url.Values{})
|
result := p.GetLoginURL("https://example.com/adfs/oauth2/", "", "", url.Values{})
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func TestAzureEntraOIDCProviderNewMultiTenant(t *testing.T) {
|
||||||
provider := NewMicrosoftEntraIDProvider(&ProviderData{},
|
provider := NewMicrosoftEntraIDProvider(&ProviderData{},
|
||||||
options.Provider{OIDCConfig: options.OIDCOptions{
|
options.Provider{OIDCConfig: options.OIDCOptions{
|
||||||
IssuerURL: "https://login.microsoftonline.com/common/v2.0",
|
IssuerURL: "https://login.microsoftonline.com/common/v2.0",
|
||||||
InsecureSkipIssuerVerification: ptr.Ptr(true),
|
InsecureSkipIssuerVerification: ptr.To(true),
|
||||||
}},
|
}},
|
||||||
)
|
)
|
||||||
g.Expect(provider.Data().ProviderName).To(Equal("Microsoft Entra ID"))
|
g.Expect(provider.Data().ProviderName).To(Equal("Microsoft Entra ID"))
|
||||||
|
|
@ -91,8 +91,8 @@ func TestAzureEntraOIDCProviderValidateSessionAllowedTenants(t *testing.T) {
|
||||||
options.Provider{
|
options.Provider{
|
||||||
OIDCConfig: options.OIDCOptions{
|
OIDCConfig: options.OIDCOptions{
|
||||||
IssuerURL: "https://login.microsoftonline.com/common/v2.0",
|
IssuerURL: "https://login.microsoftonline.com/common/v2.0",
|
||||||
InsecureSkipIssuerVerification: ptr.Ptr(true),
|
InsecureSkipIssuerVerification: ptr.To(true),
|
||||||
InsecureSkipNonce: ptr.Ptr(true),
|
InsecureSkipNonce: ptr.To(true),
|
||||||
},
|
},
|
||||||
MicrosoftEntraIDConfig: options.MicrosoftEntraIDOptions{
|
MicrosoftEntraIDConfig: options.MicrosoftEntraIDOptions{
|
||||||
AllowedTenants: []string{"85d7d600-7804-4d92-8d43-9c33c21c130c"},
|
AllowedTenants: []string{"85d7d600-7804-4d92-8d43-9c33c21c130c"},
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ func TestSkipOIDCDiscovery(t *testing.T) {
|
||||||
ClientSecretFile: clientSecret,
|
ClientSecretFile: clientSecret,
|
||||||
OIDCConfig: options.OIDCOptions{
|
OIDCConfig: options.OIDCOptions{
|
||||||
IssuerURL: msIssuerURL,
|
IssuerURL: msIssuerURL,
|
||||||
SkipDiscovery: ptr.Ptr(true),
|
SkipDiscovery: ptr.To(true),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ func TestURLsCorrectlyParsed(t *testing.T) {
|
||||||
RedeemURL: msTokenURL,
|
RedeemURL: msTokenURL,
|
||||||
OIDCConfig: options.OIDCOptions{
|
OIDCConfig: options.OIDCOptions{
|
||||||
IssuerURL: msIssuerURL,
|
IssuerURL: msIssuerURL,
|
||||||
SkipDiscovery: ptr.Ptr(true),
|
SkipDiscovery: ptr.To(true),
|
||||||
JwksURL: msKeysURL,
|
JwksURL: msKeysURL,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ func TestScope(t *testing.T) {
|
||||||
AllowedGroups: tc.allowedGroups,
|
AllowedGroups: tc.allowedGroups,
|
||||||
OIDCConfig: options.OIDCOptions{
|
OIDCConfig: options.OIDCOptions{
|
||||||
IssuerURL: msIssuerURL,
|
IssuerURL: msIssuerURL,
|
||||||
SkipDiscovery: ptr.Ptr(true),
|
SkipDiscovery: ptr.To(true),
|
||||||
JwksURL: msKeysURL,
|
JwksURL: msKeysURL,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +298,7 @@ func TestEmailClaimCorrectlySet(t *testing.T) {
|
||||||
RedeemURL: msTokenURL,
|
RedeemURL: msTokenURL,
|
||||||
OIDCConfig: options.OIDCOptions{
|
OIDCConfig: options.OIDCOptions{
|
||||||
IssuerURL: msIssuerURL,
|
IssuerURL: msIssuerURL,
|
||||||
SkipDiscovery: ptr.Ptr(true),
|
SkipDiscovery: ptr.To(true),
|
||||||
JwksURL: msKeysURL,
|
JwksURL: msKeysURL,
|
||||||
UserIDClaim: tc.userIDClaim,
|
UserIDClaim: tc.userIDClaim,
|
||||||
EmailClaim: tc.emailClaim,
|
EmailClaim: tc.emailClaim,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue