mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 09:19:39 +02:00
core/config: add support for stripping the port for matching routes (#5085)
* core/config: add support for stripping the port for matching routes * fix test * rename option, improve port detection * add more test cases
This commit is contained in:
parent
498c3aa108
commit
5373e25ac4
14 changed files with 100 additions and 34 deletions
|
@ -613,14 +613,14 @@ func (p *Policy) String() string {
|
|||
}
|
||||
|
||||
// Matches returns true if the policy would match the given URL.
|
||||
func (p *Policy) Matches(requestURL url.URL) bool {
|
||||
func (p *Policy) Matches(requestURL url.URL, stripPort bool) bool {
|
||||
// an invalid from URL should not match anything
|
||||
fromURL, err := urlutil.ParseAndValidateURL(p.From)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if !FromURLMatchesRequestURL(fromURL, &requestURL) {
|
||||
if !FromURLMatchesRequestURL(fromURL, &requestURL, stripPort) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue