diff --git a/docs/source/distributions/configuration.md b/docs/source/distributions/configuration.md index 9548780c6..6362effe8 100644 --- a/docs/source/distributions/configuration.md +++ b/docs/source/distributions/configuration.md @@ -385,6 +385,125 @@ And must respond with: If no access attributes are returned, the token is used as a namespace. +### Access control + +When authentication is enabled, access to resources is controlled +through the `access_policy` attribute of the auth config section under +server. The value for this is a list of access rules. + +Each access rule defines a list of actions either to permit or to +forbid. It may specify a principal or a resource that must match for +the rule to take effect. + +Valid actions are create, read, update, and delete. The resource to +match should be specified in the form of a type qualified identifier, +e.g. model::my-model or vector_db::some-db, or a wildcard for all +resources of a type, e.g. model::*. If the principal or resource are +not specified, they will match all requests. + +The valid resource types are model, shield, vector_db, dataset, +scoring_function, benchmark, tool, tool_group and session. + +A rule may also specify a condition, either a 'when' or an 'unless', +with additional constraints as to where the rule applies. The +constraints supported at present are: + + - 'user with in ' + - 'user with not in ' + - 'user is owner' + - 'user is not owner' + - 'user in owners ' + - 'user not in owners ' + +The attributes defined for a user will depend on how the auth +configuration is defined. + +When checking whether a particular action is allowed by the current +user for a resource, all the defined rules are tested in order to find +a match. If a match is found, the request is permitted or forbidden +depending on the type of rule. If no match is found, the request is +denied. + +If no explicit rules are specified, a default policy is defined with +which all users can access all resources defined in config but +resources created dynamically can only be accessed by the user that +created them. + +Examples: + +The following restricts access to particular github users: + +```yaml +server: + auth: + provider_config: + type: "github_token" + github_api_base_url: "https://api.github.com" + access_policy: + - permit: + principal: user-1 + actions: [create, read, delete] + description: user-1 has full access to all resources + - permit: + principal: user-2 + actions: [read] + resource: model::model-1 + description: user-2 has read access to model-1 only +``` + +Similarly, the following restricts access to particular kubernetes +service accounts: + +```yaml +server: + auth: + provider_config: + type: "oauth2_token" + audience: https://kubernetes.default.svc.cluster.local + issuer: https://kubernetes.default.svc.cluster.local + tls_cafile: /home/gsim/.minikube/ca.crt + jwks: + uri: https://kubernetes.default.svc.cluster.local:8443/openid/v1/jwks + token: ${env.TOKEN} + access_policy: + - permit: + principal: system:serviceaccount:my-namespace:my-serviceaccount + actions: [create, read, delete] + description: specific serviceaccount has full access to all resources + - permit: + principal: system:serviceaccount:default:default + actions: [read] + resource: model::model-1 + description: default account has read access to model-1 only +``` + +The following policy, which assumes that users are defined with roles +and teams by whichever authentication system is in use, allows any +user with a valid token to use models, create resources other than +models, read and delete resources they created and read resources +created by users sharing a team with them: + +``` + access_policy: + - permit: + actions: [read] + resource: model::* + description: all users have read access to models + - forbid: + actions: [create, delete] + resource: model::* + unless: user with admin in roles + description: only user with admin role can create or delete models + - permit: + actions: [create, read, delete] + when: user is owner + description: users can create resources other than models and read and delete those they own + - permit: + actions: [read] + when: user in owner teams + description: any user has read access to any resource created by a user with the same team +``` + ### Quota Configuration The `quota` section allows you to enable server-side request throttling for both