Skip to content

Commit 22880e7

Browse files
committed
Review comments addressed
Signed-off-by: jyejare <[email protected]>
1 parent 65ca1b1 commit 22880e7

File tree

4 files changed

+45
-49
lines changed

4 files changed

+45
-49
lines changed

docs/getting-started/architecture/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ typically your Offline Store). We are exploring adding a default streaming engin
1818

1919
* We recommend [using Python](language.md) for your Feature Store microservice. As mentioned in the document, precomputing features is the recommended optimal path to ensure low latency performance. Reducing feature serving to a lightweight database lookup is the ideal pattern, which means the marginal overhead of Python should be tolerable. Because of this we believe the pros of Python outweigh the costs, as reimplementing feature logic is undesirable. Java and Go Clients are also available for online feature retrieval.
2020

21-
* [Role-Based Access Control (RBAC)](rbac.md) 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.
21+
* [Role-Based Access Control (RBAC)](rbac.md) is a security mechanism that restricts access to resources based on the roles/groups/namespaces 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.
2222

2323

docs/getting-started/components/authz_manager.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ auth:
9999
100100
### Kubernetes RBAC Authorization
101101
With Kubernetes RBAC Authorization, the client uses the service account token as the authorizarion bearer token, and the
102-
server fetches the associated roles/groups/namespaces from the Kubernetes RBAC resources.
102+
server fetches the associated roles from the Kubernetes RBAC resources. Feast supports advanced authorization by extracting user groups and namespaces from Kubernetes tokens, enabling fine-grained access control beyond simple role matching. This is achieved by leveraging Kubernetes Token Access Review, which allows Feast to determine the groups and namespaces associated with a user or service account.
103103
104104
An example of Kubernetes RBAC authorization configuration is the following:
105105
{% hint style="info" %}
@@ -109,26 +109,12 @@ An example of Kubernetes RBAC authorization configuration is the following:
109109
project: my-project
110110
auth:
111111
type: kubernetes
112+
user_token: <user_token> #Optional, else service account token Or env var is used for getting the token
112113
...
113114
```
114115

115116
In case the client cannot run on the same cluster as the servers, the client token can be injected using the `LOCAL_K8S_TOKEN`
116117
environment variable on the client side. The value must refer to the token of a service account created on the servers cluster
117118
and linked to the desired RBAC roles/groups/namespaces.
118119

119-
#### Setting Up Kubernetes RBAC for Feast
120-
121-
To ensure the Kubernetes RBAC environment aligns with Feast's RBAC configuration, follow these guidelines:
122-
* The roles defined in Feast `Permission` instances must have corresponding Kubernetes RBAC `Role` names.
123-
* The Kubernetes RBAC `Role` must reside in the same namespace as the Feast service.
124-
* The client application can run in a different namespace, using its own dedicated `ServiceAccount`.
125-
* Finally, the `RoleBinding` that links the client `ServiceAccount` to the RBAC `Role` must be defined in the namespace of the Feast service.
126-
127-
#### Kubernetes RBAC Authorization with Groups and Namespaces
128-
129-
Feast supports advanced authorization by extracting user groups and namespaces from Kubernetes tokens, enabling fine-grained access control beyond simple role matching. This is achieved by leveraging Kubernetes Token Access Review, which allows Feast to determine the groups and namespaces associated with a user or service account.
130-
131-
More details can be found in [Groups and Namespaces based Auth](../../reference/auth/groups_namespaces_auth.md)
132-
133-
134-
If the above rules are satisfied, the Feast service must be granted permissions to fetch `RoleBinding` instances from the local namespace.
120+
More details can be found in [Setting up kubernetes doc](../../reference/auth/kubernetes_auth_setup.md)

docs/reference/auth/groups_namespaces_auth.md renamed to docs/reference/auth/kubernetes_auth_setup.md

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
1-
# Groups and Namespaces Authentication Support
1+
# Setting up the kubernetes Auth
22

3-
This document describes the enhanced authentication and authorization capabilities in Feast that support groups and namespaces extraction from Kubernetes tokens, extending the existing role-based access control (RBAC) system.
3+
This document describes the authentication and authorization capabilities in Feast that support groups, namespaces and roles extraction from Kubernetes tokens.
44

55
## Overview
66

7-
Feast now supports extracting user groups and namespaces of both Service Account and User from Kubernetes authentication tokens using Token Access Review, in addition to the existing role-based authentication. This allows for more granular access control based on:
7+
Feast supports extracting user groups, namespaces and roles of both Service Account and User from Kubernetes authentication tokens. This allows for more granular access control based on:
88

99
- **Groups**: User groups associated directly with User/SA and from associated namespace
1010
- **Namespaces**: Kubernetes namespaces associated with User/SA
11+
- **Roles**: Kubernetes roles associated with User/SA
1112

1213
## Key Features
1314

14-
### 1. Token Access Review Integration
15+
### Setting Up Kubernetes RBAC for Feast
1516

16-
The system now uses Kubernetes Token Access Review API to extract detailed user information from tokens, including:
17-
- User groups
18-
- Associated namespaces
19-
- User identity information
17+
#### Role based auth setup
2018

21-
### 2. Enhanced User Model
19+
To ensure the Kubernetes RBAC environment aligns with Feast's RBAC configuration, follow these guidelines:
20+
* The roles defined in Feast `Permission` instances must have corresponding Kubernetes RBAC `Role` names.
21+
* The Kubernetes RBAC `Role` must reside in the same namespace as the Feast service.
22+
* The client application can run in a different namespace, using its own dedicated `ServiceAccount`.
23+
* Finally, the `RoleBinding` that links the client `ServiceAccount` to the RBAC `Role` must be defined in the namespace of the Feast service.
2224

23-
The `User` class has been extended along with roles to include:
24-
- `groups`: List of user groups
25-
- `namespaces`: List of associated namespaces
25+
#### Group and Namespace based auth setup
2626

27-
### 3. New Policy Types
27+
To ensure the Kubernetes RBAC environment aligns with Feast's RBAC configuration, follow these guidelines:
28+
* The groups and namespaces defined in Feast `Permission` instances must have corresponding Kubernetes `Group` and `Namespace` names.
29+
* The user or service account must reside in the group or namespace defined in the Feast `Permission` instances.
30+
* The client application can run in a different namespace, using its own dedicated `ServiceAccount` or user.
31+
* Finally, the feast service grants access based on the group and namespace association defined in the Feast `Permission` instances.
2832

29-
Three new policy types have been introduced:
33+
## Policy Types
3034

31-
#### GroupBasedPolicy
35+
### RoleBasedPolicy
36+
Grants access based on user role membership.
37+
38+
```python
39+
from feast.permissions.policy import RoleBasedPolicy
40+
41+
policy = RoleBasedPolicy(roles=["data-team", "ml-engineers"])
42+
```
43+
44+
### GroupBasedPolicy
3245
Grants access based on user group membership.
3346

3447
```python
@@ -62,13 +75,12 @@ policy = CombinedGroupNamespacePolicy(
6275

6376
### Server Configuration
6477

65-
The server automatically extracts groups and namespaces when using Kubernetes authentication. No additional configuration is required beyond the existing Kubernetes auth setup.
78+
The server automatically extracts groups, namespaces and roles when using Kubernetes authentication. No additional configuration is required beyond the existing Kubernetes auth setup.
6679

6780
### Client Configuration
6881

6982
For external users (not service accounts), you can provide a user token in the configuration:
7083

71-
7284
Refer examples of providing the token are described in doc [User Token Provisioning](./user_token_provisioning.md)
7385

7486
## Usage Examples
@@ -80,11 +92,20 @@ from feast.feast_object import ALL_RESOURCE_TYPES
8092
from feast.permissions.action import READ, AuthzedAction, ALL_ACTIONS
8193
from feast.permissions.permission import Permission
8294
from feast.permissions.policy import (
95+
RoleBasedPolicy,
8396
GroupBasedPolicy,
8497
NamespaceBasedPolicy,
8598
CombinedGroupNamespacePolicy
8699
)
87100

101+
# Role-based permission
102+
role_perm = Permission(
103+
name="role_permission",
104+
types=ALL_RESOURCE_TYPES,
105+
policy=RoleBasedPolicy(roles=["reader-role"]),
106+
actions=[AuthzedAction.DESCRIBE] + READ
107+
)
108+
88109
# Group-based permission (new)
89110
data_team_perm = Permission(
90111
name="data_team_permission",
@@ -117,14 +138,6 @@ dev_staging_perm = Permission(
117138

118139
Run `feast apply` from CLI/API/SDK on server or from client(if permitted) to apply the permissions.
119140

120-
## Token Access Review Process
121-
122-
1. **Token Extraction**: The system extracts the authentication token from the request
123-
2. **Token Validation**: Uses Kubernetes Token Access Review API to validate the token
124-
3. **Information Extraction**: Extracts groups, namespaces, and user information
125-
4. **User Creation**: Creates a User object with roles, groups, and namespaces
126-
5. **Policy Evaluation**: Evaluates permissions against the user's attributes
127-
128141
## Troubleshooting
129142

130143
### Common Issues
@@ -139,7 +152,7 @@ Run `feast apply` from CLI/API/SDK on server or from client(if permitted) to app
139152
- Check that the user is properly configured in Kubernetes/ODH/RHOAI
140153

141154
3. **Permission Denied**
142-
- Verify the user is added to required groups/namespaces
155+
- Verify the user is added to required groups/namespaces Or has the required role assigned
143156
- Check that the policy is correctly configured
144157
- Review the permission evaluation logs
145158

@@ -167,6 +180,3 @@ Run `feast apply` from CLI/API/SDK on server or from client(if permitted) to app
167180
- [Permission Model](../concepts/permission.md)
168181
- [RBAC Architecture](../architecture/rbac.md)
169182
- [Kubernetes RBAC Authorization](./authz_manager.md#kubernetes-rbac-authorization)
170-
171-
172-

sdk/python/feast/permissions/auth/kubernetes_token_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _extract_groups_and_namespaces_from_token(
189189
groups.extend(namespace_groups)
190190
else:
191191
# Regular user logic - extract namespaces from dashboard-permissions RoleBindings
192-
user_namespaces = self._extract_user_data_science_projects(
192+
user_namespaces = self._extract_user_project_namespaces(
193193
username
194194
)
195195
namespaces.extend(user_namespaces)
@@ -269,7 +269,7 @@ def _extract_namespace_access_groups(self, namespace: str) -> list[str]:
269269

270270
return groups
271271

272-
def _extract_user_data_science_projects(self, username: str) -> list[str]:
272+
def _extract_user_project_namespaces(self, username: str) -> list[str]:
273273
"""
274274
Extract data science project namespaces where a user has been added via dashboard-permissions RoleBindings.
275275

0 commit comments

Comments
 (0)