-
-
Notifications
You must be signed in to change notification settings - Fork 144
BE: RBAC: Support provider for basic auth #917
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
Conversation
api/src/main/java/io/kafbat/ui/config/auth/BasicAuthSecurityConfig.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/kafbat/ui/model/rbac/provider/Provider.java
Outdated
Show resolved
Hide resolved
create basic auth extractor
refactoring
} | ||
} | ||
|
||
private String password(String password, PasswordEncoder encoder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we even need this method, we could delegate this to the encoder which should handle this via encoder.encode(password);
|
||
return new RbacUserDetailsService(new RbacBasicAuthUser(userDetails, extractor.groups(user.getName()))); | ||
} else { | ||
return new MapReactiveUserDetailsService(userDetails); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we can do a fast return in the beginning of the method
.filter(role -> role.getSubjects().stream() | ||
.filter(subj -> Provider.LOGIN_FORM.equals(subj.getProvider())) | ||
.filter(subj -> "user".equals(subj.getType())) | ||
.anyMatch(subj -> username.equals(subj.getValue())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd suggest equalsIgnoreCase
here just in case, what do you think?
private WebTestClient client; | ||
|
||
@Test | ||
void testUserPermissions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding a test 😄
Implementing a default role makes sense, but that would still require creating a provider for |
Maybe instead of LoginForm it would be better to add provider wildcard (ANY) and add this role as default? |
I don't think so, we'd just apply a default role for anyone who can successfully log in, no matter what auth method |
@Haarolean @germanosin Alright, so can we close this PR then? |
yeah I think so. Sorry that we thought about it too late :) |
What changes did you make? (Give an overview)
Resolve #850
Is there anything you'd like reviewers to focus on?
How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)
Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)
Check out Contributing and Code of Conduct
A picture of a cute animal (not mandatory but encouraged)