A regular expression (regex) describes character or string formats for matching requests when ordinary path expressions cannot express the authorization rule. section 8.3 section 8.4
Use regexes selectively because they provide power at the cost of readability:
- Match detailed path conditions, including symbols, characters, or combinations of path variables. section 8.3
- Pass a RegexRequestMatcher to requestMatchers(), or configure regexMatchers() for endpoint authorization. section 8.3
- Prefer path expressions when they are sufficient, and reserve regexes for requirements those expressions cannot handle. section 8.3
Authorize video requests
A video endpoint accepts any authenticated user when the country is the United States, Canada, or United Kingdom, or when the language is English. A regex matcher allows john to access /video/us/en but rejects /video/fr/fr; jane, with the premium authority, can access both.


























