mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-19 04:47:48 +00:00
fix(security): allow loopback hosts for loopback providerURL (#154)
Issue #154: a providerURL that points at a localhost IdP caused an infinite redirect loop. validateHost rejected loopback hosts unconditionally, so buildAuthURL returned an empty string. Derive allowLoopbackHosts from a loopback providerURL at construction time. Discovery validation already used this derivation, so the two validation layers now agree. This adds no new config surface. Cloud metadata hosts (169.254.169.254, metadata.google.internal), link-local, and unspecified addresses stay blocked unconditionally. Non-loopback providers keep identical behaviour. Add issue154_regression_test.go: 8 tests pin the new allowance, the default block, and the security envelope.
This commit is contained in:
+12
@@ -671,6 +671,18 @@ func isLoopbackHost(host string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isLoopbackProviderURL reports whether providerURL's host is loopback
|
||||
// (localhost or a loopback IP literal). Used at construction time to derive
|
||||
// allowLoopbackHosts, so local-development providers are not blocked by
|
||||
// validateHost's outbound URL checks.
|
||||
func isLoopbackProviderURL(providerURL string) bool {
|
||||
pu, err := url.Parse(providerURL)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return isLoopbackHost(pu.Hostname())
|
||||
}
|
||||
|
||||
// isValidLogLevel checks if the provided log level string is one of the supported values ("debug", "info", "error").
|
||||
//
|
||||
// Parameters:
|
||||
|
||||
Reference in New Issue
Block a user