-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Configurable Keto variables #870
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: AnujaVane The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @AnujaVane. Thanks for your PR. I'm waiting for a feast-dev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
run |
if (options == null) { | ||
throw new IllegalArgumentException("Cannot pass empty or null options to KetoAuth"); | ||
} | ||
ApiClient defaultClient = Configuration.getDefaultApiClient(); | ||
defaultClient.setBasePath(options.get("basePath")); | ||
defaultClient.setBasePath((String) options.get("basePath")); |
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.
a better name for the option is authorizationUrl
@@ -57,20 +59,28 @@ public KetoAuthorizationProvider(Map<String, String> options) { | |||
* @return AuthorizationResult result of authorization query | |||
*/ | |||
public AuthorizationResult checkAccess(String project, Authentication authentication) { | |||
String email = getEmailFromAuth(authentication); | |||
String subject = (String) this.options.get("subject"); | |||
if ((subject == null) || (subject.isEmpty())) subject = "email"; |
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.
email
should be a constant like DEFAULT_SUBJECT_CLAIM
@@ -57,20 +59,28 @@ public KetoAuthorizationProvider(Map<String, String> options) { | |||
* @return AuthorizationResult result of authorization query | |||
*/ | |||
public AuthorizationResult checkAccess(String project, Authentication authentication) { | |||
String email = getEmailFromAuth(authentication); | |||
String subject = (String) this.options.get("subject"); |
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.
A better name for this option is subjectClaim
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.
rename the option and the variable actually
* @return String user email | ||
*/ | ||
private String getEmailFromAuth(Authentication authentication) { | ||
private String getSubjectFromAuth(Authentication authentication, String subject) { |
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.
rename subject
to subjectClaim
Jwt principle = ((Jwt) authentication.getPrincipal()); | ||
Map<String, Object> claims = principle.getClaims(); | ||
String email = (String) claims.get("email"); | ||
String subjectValue = (String) claims.get(subject); |
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.
subjectValue
can then be named subject
@@ -54,6 +54,6 @@ | |||
private String provider; | |||
|
|||
// K/V options to initialize the provider with |
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.
this is no longer a k/V pair since we allow a list for roles. may be worth a conversation
|| (String.format("roles:feast:%s-member", project)).equals(role.getId())) { | ||
return AuthorizationResult.success(); | ||
for (String roleTemplate : roleTemplates) { | ||
if (roleTemplate.contains("{PROJECT}")) { |
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.
PROJECT
could be a constant and actually could be in a list of constants that could be replaced in the role templates.
/lgtm |
/ok-to-test |
subject: email | ||
roles: | ||
- role:feast:admin | ||
- role:feast:{PROJECT}-member |
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 am a bit wary about using complex objects as options. I would strongly prefer to stick to K/V here, so perhaps we can turn roles into a CSV.
I think a fundamental problem that I have with the current |
/ok-to-test |
@AnujaVane: The following tests failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
replaced with #864 |
What this PR does / why we need it:
Does this PR introduce a user-facing change?: NONE