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

Allow to remove header group prefix #207

Merged
merged 2 commits into from
Jun 18, 2020

Conversation

offtherailz
Copy link
Member

This PR allows to remove from role headers a prefix for mapping groups.

@offtherailz offtherailz requested a review from mbarto June 15, 2020 14:35
@offtherailz offtherailz self-assigned this Jun 15, 2020
@coveralls
Copy link

coveralls commented Jun 15, 2020

Coverage Status

Coverage increased (+0.1%) to 38.233% when pulling f809cf5 on offtherailz:fix_header_prefix into e89c33c on geosolutions-it:master.

@@ -77,6 +81,9 @@ protected void authenticate(HttpServletRequest req) {
if (groupName.equals(GroupReservedNames.EVERYONE.groupName())) {
everyoneFound = true;
}
if(groupHeaderPrefix != null && groupName.startsWith(groupHeaderPrefix)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to implement a more generic (and optional) groupName mapper that transforms group names using an SpEl expression.

Copy link
Member Author

@offtherailz offtherailz Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, I didn't do that because testing was hard. Now I'm more confident and I think I can do it relatively quickly
I need a map of regex --> expression.

@@ -77,6 +81,9 @@ protected void authenticate(HttpServletRequest req) {
if (groupName.equals(GroupReservedNames.EVERYONE.groupName())) {
everyoneFound = true;
}
if(groupHeaderPrefix != null && groupName.startsWith(groupHeaderPrefix)) {
groupName = groupName.replaceAll(groupHeaderPrefix, "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to transform ROLE_SOMETHINGROLE_ into SOMETHING, because of replaceAll

@offtherailz offtherailz requested a review from mbarto June 16, 2020 14:06
@offtherailz offtherailz merged commit bec43cd into geosolutions-it:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants