-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 5 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| # Groups and Namespaces Authentication Support | ||
|
jyejare marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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. | ||
|
|
||
| ## Overview | ||
|
|
||
| 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: | ||
|
|
||
| - **Groups**: User groups associated directly with User/SA and from associated namespace | ||
| - **Namespaces**: Kubernetes namespaces associated with User/SA | ||
|
|
||
| ## Key Features | ||
|
|
||
| ### 1. Token Access Review Integration | ||
|
|
||
| The system now uses Kubernetes Token Access Review API to extract detailed user information from tokens, including: | ||
| - User groups | ||
| - Associated namespaces | ||
| - User identity information | ||
|
|
||
| ### 2. Enhanced User Model | ||
|
|
||
| The `User` class has been extended along with roles to include: | ||
| - `groups`: List of user groups | ||
| - `namespaces`: List of associated namespaces | ||
|
|
||
| ### 3. New Policy Types | ||
|
|
||
| Three new policy types have been introduced: | ||
|
|
||
| #### GroupBasedPolicy | ||
| Grants access based on user group membership. | ||
|
|
||
| ```python | ||
| from feast.permissions.policy import GroupBasedPolicy | ||
|
|
||
| policy = GroupBasedPolicy(groups=["data-team", "ml-engineers"]) | ||
| ``` | ||
|
|
||
| #### NamespaceBasedPolicy | ||
| Grants access based on user namespace association. | ||
|
|
||
| ```python | ||
| from feast.permissions.policy import NamespaceBasedPolicy | ||
|
|
||
| policy = NamespaceBasedPolicy(namespaces=["production", "staging"]) | ||
| ``` | ||
|
|
||
| #### CombinedGroupNamespacePolicy | ||
| Grants access only when user is added into either permitted groups AND namespaces. | ||
|
|
||
| ```python | ||
| from feast.permissions.policy import CombinedGroupNamespacePolicy | ||
|
|
||
| policy = CombinedGroupNamespacePolicy( | ||
| groups=["data-team"], | ||
| namespaces=["production"] | ||
| ) | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Server Configuration | ||
|
|
||
| The server automatically extracts groups and namespaces when using Kubernetes authentication. No additional configuration is required beyond the existing Kubernetes auth setup. | ||
|
|
||
| ### Client Configuration | ||
|
|
||
| For external users (not service accounts), you can provide a user token in the configuration: | ||
|
|
||
|
|
||
| Refer examples of providing the token are described in doc [User Token Provisioning](./user_token_provisioning.md) | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Basic Permission Setup | ||
|
|
||
| ```python | ||
| from feast.feast_object import ALL_RESOURCE_TYPES | ||
| from feast.permissions.action import READ, AuthzedAction, ALL_ACTIONS | ||
| from feast.permissions.permission import Permission | ||
| from feast.permissions.policy import ( | ||
| GroupBasedPolicy, | ||
| NamespaceBasedPolicy, | ||
| CombinedGroupNamespacePolicy | ||
| ) | ||
|
|
||
| # Group-based permission (new) | ||
| data_team_perm = Permission( | ||
| name="data_team_permission", | ||
| types=ALL_RESOURCE_TYPES, | ||
| policy=GroupBasedPolicy(groups=["data-team", "ml-engineers"]), | ||
| actions=[AuthzedAction.DESCRIBE] + READ | ||
| ) | ||
|
|
||
| # Namespace-based permission (new) | ||
| prod_perm = Permission( | ||
| name="production_permission", | ||
| types=ALL_RESOURCE_TYPES, | ||
| policy=NamespaceBasedPolicy(namespaces=["production"]), | ||
| actions=[AuthzedAction.DESCRIBE] + READ | ||
| ) | ||
|
|
||
| # Combined permission (new) | ||
| dev_staging_perm = Permission( | ||
| name="dev_staging_permission", | ||
| types=ALL_RESOURCE_TYPES, | ||
| policy=CombinedGroupNamespacePolicy( | ||
| groups=["dev-team"], | ||
| namespaces=["staging"] | ||
| ), | ||
| actions=ALL_ACTIONS | ||
| ) | ||
| ``` | ||
|
|
||
| ### Applying Permissions | ||
|
|
||
| Run `feast apply` from CLI/API/SDK on server or from client(if permitted) to apply the permissions. | ||
|
|
||
| ## Token Access Review Process | ||
|
|
||
| 1. **Token Extraction**: The system extracts the authentication token from the request | ||
| 2. **Token Validation**: Uses Kubernetes Token Access Review API to validate the token | ||
| 3. **Information Extraction**: Extracts groups, namespaces, and user information | ||
| 4. **User Creation**: Creates a User object with roles, groups, and namespaces | ||
| 5. **Policy Evaluation**: Evaluates permissions against the user's attributes | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common Issues | ||
|
|
||
| 1. **Token Access Review Fails** | ||
| - Check that the Feast server has the required RBAC permissions | ||
| - Verify the token is valid and not expired | ||
| - Check server logs for detailed error messages in debug mode | ||
|
|
||
| 2. **Groups/Namespaces Not Extracted** | ||
| - Verify the token contains the expected claims | ||
| - Check that the user is properly configured in Kubernetes/ODH/RHOAI | ||
|
|
||
| 3. **Permission Denied** | ||
| - Verify the user is added to required groups/namespaces | ||
| - Check that the policy is correctly configured | ||
| - Review the permission evaluation logs | ||
|
|
||
| ## Migration Guide | ||
|
|
||
| ### From Role-Based to Group/Namespace-Based | ||
|
|
||
| 1. **Identify User Groups**: Determine which groups your users belong to | ||
| 2. **Map Namespaces**: Identify which namespaces users should have access to | ||
| 3. **Create New Policies**: Define group-based and namespace-based policies | ||
| 4. **Test Gradually**: Start with read-only permissions and gradually expand | ||
| 5. **Monitor**: Watch logs to ensure proper authentication and authorization | ||
|
|
||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Principle of Least Privilege**: Grant only the minimum required permissions | ||
| 2. **Group Organization**: Organize users into logical groups based on their responsibilities | ||
| 3. **Namespace Isolation**: Use namespaces to isolate different environments or teams | ||
| 4. **Regular Audits**: Periodically review and audit permissions | ||
|
|
||
| ## Related Documentation | ||
|
|
||
| - [Authorization Manager](./authz_manager.md) | ||
| - [Permission Model](../concepts/permission.md) | ||
| - [RBAC Architecture](../architecture/rbac.md) | ||
| - [Kubernetes RBAC Authorization](./authz_manager.md#kubernetes-rbac-authorization) | ||
|
|
||
|
|
||
|
|
||
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.