Authorization Policy

    For example, the following authorization policy applies to workloads matched with label selector “app: httpbin, version: v1”.

    It allows requests from: - service account “cluster.local/ns/default/sa/sleep” or - namespace “test” to access the workload with: - “GET” method at paths of prefix “/info” or, - “POST” method at path “/data”. when the request has a valid JWT token issued by “https://accounts.google.com”.

    Any other requests will be rejected.

    Access control is enabled on a workload if there is any authorization policies selecting the workload. When access control is enabled, the default behavior is deny (deny-by-default) which means requests to the workload will be rejected if the request is not allowed by any of the authorization policies selecting the workload.

    Currently AuthorizationPolicy only supports “ALLOW” action. This means that if multiple authorization policies apply to the same workload, the effect is additive.

    Authorization Policy scope (target) is determined by “metadata/namespace” and an optional “selector”. - “metadata/namespace” tells which namespace the policy applies. If set to root namespace, the policy applies to all namespaces in a mesh. - workload “selector” can be used to further restrict where a policy applies.

    For example,

    The following authorization policy applies to workloads containing label “app: httpbin” in namespace bar.

    1. kind: AuthorizationPolicy
    2. metadata:
    3. namespace: bar
    4. spec:
    5. selector:
    6. matchLabels:
    7. app: httpbin

    The following authorization policy applies to all workloads in namespace foo.

    The following authorization policy applies to workloads containing label “version: v1” in all namespaces in the mesh. (Assuming the root namespace is configured to “istio-config”).

    1. apiVersion: security.istio.io/v1beta1
    2. kind: AuthorizationPolicy
    3. metadata:
    4. name: policy
    5. namespace: istio-config
    6. selector:
    7. matchLabels:
    8. version: v1

    AuthorizationPolicy enables access control on workloads.

    For example, the following authorization policy denies all requests to workloads in namespace foo.

    The following authorization policy allows all requests to workloads in namespace foo.

    1. apiVersion: security.istio.io/v1beta1
    2. kind: AuthorizationPolicy
    3. name: allow-all
    4. namespace: foo
    5. spec:
    6. rules:

    Condition

    Condition specifies additional required attributes.

    FieldTypeDescriptionRequired
    keystring

    The name of an Istio attribute. See the full list of supported attributes.

    Yes
    valuesstring[]

    The allowed values for the attribute.

    Yes

    Operation specifies the operations of a request.

    Rule

    Rule allows access from a list of sources to perform a list of operations when the condition is matched.

    Any string field in the rule supports Exact, Prefix, Suffix and Presence match: - Exact match: “abc” will match on value “abc”. - Prefix match: “abc” will match on value “abc” and “abcd”. - Suffix match: “abc” will match on value “abc” and “xabc”. - Presence match: “*” will match when value is not empty.

    FieldTypeDescriptionRequired
    fromFrom[]

    Optional. from specifies the source of a request.

    No
    to

    Optional. to specifies the operation of a request.

    If not set, any operation is allowed.

    No
    whenCondition[]

    Optional. when specifies a list of additional conditions of a request.

    If not set, any condition is allowed.

    No

    From includes a list or sources.

    Rule.To

    To includes a list or operations.

    FieldTypeDescriptionRequired
    operationOperation

    Operation specifies the operation of a request.

    No

    Source specifies the source identities of a request.