Have a look at the API Gateway tutorials and the samples in the examples/oauth2 folder of the Membrane distribution.
ReDoS Protection
ReDoS Attacks on APIs and Gateways What regular expression denial of service is, how backtracking makes it possible, and why APIs and OpenAPI patterns are affected.