Goals:
- Protect individual Feast instances like
FeatureView, OnDemandFeatureView, FeatureService(and others) - Decouple permission configuration from the instance definition
- Allow to plug-in custom authentication modules (Feast server use case)
Allow to protect the unauthorized use of the protected resources from the python SDK
The proposal assumes to use the RBAC security model to define Feast permissions.
Permissions are defined in the feature definition as instances of FeastPermission type. Each instance identifies:
- The permission name
- The protected resource, one of
Entity, DataSource, FeatureView, StreamFeatureView, OnDemandFeatureView, FeatureService, SavedDataset, ValidationReference- Optionally a subset of the target resources can be selected by applying a regex filter on the resource name or tags
- The permitted actions, one of
read, edit, query_offline, query_online, write_online and write_offline - The policies that must be satisfied to access or perform these actions on the protected resource
- The default policy validates the configured permission roles against the user/client roles
- The decision strategy to evaluate multiple policies, one of
unanimous, affirmative, consensus
Note we assume to model only the permissions to allow executions, not to deny them, at least as a first step.
The following example specifies that only users with risk_reader role can query from resources tagged with team: risk and
named like very_important_*:
risk_role = FeastPermission(
name="query_risk_stores",
resources=FeastResource(
type=AuthzedResource.ALL,
conditions=[
{
"name": "very_important_*", # Resource name must match the pattern AND
"team": "risk", # Resource must include this tag
}
],
),
actions=[AuthzedAction.QUERY],
policies=[RoleBasedPolicy(["risk_reader"])],
decision_strategy=DecisionStrategy.UNANIMOUS, # Could be omitted, it's the default value BTW
)Permission classes to be introduced:
# In alternative, consider using the FeastObjectType enum (ATM it misses some types and ALL)
class AuthzedResource(enum.Enum):
ALL = "all"
DATA_SOURCE = "data source"
ENTITY = "entity"
FEATURE_VIEW = "feature view"
ON_DEMAND_FEATURE_VIEW = "on demand feature view"
STREAM_FEATURE_VIEW = "stream feature view"
FEATURE_SERVICE = "feature service"
SAVED_DATASET = "saved dataset"
VALIDATION_REFERENCE = "validation reference"
class AuthzedAction(enum.Enum):
ALL = "all"
READ = "read"
EDIT = "edit" # CREATE + UPDATE + DELETE
QUERY = "query" # ONLINE + OFFLINE
QUERY_ONLINE = "query online"
QUERY_OFFLINE = "query offline"
WRITE = ("write",) # ONLINE + OFFLINE
WRITE_ONLINE = "write online"
WRITE_OFFLINE = "write offline"
class DecisionStrategy(enum.Enum):
# all policies must evaluate to a positive decision
UNANIMOUS = 1
# at least one policy must evaluate to a positive decision
AFFIRMATIVE = 2
# the no. of positive decisions must be greater than the no. of negative decisions
CONSENSUS = 3
class FeastResource:
def __init__(
self,
type: AuthzedResource,
# Optional filter to match only resources with a given name or tag
# ALL the conditions must match to select any resource of the given type
# Defaults to None, equivalent to not apply any additional filter
conditions: Optional[Dict[str, str]] = {},
# Note: here we could probably be more explicit with parameters:
# "name_patterns: Optional[List[str]] = []"
# "required_tags: Optional[Dict[str, str]] = {}"
):
pass
# We can instroduce the FeastPolicy interface whenever other classes are added to support custom policies
class RoleBasedPolicy:
def __init__(
self,
roles: List[StrictStr],
):
pass
def get_roles(self):
pass
class FeastPermission:
def __init__(
self,
name: StrictStr,
resources: Optional[List[FeastResource]] = [FeastResource(AuthzedResource.ALL)],
actions: Optional[List[AuthzedAction]] = [AuthzedAction.ALL],
policies: Optional[List[RoleBasedPolicy]] = [], # Equivalent to allow-all
decision_strategy: Optional[DecisionStrategy] = DecisionStrategy.UNANIMOUS,
):
passWe can add helpers to simplify the creation of permissions with pre-built defaults:
@classmethod
def with_permission_to_query_online(
cls,
name: StrictStr,
roles: List[StrictStr],
conditions: Dict[str, str],
decision_strategy: Optional[DecisionStrategy] = DecisionStrategy.AFFIRMATIVE,
):
return cls(
name=name,
resources=[
FeastResource(
type=AuthzedResource.ALL,
conditions=conditions,
)
],
actions=[AuthzedAction.QUERY_ONLINE],
policies=[RoleBasedPolicy(roles)],
decision_strategy=decision_strategy,
)FeatureView(tags={"team": "risk"})
FeatureService(tags={"team": "general_purpose"})
# Only users with 'restricted-team' role can read online store from resources with tag 'team: risk'
restricted_access_to_online_store = FeastPermission.with_permission_to_query_online(
name="restricted_access_to_online_store",
roles=["restricted-team"],
conditions={"team": "risk"},
)
# Users with 'general-team' role can read online store from any resources
general_access_to_online_stores = FeastPermission.with_permission_to_query_online(
name="general_access_to_online_stores",
roles=["general-team"],
)