Skip to content

Configurable Keto variables - #870

Closed
AnujaVane wants to merge 3 commits into
feast-dev:masterfrom
Cimpress-MCP:feature/keto-config
Closed

AnujaVane wants to merge 3 commits into
feast-dev:masterfrom
Cimpress-MCP:feature/keto-config

Conversation

@AnujaVane

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

  1. Configurable permission role templates.
  2. Configurable subject from the JWT token.

Does this PR introduce a user-facing change?: NONE

@feast-ci-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AnujaVane
To complete the pull request process, please assign davidheryanto
You can assign the PR to them by writing /assign @davidheryanto in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@feast-ci-bot

Copy link
Copy Markdown
Collaborator

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@AnujaVane AnujaVane changed the title WIP : Feature/keto config WIP: Configurable Keto variables Jul 9, 2020
@dr3s

dr3s commented Jul 9, 2020

Copy link
Copy Markdown
Collaborator

run mvn spotless:apply

@AnujaVane AnujaVane changed the title WIP: Configurable Keto variables Configurable Keto variables Jul 9, 2020
}
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath(options.get("basePath"));
defaultClient.setBasePath((String) options.get("basePath"));

Copy link
Copy Markdown
Collaborator

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

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";

Copy link
Copy Markdown
Collaborator

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

*/
public AuthorizationResult checkAccess(String project, Authentication authentication) {
String email = getEmailFromAuth(authentication);
String subject = (String) this.options.get("subject");

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

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) {

Copy link
Copy Markdown
Collaborator

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);

Copy link
Copy Markdown
Collaborator

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 @@ public static class AuthorizationProperties {
private String provider;

// K/V options to initialize the provider with

Copy link
Copy Markdown
Collaborator

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}")) {

Copy link
Copy Markdown
Collaborator

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.

@dr3s

dr3s commented Jul 9, 2020

Copy link
Copy Markdown
Collaborator

/lgtm

@dr3s

dr3s commented Jul 9, 2020

Copy link
Copy Markdown
Collaborator

/ok-to-test

subject: email
roles:
- role:feast:admin
- role:feast:{PROJECT}-member

Copy link
Copy Markdown
Member

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.

@woop

woop commented Jul 10, 2020

Copy link
Copy Markdown
Member

I think a fundamental problem that I have with the current checkAccess implementation for Keto is that it doesn't use Keto as intended. Yes, we can retrieve the roles and parse it client-side to determine access, but that is what the /allowed endpoint on Keto is for. In a sense, I think we are duplicating work by adding role templating into Feast. Keto already supports this through its pattern matching.

@woop

woop commented Jul 10, 2020

Copy link
Copy Markdown
Member

/ok-to-test

@feast-ci-bot

Copy link
Copy Markdown
Collaborator

@AnujaVane: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
test-end-to-end-batch 1da5201 link /test test-end-to-end-batch
test-end-to-end-auth 1da5201 link /test test-end-to-end-auth

Full PR test history

Details

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.

@dr3s dr3s closed this Jul 10, 2020
@dr3s

dr3s commented Jul 10, 2020

Copy link
Copy Markdown
Collaborator

replaced with #864

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.

4 participants