Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Istio安全杂谈之二:服务间授权 #4

Open
acappella2017 opened this issue Aug 2, 2019 · 0 comments
Open

Istio安全杂谈之二:服务间授权 #4

acappella2017 opened this issue Aug 2, 2019 · 0 comments
Labels

Comments

@acappella2017
Copy link
Owner

在上一篇文章(Istio安全杂谈之二:服务间授权)中,我们通过Istio在服务之间开启了mTLS。通过mTLS保证了:

  • service之间的通信是加密的
  • service之间互相知道对方是谁(服务间认证)

那么,如何使用好不容易得来的身份信息实现服务之间的授权呢?Istio采用RBAC(基于角色的权限控制)的方式来实现授权。

首先,需要在Istio中定义角色。

角色(ServiceRole)包含一组访问服务的权限,比如:下面的配置文件定义了一个叫database-viewer的角色,这个角色被允许通过Get请求访问数据库service.

apiVersion: "rbac.istio.io/v1alpha1"
kind: ServiceRole
metadata:
  name: database-viewer
  namespace: istio-tls
spec:
  rules:
  - services: ["database.default.svc.cluster.local"]
    methods: ["GET"]

那么,如果有一个叫database-statistics的服务,它希望获得查看数据库的权限,怎样讲database-viewer这个角色分配给它呢?这就要用到角色绑定(ServiceRoleBinding)了。ServiceRoleBinding的目的是链接一个主体(Identity)和一组角色。

下文定义了一个叫binding-database-consumerServiceRoleBinding
注意user填的是cluster.local/ns/istio-tls/sa/database-statistics,也就是database-statistics这个服务的SPIFFE ID(服务的身份证号)。

apiVersion: "rbac.istio.io/v1alpha1"
kind: ServiceRoleBinding
metadata:
  name: binding-database-consumer
  namespace: istio-tls
spec:
  subjects:
  - user: "cluster.local/ns/istio-tls/sa/database-statistics"
  roleRef:
    kind: ServiceRole
    name: "database-viewer"

参考

  1. Istio concept:Policies and Security
  2. Istio Service Mesh: service to service communication
  3. 微服务安全沉思录之二:认证与鉴权
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant