Don't log invalid redirect if redirect is empty
This commit is contained in:
		
							parent
							
								
									713c3927a9
								
							
						
					
					
						commit
						dc756b9de3
					
				|  | @ -56,6 +56,7 @@ | ||||||
| ## Changes since v5.1.1 | ## Changes since v5.1.1 | ||||||
| 
 | 
 | ||||||
| - [#620](https://github.com/oauth2-proxy/oauth2-proxy/pull/620) Add HealthCheck middleware (@JoelSpeed) | - [#620](https://github.com/oauth2-proxy/oauth2-proxy/pull/620) Add HealthCheck middleware (@JoelSpeed) | ||||||
|  | - [#597](https://github.com/oauth2-proxy/oauth2-proxy/pull/597) Don't log invalid redirect if redirect is empty (@JoelSpeed) | ||||||
| - [#604](https://github.com/oauth2-proxy/oauth2-proxy/pull/604) Add Keycloak local testing environment (@EvgeniGordeev) | - [#604](https://github.com/oauth2-proxy/oauth2-proxy/pull/604) Add Keycloak local testing environment (@EvgeniGordeev) | ||||||
| - [#539](https://github.com/oauth2-proxy/oauth2-proxy/pull/539) Refactor encryption ciphers and add AES-GCM support (@NickMeves) | - [#539](https://github.com/oauth2-proxy/oauth2-proxy/pull/539) Refactor encryption ciphers and add AES-GCM support (@NickMeves) | ||||||
| - [#601](https://github.com/oauth2-proxy/oauth2-proxy/pull/601) Ensure decrypted user/email are valid UTF8 (@JoelSpeed) | - [#601](https://github.com/oauth2-proxy/oauth2-proxy/pull/601) Ensure decrypted user/email are valid UTF8 (@JoelSpeed) | ||||||
|  |  | ||||||
|  | @ -598,6 +598,9 @@ func validOptionalPort(port string) bool { | ||||||
| // IsValidRedirect checks whether the redirect URL is whitelisted
 | // IsValidRedirect checks whether the redirect URL is whitelisted
 | ||||||
| func (p *OAuthProxy) IsValidRedirect(redirect string) bool { | func (p *OAuthProxy) IsValidRedirect(redirect string) bool { | ||||||
| 	switch { | 	switch { | ||||||
|  | 	case redirect == "": | ||||||
|  | 		// The user didn't specify a redirect, should fallback to `/`
 | ||||||
|  | 		return false | ||||||
| 	case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//") && !invalidRedirectRegex.MatchString(redirect): | 	case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//") && !invalidRedirectRegex.MatchString(redirect): | ||||||
| 		return true | 		return true | ||||||
| 	case strings.HasPrefix(redirect, "http://") || strings.HasPrefix(redirect, "https://"): | 	case strings.HasPrefix(redirect, "http://") || strings.HasPrefix(redirect, "https://"): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue