赞
踩
Istio通过客户端和服务器端Policy Enforcement Points(PEPS)建立服务到服务的通信通道,PEPS在istio架构中的实现是envoy。
Peer authentication:
istio提供双向TLS作为传输认证的全栈解决方案,无需更改服务代码就可以启用它。这个解决方案为:
Request authentication
当一个工作负载使用双向TLS认证向另一个工作负载发送请求时,该请求的处理方式如下:
允许服务同时接受纯文本流量和双向TLS流量,这个功能极大地提升了双向TLS的入门体验。
服务器身份被编码在证书里,但服务名称通过服务发现或DNS被检索,安全命名信息将服务器身份映射到服务名称,身份a到服务名称b的映射表示“授权a运行服务b”。
认证策略是对服务收到的请求生效的;
要在双向TLS中指定客户端认证策略,需要在DetinationRule中设置TLSSetting.
自定义双向认证
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: db-mtls
spec:
host: mydbserver.prod.svc.cluster.local
trafficPolicy:
tls:
mode: MUTUAL
clientCertificate: /etc/certs/clientcert.pem
privateKey: /etc/certs/private.pem
caCertificates: /etc/certs/cacerts.pem
单向认证,不去校验客户端
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: tls-foo
spec:
host: "*.foo.com"
trafficPolicy:
tls:
mode: SIMPLE
使用默认istio双向认证
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: ratings-istio-mtls
spec:
host: ratings.prod.svc.cluster.local
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
严格tls认证,不支持明文
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: "default"
namespace: "istio-system"
spec:
mtls:
mode: STRICT
标签app=httpbin不开启认证
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: "overwrite-example"
namespace: "foo"
spec:
selector:
matchLabels:
app: httpbin
mtls:
mode: DISABLE
RequestAuthentication认证策略指定验证JSON Web Token(JWT)所需的值。这些值包括:
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: "jwt-example"
namespace: istio-system
spec:
selector:
matchLabels:
istio: ingressgateway
jwtRules:
- issuer: "testing@secure.istio.io"
jwksUri: "https://raw.githubusercontent.com/istio/istio/release-1.12/security/tools/jwt/samples/jwks.json"
拒绝没有token的请求
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: "frontend-ingress"
namespace: istio-system
spec:
selector:
matchLabels:
istio: ingressgateway
action: DENY
rules:
- from:
- source:
notRequestPrincipals: ["*"]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。