-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Groups and Namespaces based authorization, for Users and Service Accounts #5619
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
Merged
franciscojavierarceo
merged 7 commits into
feast-dev:master
from
jyejare:groups_nss_roles
Oct 10, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
64ab0c5
Groups and Namespaces authorization
jyejare 12e2587
Role binding for token access review and groups identifications from …
jyejare 940183a
Fixing unit tests
jyejare 83c94e5
TLS Path automatic setup
jyejare 65ca1b1
Documentation added along with some Makefile additions
jyejare fa12ca7
Review comments addressed
jyejare b16fd86
Merge branch 'master' into groups_nss_roles
franciscojavierarceo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
docs/changelogs/Groups_Namespaces_Auth_implmentation_summary.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Groups and Namespaces Based Authorization Implementation Summary | ||
|
||
## Overview | ||
This document summarizes the implementation of groups and namespaces extraction support in Feast for user authentication in Pull Request https://github.com/feast-dev/feast/pull/5619. | ||
|
||
## Changes Made | ||
|
||
### 1. Enhanced User Model (`sdk/python/feast/permissions/user.py`) | ||
- **Extended User class** to include `groups` and `namespaces` attributes | ||
- **Added methods**: | ||
- `has_matching_group()`: Check if user has required groups | ||
- `has_matching_namespace()`: Check if user has required namespaces | ||
- **Maintained backward compatibility** with existing role-based functionality | ||
|
||
### 2. New Policy Types (`sdk/python/feast/permissions/policy.py`) | ||
- **GroupBasedPolicy**: Grants access based on user group membership | ||
- **NamespaceBasedPolicy**: Grants access based on user namespace association | ||
- **CombinedGroupNamespacePolicy**: Requires both group OR namespace match | ||
- **Updated Policy.from_proto()** to handle new policy types | ||
- **Maintained backward compatibility** with existing RoleBasedPolicy | ||
|
||
### 3. Protobuf Definitions (`protos/feast/core/Policy.proto`) | ||
- **Added GroupBasedPolicy message** with groups field | ||
- **Added NamespaceBasedPolicy message** with namespaces field | ||
- **Extended Policy message** to include new policy types in oneof | ||
- **[Love] Regenerated Python protobuf files** using `make compile-protos-python` | ||
|
||
### 4. Token Access Review Integration (`sdk/python/feast/permissions/auth/kubernetes_token_parser.py`) | ||
- **Added AuthenticationV1Api client** for Token Access Review | ||
- **Implemented `_extract_groups_and_namespaces_from_token()`**: | ||
- Uses Kubernetes Token Access Review API | ||
- Extracts groups and namespaces from token response | ||
- Handles both service accounts and regular users | ||
- **Updated `user_details_from_access_token()`** to include groups and namespaces | ||
|
||
### 5. Client SDK Updates (`sdk/python/feast/permissions/client/kubernetes_auth_client_manager.py`) | ||
- **Extended KubernetesAuthConfig** to support user tokens | ||
- **Updated `get_token()` method** to check for user_token in config | ||
- **Maintained backward compatibility** with service account tokens | ||
|
||
### 6. Configuration Model (`sdk/python/feast/permissions/auth_model.py`) | ||
- **Added user_token field** to KubernetesAuthConfig for external users | ||
- **Maintained backward compatibility** with existing configurations | ||
|
||
### 7. Comprehensive Tests (`sdk/python/tests/permissions/test_groups_namespaces_auth.py`) | ||
- **15 test cases** covering all new functionality | ||
- **Tests for**: | ||
- User creation with groups/namespaces | ||
- Group matching functionality | ||
- Namespace matching functionality | ||
- All new policy types | ||
- Backward compatibility | ||
|
||
### 8. Documentation (`docs/getting-started/components/groups_namespaces_auth.md`) | ||
- **Usage examples** and configuration guides | ||
- **Security considerations** and best practices | ||
- **Troubleshooting guide** and migration instructions | ||
|
||
|
||
## Key Features Implemented | ||
|
||
### ✅ Token Access Review Integration | ||
- Uses Kubernetes Token Access Review API to extract user details | ||
- Handles both service accounts and external users | ||
|
||
### ✅ Groups and Namespaces Extraction | ||
- Extracts groups and namespaces from token response | ||
- Supports both service account and regular user tokens | ||
|
||
### ✅ New Policy Types | ||
- **GroupBasedPolicy**: Access based on group membership | ||
- **NamespaceBasedPolicy**: Access based on namespace association | ||
- **CombinedGroupNamespacePolicy**: Requires either group OR namespace | ||
|
||
### ✅ Client SDK Support | ||
- Extended to support user tokens for external users | ||
- Maintains backward compatibility with service account tokens | ||
- New parameter in KubernetesAuthConfig for user tokens | ||
|
||
|
||
## Usage Examples | ||
|
||
### Basic Group-Based Permission | ||
```python | ||
from feast.permissions.policy import GroupBasedPolicy | ||
from feast.permissions.permission import Permission | ||
|
||
policy = GroupBasedPolicy(groups=["data-team", "ml-engineers"]) | ||
permission = Permission( | ||
name="data_team_access", | ||
types=ALL_RESOURCE_TYPES, | ||
policy=policy, | ||
actions=[AuthzedAction.DESCRIBE] + READ | ||
) | ||
``` | ||
|
||
### Basic Namespace-Based Permission | ||
```python | ||
from feast.permissions.policy import NamespaceBasedPolicy | ||
from feast.permissions.permission import Permission | ||
|
||
policy = NamespaceBasedPolicy(namespaces=["de-dsp", "ml-dsp"]) | ||
permission = Permission( | ||
name="data_team_access", | ||
types=ALL_RESOURCE_TYPES, | ||
policy=policy, | ||
actions=[AuthzedAction.DESCRIBE] + READ | ||
) | ||
``` | ||
|
||
### Combined Group + Namespace Permission | ||
```python | ||
from feast.permissions.policy import CombinedGroupNamespacePolicy | ||
|
||
policy = CombinedGroupNamespacePolicy( | ||
groups=["data-team"], | ||
namespaces=["production"] | ||
) | ||
``` | ||
|
||
### Client Configuration with User Token | ||
```python | ||
from feast.permissions.auth_model import KubernetesAuthConfig | ||
|
||
auth_config = KubernetesAuthConfig( | ||
type="kubernetes", | ||
user_token="your-kubernetes-user-token" # For external users | ||
) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.