This package defines user-facing authentication policy.
Jwt
JSON Web Token (JWT) token format for authentication as defined by
RFC 7519. See OAuth
2.0 and OIDC
1.0 for how this is used in the whole
authentication flow.
A JWT for all requests except request at path /health_check and path with
prefix /status/. This is useful to expose some paths for public access but
keep others JWT validated.
A JWT only for requests at path of prefix /status/ but except the path of
/status/version. This means for any request path with prefix /status/ except
/status/version will require a valid JWT to proceed.
URL of the provider’s public key set to validate signature of the
JWT. See OpenID Discovery.
Optional if the key set document can either (a) be retrieved from
OpenID
Discovery of
the issuer or (b) inferred from the email domain of the issuer (e.g. a
Google service account).
List of trigger rules to decide if this JWT should be used to validate the
request. The JWT validation happens if any one of the rules matched.
If the list is not empty and none of the rules matched, authentication will
skip the JWT validation.
Leave this empty to always trigger the JWT validation.
Jwt.TriggerRule
Trigger rule to match against a request. The trigger rule is satisfied if
and only if both rules, excludedpaths and includepaths are satisfied.
List of paths that the request must include. If the list is not empty, the
rule is satisfied if request path matches at least one of the path in the list.
If the list is empty, the rule is ignored, in other words the rule is always satisfied.
MutualTls
TLS authentication params.
Field
Type
Description
allowTls
bool
WILL BE DEPRECATED, if set, will translates to TLS_PERMISSIVE mode.
Set this flag to true to allow regular TLS (i.e without client x509
certificate). If request carries client certificate, identity will be
extracted and used (set to peer identity). Otherwise, peer identity will
be left unset.
When the flag is false (default), request must have client certificate.
Client cert must be presented, connection is in TLS.
PERMISSIVE
Connection can be either plaintext or TLS, and client cert can be omitted.
OriginAuthenticationMethod
OriginAuthenticationMethod defines authentication method/params for origin
authentication. Origin could be end-user, device, delegate service etc.
Currently, only JWT is supported for origin authentication.
PeerAuthenticationMethod defines one particular type of authentication, e.g
mutual TLS, JWT etc, (no authentication is one type by itself) that can
be used for peer authentication.
The type can be progammatically determine by checking the type of the
“params” field.
Policy defines what authentication methods can be accepted on workload(s),
and if authenticated, which method/certificate will set the request principal
(i.e request.auth.principal attribute).
Authentication policy is composed of 2-part authentication:
- peer: verify caller service credentials. This part will set source.user
(peer identity).
- origin: verify the origin credentials. This part will set request.auth.user
(origin identity), as well as other attributes like request.auth.presenter,
request.auth.audiences and raw claims. Note that the identity could be
end-user, service account, device etc.
Last but not least, the principal binding rule defines which identity (peer
or origin) should be used as principal. By default, it uses peer.
Examples:
Policy to enable mTLS for all services in namespace frod. The policy name must be
default, and it contains no rule for targets.
Policy to require mTLS for peer authentication, and JWT for origin authentication
for productpage:9000 except the path ‘/health_check’ . Principal is set from origin identity.
List of authentication methods that can be used for peer authentication.
They will be evaluated in order; the first validate one will be used to
set peer identity (source.user) and other peer attributes. If none of
these methods pass, request will be rejected with authentication failed error (401).
Leave the list empty if peer authentication is not required
peerIsOptional
bool
Set this flag to true to accept request (for peer authentication perspective),
even when none of the peer authentication methods defined above satisfied.
Typically, this is used to delay the rejection decision to next layer (e.g
authorization).
This flag is ignored if no authentication defined for peer (peers field is empty).
List of authentication methods that can be used for origin authentication.
Similar to peers, these will be evaluated in order; the first validate one
will be used to set origin identity and attributes (i.e request.auth.user,
request.auth.issuer etc). If none of these methods pass, request will be
rejected with authentication failed error (401).
A method may be skipped, depends on its trigger rule. If all of these methods
are skipped, origin authentication will be ignored, as if it is not defined.
Leave the list empty if origin authentication is not required.
originIsOptional
bool
Set this flag to true to accept request (for origin authentication perspective),
even when none of the origin authentication methods defined above satisfied.
Typically, this is used to delay the rejection decision to next layer (e.g
authorization).
This flag is ignored if no authentication defined for origin (origins field is empty).
Define whether peer or origin identity should be use for principal. Default
value is USE_PEER.
If peer (or origin) identity is not available, either because of peer/origin
authentication is not defined, or failed, principal will be left unset.
In other words, binding rule does not affect the decision to accept or
reject request.
PortSelector
PortSelector specifies the name or number of a port to be used for
matching targets for authentication policy. This is copied from
networking API to avoid dependency.
Field
Type
Description
number
uint32 (oneof)
Valid port number
name
string (oneof)
Port name
PrincipalBinding
Associates authentication with request principal.
Name
Description
USE_PEER
Principal will be set to the identity from peer authentication.
USE_ORIGIN
Principal will be set to the identity from origin authentication.
StringMatch
Describes how to match a given string. Match is case-sensitive.
Field
Type
Description
exact
string (oneof)
exact string match.
prefix
string (oneof)
prefix-based match.
suffix
string (oneof)
suffix-based match.
regex
string (oneof)
ECMAscript style regex-based match as defined by EDCA-262.
Example: “^/pets/(.*?)?”
TargetSelector
TargetSelector defines a matching rule to a workload. A workload is selected
if it is associated with the service name and service port(s) specified in the selector rule.
Field
Type
Description
name
string
REQUIRED. The name must be a short name from the service registry. The
fully qualified domain name will be resolved in a platform specific manner.
Specifies the ports. Note that this is the port(s) exposed by the service, not workload instance ports.
For example, if a service is defined as below, then 8000 should be used, not 9000.