feat: Add RBAC blog post to website (#5861) · feast-dev/feast@b1844a3
1+---
2+title: Feast Launches RBAC!
3+description: Feast now supports Role Based Access Controls (RBAC) so you can secure and govern your data with granular authorization policies.
4+date: 2024-11-21
5+authors: ["Danielle Martinoli", "Francisco Javier Arceo"]
6+---
7+8+<div class="hero-image">
9+<img src="/images/blog/rbac-architecture.jpg" alt="Feast RBAC Architecture" loading="lazy">
10+</div>
11+12+# Feast Launches RBAC! 🚀
13+14+# What is the Feast Permission Model?
15+16+Feast now supports Role Based Access Controls (RBAC) so you can secure and govern your data.
17+18+If you ever wanted to securely partition your feature store across different teams, the new Feast permissions model is here to make that possible!
19+20+This powerful feature allows administrators to configure granular authorization policies, letting them decide which users and groups can access specific resources and what operations they can perform.
21+22+The default implementation is based on Role-Based Access Control (RBAC): user roles determine whether a user has permission to perform specific functions on registered resources.
23+24+# Why is RBAC important for Feast?
25+26+Feature stores often operate on sensitive, proprietary data and we want to make sure teams are able to govern the access and control of that data thoughtfully, while benefiting from transparent code and an open source community like Feast.
27+28+That's why we built RBAC using [Kubernetes RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac) and [OpenID Connect protocol (OIDC)](https://auth0.com/docs/authenticate/protocols/openid-connect-protocol), ensuring secure, fine-grained access control in Feast.
29+30+# What are the Benefits of using Feast Permissions?
31+32+Using the Feast Permissions Model offers two key benefits:
33+34+1. Securely share and partition your feature store: grant each team only the minimum privileges necessary to access and manage the relevant resources.
35+2. Adopt a Service-Oriented Architecture and leverage the benefits of a distributed system.
36+37+# How Feast Uses RBAC
38+39+## Permissions as Feast resources
40+41+The RBAC configuration is defined using a new Feast object type called "Permission". Permissions are registered in the Feast registry and are defined and applied like all the other registry objects, using Python code.
42+43+A permission is defined by these three components:
44+45+* A **resource**: a Feast object that we want to secure against unauthorized access. It's identified by the matching type(s), a possibly empty list of name patterns and a dictionary of required tags.
46+* An **action**: a logical operation performed on the secured resource, such as managing the resource state with CREATE, DESCRIBE, UPDATE or DELETE, or accessing the resource data with READ and WRITE (differentiated by ONLINE and OFFLINE store types)
47+* A **policy**: the rule to enforce authorization decisions based on the current user. The default implementation uses role-based policies.
48+49+The resource types supported by the permission framework are those defining the customer feature store:
50+51+* Project
52+* Entity
53+* FeatureView
54+* OnDemandFeatureView
55+* BatchFeatureView
56+* StreamFeatureView
57+* FeatureService
58+* DataSource
59+* ValidationReference
60+* SavedDataset
61+* Permission
62+63+64+**TIP**: Check out the Permission APIs in the [Feast Python API Documentation](https://docs.feast.dev/getting-started/concepts/permission) to learn more!
65+66+```python
67+# This configuration grants users with the 'owner' role permissions
68+# to fetch resource status and read data from all the feature views
69+from feast.permissions.action import AuthzedAction, READ
70+# Note: READ is a global list including both READ_OFFLINE and
71+# READ_ONLINE values from AuthzedAction enum
72+73+# You do not have to specify `name_patterns`
74+Permission(
75+name="fv-owner",
76+types=[FeatureView],
77+policy=RoleBasedPolicy(roles=["owner"]),
78+actions=[AuthzedAction.DESCRIBE, READ],
79+)
80+81+# This configuration grants users with the 'lab' role permissions
82+# to fetch resource status and read data from all feature views
83+# named 'lab_stream_feature_view' or 'lab_feature_view'
84+from feast.permissions.action import AuthzedAction, READ
85+86+Permission(
87+name="lab-reader",
88+types=[FeatureView],
89+name_patterns=["lab_stream_feature_view", "lab_feature_view"],
90+policy=RoleBasedPolicy(roles=["lab"]),
91+actions=[AuthzedAction.DESCRIBE, READ],
92+)
93+94+# As an alternative, we can use Python regular expression patterns
95+# to grant the same permission to all feature views whose name
96+# starts by 'lab'
97+from feast.permissions.action import AuthzedAction, READ
98+99+Permission(
100+name="lab-reader",
101+types=[FeatureView],
102+name_patterns="lab.*", # Accepts both 'str' and 'list[str]' types
103+policy=RoleBasedPolicy(roles=["lab"]),
104+actions=[AuthzedAction.DESCRIBE, READ],
105+)
106+107+# This configuration grants users with the 'prod' role permissions
108+# to fetch resource status and read data from all feature views
109+# whose names include the '_prod_' word
110+from feast.permissions.action import AuthzedAction, READ
111+112+Permission(
113+name="prod-reader",
114+types=[FeatureView, FeatureService],
115+name_patterns=".*_prod_.*",
116+policy=RoleBasedPolicy(roles=["prod"]),
117+actions=[AuthzedAction.DESCRIBE, READ],
118+)
119+120+# This configuration grants permissions to write on all data sources
121+# tagged with 'risk_level' set to 'high', exclusively to users
122+# with the 'admin' or 'data_team' roles
123+from feast.permissions.action import WRITE
124+# Note: WRITE is a global list including both WRITE_OFFLINE and
125+# WRITE_ONLINE values from AuthzedAction enum
126+127+Permission(
128+name="data-writer",
129+types=[DataSource],
130+required_tags={"risk_level": "high"},
131+policy=RoleBasedPolicy(roles=["admin", "data_team"]),
132+actions=[WRITE],
133+)
134+```
135+136+## Why Now is the Time for Distributed Feature Stores
137+138+But wait a moment—does that mean every time I access the FeatureStore API, I have to go through an authorization check?
139+140+Well, yes and no-but mostly no if you work in a development environment.
141+If your environment doesn't use any remote Feast service, RBAC enforcement won't take place.
142+143+Indeed, the reference architecture for the permission model feature represents a fully distributed environment:
144+145+<div class="content-image">
146+<img src="/images/blog/rbac-architecture.jpg" alt="RBAC Architecture Diagram" loading="lazy">
147+</div>
148+149+* Feast functions are deployed as interconnected services.
150+* Service endpoints enforce authorization, processing only authorized requests.
151+* Clients use the feature store transparently, with authorization headers automatically injected in every request.
152+* Service-to-service communications are permitted automatically.
153+154+Currently, only the following Python servers are supported in an authorized environment:
155+- Online REST feature server
156+- Offline Arrow Flight feature server
157+- gRPC Registry server
158+159+## Configuring Feast Authorization
160+161+For backward compatibility, by default no authorizations are enforced. The authorization functionality must be explicitly enabled using the auth configuration section in feature\_store.yaml.
162+Of course, all server and client applications must have a consistent configuration.
163+164+Currently, feast supports [OIDC](https://auth0.com/docs/authenticate/protocols/openid-connect-protocol) and [Kubernetes RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac) authentication/authorization.
165+166+* With OIDC authorization, the client uses an OIDC server to fetch a JSON Web Token (JWT), which is then included in every request. On the server side, the token is parsed to extract user roles and validate them against the configured permissions.
167+* With Kubernetes authorization, the client injects its service account JWT token into the request. The server then extracts the service account name from the token and uses it to look up the associated role in the Kubernetes RBAC resources.
168+169+## Inspecting and Troubleshooting the Permissions Model
170+171+The feast CLI includes a new `permissions` command to list the registered permissions, with options to identify the matching resources for each configured permission and the existing resources that are not covered by any permission.
172+173+For troubleshooting purposes, it also provides a command to list all the resources and operations allowed to any managed role.
174+175+# How Can I Get Started?
176+177+This new feature includes working examples for both supported authorization protocols. You can start by experimenting with these examples to see how they fit your own feature store and assess their benefits.
178+179+As this is a completely new functionality, your feedback will be extremely valuable. It will help us adapt the feature to meet real-world requirements and better serve our customers.