canonical / oathkeeper-operator

Charmed Ory Oathkeeper
https://charmhub.io/oathkeeper
Apache License 2.0
1 stars 4 forks source link

fix: correct the regular expressions #53

Closed natalian98 closed 7 months ago

natalian98 commented 7 months ago

This PR tries to fix oathkeeper rules not handling urls with trailing slashes. The "deny" regex should match everything except for the allowed endpoints.

You can quickly check it with https://regex101.com/

# deny regex
^(https|http):\/\/example.com(?!\/welcome((\/.*$)|$)|\/about\/app((\/.*$)|$)).*

# will match the first 3
https://example.com/about/
https://example.com/
https://example.com
https://example.com/about/app
https://example.com/welcome
https://example.com/about/app/
https://example.com/welcome/

With the previous regex, the third url is not matched, while the last two are. Both cases are incorrect.

# allow regex
^(https|http):\/\/example.com\/welcome((\/.*$)|$)

# will match both
https://example.com/welcome
https://example.com/welcome/

With the previous regex, only the first one is matched