Skip to content

Conversation

@dmartinol
Copy link
Contributor

@dmartinol dmartinol commented Aug 5, 2024

What this PR does / why we need it:

This PR proposes a permission model to enable the store administrator to identify which users are allowed to execute operations on each managed resource.

Granular permission enforcement identifies user roles (*) allowed to execute requested operations on
resources matched by type, optional name patterns, and tags:

Permission(
    name="reader",
    types=[FeatureView],
    name_pattern=".*risky.*",
    policy=RoleBasedPolicy(roles=["trusted"]),
    actions=[AuthzedAction.QUERY_OFFLINE],
)

Such resource partitioning allows teams working on the same set of features to share the same feature store, mitigating the risk of unexpected changes due to unauthorized operations.

The PR also adds support for managing authorization tokens from either OIDC or Kubernetes, in a configurable way.

Permission authorization enforcement is performed when requests are executed through one of the Feast (Python) servers:

  • The online feature server (REST)
  • The offline feature server (Arrow Flight)
  • The registry server (grpc)
project: foo
registry: "registry.db"
provider: local
online_store:
  path: foo
entity_key_serialization_version: 2
auth:
  type: kubernetes

To avoid backward incompatibility with existing installations, the default authorization is not enabled (e.g., auth type
is set to no-auth) .

Feast clients can use the same configuration options to automatically retrieve the token from the authorization server
and transparently secure all the remote requests. This pattern allows the client to use the authorization infrastructure without affecting the business code.

By design, only the client requests are validated: once the endpoint execution is permitted for the original client request,
all the next service-to-service requests generated by the execution flow are automatically allowed.

Validation is typically implemented within the endpoint functions using an assertion-like style:

        assert_permissions(
            resource=FeatureView.from_proto(request.feature_view),
            actions=[AuthzedAction.WRITE_ONLINE],
        )

The PR also includes:

  • Docs update to provide general description of the feature
  • Unit test for all the new modules
  • Integration tests to verify the server behavior while adding the authorization components
  • New permission CLI command with sub-commands to explore and troubleshoot the permissions settings

Fully working examples both Kubernetes and OIDC authorization will be in another next PR.

(*) Match by role is the predefined option, but it can be customized to support any other user validation.

Other features coming soon

Which issue(s) this PR fixes:

Fixes #4198

@dmartinol dmartinol changed the title Feast Security Model (aka RBAC) feat: Feast Security Model (aka RBAC) Aug 5, 2024
@redhatHameed redhatHameed force-pushed the feast-rbac branch 3 times, most recently from 13c57d4 to c456222 Compare August 5, 2024 16:27
@dmartinol dmartinol marked this pull request as ready for review August 5, 2024 17:24
@tokoko
Copy link
Collaborator

tokoko commented Aug 5, 2024

This is gonna take a while 😄

@HaoXuAI
Copy link
Collaborator

HaoXuAI commented Aug 6, 2024

Hey, this is a great feature and also a big PR. Maybe it's better to walk us through the design, implementation, demo etc. in the next standup to get us understanding it better?

@redhatHameed
Copy link
Contributor

redhatHameed commented Aug 6, 2024

Hey, this is a great feature and also a big PR. Maybe it's better to walk us through the design, implementation, demo etc. in the next standup to get us understanding it better?

sure, this will be a good idea.
cc @jeremyary @dmartinol

@redhatHameed redhatHameed force-pushed the feast-rbac branch 2 times, most recently from 9b8f88d to 0a3a3ba Compare August 7, 2024 13:13
@dmartinol
Copy link
Contributor Author

dmartinol commented Aug 7, 2024

@tokoko we realized that when the remote registry (transparently) invokes a server API, there's no way to catch a FeatureViewNotFoundException as in this example, because the server raises an InactiveRpcError instead.

Should we create an issue to extend the registry server to add error details and the registry client to convert the grpc error into the original Exception? I don't think this has to be part of the RBAC commit.

@redhatHameed FYI this is also the root cause of the error in the demo setup

An error occurred: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Exception calling application: Feature view driver_hourly_stats_fresh does not exist in project server"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Exception calling application: Feature view driver_hourly_stats_fresh does not exist in project server", grpc_status:2, created_time:"2024-08-07T15:00:29.930731564+00:00"}"
>

@tokoko
Copy link
Collaborator

tokoko commented Aug 7, 2024

@dmartinol sure, sounds like a bug to me. That should be tested in registry tests as well, I think. please go ahead and create a ticket.

@franciscojavierarceo
Copy link
Member

In the PR template you say

"To avoid backward compatibilities with existing installations, the default authorization is not enabled (e.g., auth type is set to no-auth) ."

Did you mean "To avoid backward incompatibility with.."


## Introduction

Role-Based Access Control (RBAC) is a security mechanism that restricts access to resources based on the roles of individual users within an organization. In the context of the Feast Feature Store, RBAC ensures that only authorized users or groups can access or modify specific resources, thereby maintaining data security and operational integrity.

Choose a reason for hiding this comment

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

Suggested change
Role-Based Access Control (RBAC) is a security mechanism that restricts access to resources based on the roles of individual users within an organization. In the context of the Feast Feature Store, RBAC ensures that only authorized users or groups can access or modify specific resources, thereby maintaining data security and operational integrity.
Role-Based Access Control (RBAC) is a security mechanism that restricts access to resources based on the roles of individual users within an organization. In the context of the Feast Feature Store, RBAC ensures that only authorized users or groups can access or modify specific resources, thereby maintaining data security and operational integrity.
Suggested change
Role-Based Access Control (RBAC) is a security mechanism that restricts access to resources based on the roles of individual users within an organization. In the context of the Feast Feature Store, RBAC ensures that only authorized users or groups can access or modify specific resources, thereby maintaining data security and operational integrity.
Role-Based Access Control (RBAC) is a security mechanism that restricts access to resources based on the roles of individual users within an organization. In the context of the Feast, RBAC ensures that only authorized users or groups can access or modify specific resources, thereby maintaining data security and operational integrity.


## Functional Requirements

The RBAC implementation in Feast Feature Store is designed to:

Choose a reason for hiding this comment

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

Suggested change
The RBAC implementation in Feast Feature Store is designed to:
The RBAC implementation in Feast is designed to:


## Business Goals

The primary business goals of implementing RBAC in the Feast Feature Store are:

Choose a reason for hiding this comment

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

Suggested change
The primary business goals of implementing RBAC in the Feast Feature Store are:
The primary business goals of implementing RBAC in the Feast are:


The primary business goals of implementing RBAC in the Feast Feature Store are:

1. **Feature Sharing**: Enable multiple teams to share the feature store while ensuring controlled access to data partitions. This allows for collaborative work without compromising data security.

Choose a reason for hiding this comment

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

Suggested change
1. **Feature Sharing**: Enable multiple teams to share the feature store while ensuring controlled access to data partitions. This allows for collaborative work without compromising data security.
1. **Feature Sharing**: Enable multiple teams to share the feature store while ensuring controlled access. This allows for collaborative work without compromising data security.


## Reference Architecture

The Feast Feature Store operates as a collection of connected services, each enforcing authorization permissions. The architecture is designed as a distributed microservices system with the following key components:

Choose a reason for hiding this comment

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

Suggested change
The Feast Feature Store operates as a collection of connected services, each enforcing authorization permissions. The architecture is designed as a distributed microservices system with the following key components:
Feast operates as a collection of connected services, each enforcing authorization permissions. The architecture is designed as a distributed microservices system with the following key components:


The Feast Feature Store operates as a collection of connected services, each enforcing authorization permissions. The architecture is designed as a distributed microservices system with the following key components:

- **Service Endpoints**: These enforce authorization permissions, ensuring that only authorized requests are processed.

Choose a reason for hiding this comment

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

Can you confirm that these three are correct? i know this was generated with an LLM (which is fine!) but I think some of this may not be right.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's correct, simplified it more .

note Service-to-Service Communication this feature not yet part of this PR will be implementation next PRs.

- **Action**: A logical operation performed on a resource, such as Create, Describe, Update, Delete, query, or write operations.
- **Policy**: A set of rules that enforce authorization decisions on resources. The default implementation uses role-based policies.

### Configuring Permissions

Choose a reason for hiding this comment

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

Please remove this section as the architecture is meant to give a motivation and not the implementation details.

Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

Last changes. The architecture section should be pretty high level. I believe some of what you added to a PR is included in other documentation. If it's not, can you add it to the components section? I like the documentation, I just think it's better served under the components section.

After that I think we're good.

)
```

### Enforcing Permission Policy

Choose a reason for hiding this comment

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

Please remove this section as well.

Comment on lines 64 to 73
```python
assert_permissions(
resource=feature_service,
actions=[AuthzedAction.QUERY_ONLINE]
)
```

## Use Cases

### Tag-Based Permission

Choose a reason for hiding this comment

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

Please remove this section as well.

)
```

### Name-Based Permission

Choose a reason for hiding this comment

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

Please remove this section as well.

3. **Policy Enforcer**: Validates the secured endpoint against the retrieved user details.
4. **Token Injector**: Adds the authorization token to each secured request header.

### OIDC Authorization

Choose a reason for hiding this comment

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

Please remove this section as well.

auth_server_url: _OIDC_SERVER_URL_
```
### Kubernetes Authorization

Choose a reason for hiding this comment

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

Please remove this section as well.

@redhatHameed
Copy link
Contributor

redhatHameed commented Aug 20, 2024

Last changes. The architecture section should be pretty high level. I believe some of what you added to a PR is included in other documentation. If it's not, can you add it to the components section? I like the documentation, I just think it's better served under the components section.

After that I think we're good.

Agreed was repetition these are already aded into components section, hence removed from here.

[![License](https://img.shields.io/badge/License-Apache%202.0-blue)](https://github.com/feast-dev/feast/blob/master/LICENSE)
[![GitHub Release](https://img.shields.io/github/v/release/feast-dev/feast.svg?style=flat&sort=semver&color=blue)](https://github.com/feast-dev/feast/releases)

## Join us on Slack!

Choose a reason for hiding this comment

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

Can you revert this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

Amazing work here, thanks for taking in all of the changes!

/lgtm

@redhatHameed
Copy link
Contributor

redhatHameed commented Aug 21, 2024

@tokoko @franciscojavierarceo Thanks for taking time to review and approve this

Next PRs will handle:

  1. Working examples of RBAC configuration with OIDC and Kubernetes.
  2. Solution for intra-service communication
  3. Fix the dependencies to make it not required in setup.py
  4. Refactoring the OIDC authentication to use discovery URL

Also if there is no any further concern can you merge this Thanks

cc @jeremyary @dandawg

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.

Security Model

8 participants