authcrunch / authcrunch.github.io

Documentation for Caddy v2 Auth Portal and Authorize Plugins.
81 stars 35 forks source link

Improve 'regex match role' to note escaping braces #64

Open mechanarchy opened 2 months ago

mechanarchy commented 2 months ago

I am trying to match and drop roles named as GUIDs, using:

transform user {
  regex match role "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
  action drop matched role
}

However, this conflicts with Caddy's use of placeholders, and the {4} are stripped out, meaning that this matching rule does not work as expected. The correct syntax to use here is:

regex match role "[0-9a-f]\\{8\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{4\\}-[0-9a-f]\\{12\\}"

Please can this be noted in the documentation to help other users avoid the same pitfall: https://github.com/authcrunch/authcrunch.github.io/blob/c6d02968980595021863c223369f9f6cb31992b6/docs/authenticate/42-user-transforms.md?plain=1#L148-L160

greenpau commented 2 months ago

@mechanarchy , thank you for pointing this out. Please submit PR to the docs repo.

mechanarchy commented 2 months ago

Thanks @greenpau , I have opened #65.