istio.io/archive/v1.1/zh/blog/2018/istio-authorization/index.html

112 lines
35 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html><html lang=zh itemscope itemtype=https://schema.org/WebPage><head><meta charset=utf-8><meta http-equiv=x-ua-compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=theme-color content=#466BB0><meta name=title content="基于 Istio 的 Micro-Segmentation 授权"><meta name=description content="描述 Istio 的授权功能以及如何在各种用例中使用它。"><meta name=author content="Limin Wang"><meta name=keywords content=microservices,services,mesh,authorization,rbac,security><meta property=og:title content="基于 Istio 的 Micro-Segmentation 授权"><meta property=og:type content=website><meta property=og:description content="描述 Istio 的授权功能以及如何在各种用例中使用它。"><meta property=og:url content=/v1.1/zh/blog/2018/istio-authorization/><meta property=og:image content=/v1.1/img/istio-whitelogo-bluebackground-framed.svg><meta property=og:image:alt content="Istio Logo"><meta property=og:image:width content=112><meta property=og:image:height content=150><meta property=og:site_name content=Istio><meta name=twitter:card content=summary><meta name=twitter:site content=@IstioMesh><title>Istioldie 1.1 / 基于 Istio 的 Micro-Segmentation 授权</title><script async src="https://www.googletagmanager.com/gtag/js?id=UA-98480406-2"></script><script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}
gtag('js',new Date());gtag('config','UA-98480406-2');</script><link rel=alternate type=application/rss+xml title="Istio Blog" href=/v1.1/feed.xml><link rel="shortcut icon" href=/v1.1/favicons/favicon.ico><link rel=apple-touch-icon href=/v1.1/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/v1.1/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/v1.1/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/v1.1/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/v1.1/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/v1.1/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/v1.1/favicons/android-96x96.png sizes=96xW96><link rel=icon type=image/png href=/v1.1/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/v1.1/favicons/android-192x192.png sizes=192x192><link rel=manifest href=/v1.1/manifest.json><meta name=apple-mobile-web-app-title content=Istio><meta name=application-name content=Istio><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Work+Sans:400|Chivo:400|Work+Sans:500,300,600,300italic,400italic,500italic,600italic|Chivo:500,300,600,300italic,400italic,500italic,600italic"><link rel=stylesheet href=/v1.1/css/all.css></head><body class="language-unknown archive-site"><script src=/v1.1/js/themes_init.min.js></script><script>const branchName="release-1.1";const docTitle="基于 Istio 的 Micro-Segmentation 授权";const iconFile="\/v1.1/img/icons.svg";const buttonCopy='复制到剪切板';const buttonPrint='打印';const buttonDownload='下载';</script><script src="https://www.google.com/cse/brand?form=search-form" defer></script><script src=/v1.1/js/all.min.js data-manual defer></script><header><nav><a id=brand href=/v1.1/zh/><span class=logo><svg viewBox="0 0 300 300"><circle cx="150" cy="150" r="146" stroke-width="2" /><path d="M65 240H225L125 270z"/><path d="M65 230l60-10V110z"/><path d="M135 220l90 10L135 30z"/></svg></span><span class=name>Istioldie 1.1</span></a><div id=hamburger><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#hamburger"/></svg></div><div id=header-links><a title="了解如何部署、使用和运维 Istio。" href=/v1.1/zh/docs/>文档</a>
<span title="关于使用 Istio 的博客文章。">博客</span>
<a title="一堆帮助您部署、配置和使用 Istio 的资源。" href=/v1.1/zh/help/>帮助</a>
<a title=关于Istio的说明。 href=/v1.1/zh/about/>关于</a><div class=menu><button id=gearDropdownButton class=menu-trigger title=选项和设置 aria-label="Options and Settings" aria-controls=gearDropdownContent><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#gear"/></svg></button><div id=gearDropdownContent class=menu-content aria-labelledby=gearDropdownButton role=menu><a tabindex=-1 role=menuitem lang=en id=switch-lang-en>English</a>
<a tabindex=-1 role=menuitem lang=zh id=switch-lang-zh class=active>中文</a><div role=separator></div><a tabindex=-1 role=menuitem class=active id=light-theme-item>亮主题</a>
<a tabindex=-1 role=menuitem id=dark-theme-item>暗主题</a><div role=separator></div><a tabindex=-1 role=menuitem id=syntax-coloring-item>代码高亮</a><div role=separator></div><h6>本站的其它版本</h6><a tabindex=-1 role=menuitem onclick="navigateToUrlOrRoot('https://istio.io/blog\/2018\/istio-authorization\/');return false;">当前版本</a>
<a tabindex=-1 role=menuitem onclick="navigateToUrlOrRoot('https://preliminary.istio.io/blog\/2018\/istio-authorization\/');return false;">下个版本</a>
<a tabindex=-1 role=menuitem href=https://archive.istio.io>旧版本</a></div></div><button id=search-show title=搜索istio.io aria-label=Search><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#magnifier"/></svg></button></div><form id=search-form name=cse role=search><input type=hidden name=cx value=013699703217164175118:iwwf17ikgf4>
<input type=hidden name=ie value=utf-8>
<input type=hidden name=hl value=en>
<input type=hidden id=search-page-url value=/v1.1/search.html>
<input id=search-textbox class=form-control name=q type=search aria-label=搜索istio.io>
<button id=search-close title="Cancel search" type=reset aria-label="Cancel search"><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#cancel-x"/></svg></button></form></nav></header><main class=primary><div id=sidebar-container class="sidebar-container sidebar-offcanvas"><nav id=sidebar aria-label="Section Navigation"><div class=directory><div class=card><button class="header dynamic" id=card0 title="2019 年的博客文章。" aria-controls=card0-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#blog"/></svg>2019 年的博客文章</button><div class=body aria-labelledby=card0 role=region id=card0-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card0><li role=none><a role=treeitem title="Istio 1.0.8 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.0.8/>发布 Istio 1.0.8</a></li><li role=none><a role=treeitem title="学习延长 Istio 自签发根证书的有效期的方法。" href=/v1.1/zh/blog/2019/root-transition/>延长 Istio 自签发根证书的有效期</a></li><li role=none><a role=treeitem title="发布 Istio 1.1.8 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.8/>发布 Istio 1.1.8</a></li><li role=none><a role=treeitem title="应对 CVE-2019-12243 带来的安全威胁。" href=/v1.1/zh/blog/2019/cve-2019-12243/>安全更新 - CVE-2019-12243</a></li><li role=none><a role=treeitem title="Istio 1.0 即将宣告终结。" href=/v1.1/zh/blog/2019/announcing-1.0-eol/>Istio 1.0 将在 2019 年 6 月 19 日停止支持</a></li><li role=none><a role=treeitem title="发布 Istio 1.1.7 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.7/>发布 Istio 1.1.7</a></li><li role=none><a role=treeitem title="Istio 1.1.6 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.6/>发布 Istio 1.1.6</a></li><li role=none><a role=treeitem title="发布 Istio 1.1.5 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.5/>发布 Istio 1.1.5</a></li><li role=none><a role=treeitem title="发布 Istio 1.1.4 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.4/>发布 Istio 1.1.4</a></li><li role=none><a role=treeitem title="Istio 1.1.3。" href=/v1.1/zh/blog/2019/announcing-1.1.3/>安全更新:发布 Istio 1.1.3</a></li><li role=none><a role=treeitem title="Istio 1.0.7 的补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.0.7/>安全更新:发布 Istio 1.0.7</a></li><li role=none><a role=treeitem title="Istio 1.1.2 的补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.2/>安全更新:发布 Istio 1.1.2</a></li><li role=none><a role=treeitem title="发布 Istio 1.1.1 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.1.1/>发布 Istio 1.1.1</a></li><li role=none><a role=treeitem title="Istio 1.1 发布声明。" href=/v1.1/zh/blog/2019/announcing-1.1/>宣布 Istio 1.1 发布</a></li><li role=none><a role=treeitem title="Istio 1.1 性能概览." href=/v1.1/zh/blog/2019/istio1.1_perf/>面向性能而架构的 Istio 1.1</a></li><li role=none><a role=treeitem title="发布 Istio 1.0.6 补丁版本。" href=/v1.1/zh/blog/2019/announcing-1.0.6/>Istio 1.0.6 发布</a></li><li role=none><a role=treeitem title="在多集群服务网格环境中配置 Istio 的路由规则。" href=/v1.1/zh/blog/2019/multicluster-version-routing/>多集群服务网格中的分版本路由</a></li><li role=none><a role=treeitem title=宣布新的博客策略。 href=/v1.1/zh/blog/2019/sail-the-blog/>博客策略更新</a></li><li role=none><a role=treeitem title="评估加入 Egress gateway 对性能造成的影响。" href=/v1.1/zh/blog/2019/egress-performance/>Egress gateway 性能测试</a></li><li role=none><a role=treeitem title="Istio 将数据面组件注入到现存部署之中的过程。" href=/v1.1/zh/blog/2019/data-plane-setup/>Istio Sidecar 注入过程解密</a></li><li role=none><a role=treeitem title="使用 AppSwitch 解决应用程序启动顺序和启动延迟。" href=/v1.1/zh/blog/2019/appswitch/>使用 AppSwitch 进行 Sidestepping 依赖性排序</a></li><li role=none><a role=treeitem title="如何使用 cert-manager 手工部署一个自定义 Ingress 网关。" href=/v1.1/zh/blog/2019/custom-ingress-gateway/>使用 Cert-Manager 部署一个自定义 Ingress 网关</a></li><li role=none><a role=treeitem title="Istio 推出新的讨论板。" href=/v1.1/zh/blog/2019/announcing-discuss.istio.io/>宣布 discuss.istio.io</a></li></ul></div></div><div class=card><button class="header dynamic" id=card1 title="2017 年的博客文章。" aria-controls=card1-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#blog"/></svg>2017 年的博客文章</button><div class=body aria-labelledby=card1 role=region id=card1-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card1><li role=none><a role=treeitem title=提高可用,降低延迟。 href=/v1.1/zh/blog/2017/mixer-spof-myth/>Mixer 和 SPOF 神话</a></li><li role=none><a role=treeitem title="概要说明 Mixer 的插件架构。" href=/v1.1/zh/blog/2017/adapter-model/>Mixer 适配器模型</a></li><li role=none><a role=treeitem title="Istio 0.2 公告。" href=/v1.1/zh/blog/2017/0.2-announcement/>宣布 Istio 0.2</a></li><li role=none><a role=treeitem title="Istio 的策略如何关联 Kubernetes 的网络策略 。" href=/v1.1/zh/blog/2017/0.1-using-network-policy/>Istio 使用网络策略</a></li><li role=none><a role=treeitem title="使用 Istio 创建自动缩放的金丝雀部署。" href=/v1.1/zh/blog/2017/0.1-canary/>使用 Istio 进行金丝雀部署</a></li><li role=none><a role=treeitem title="Istio Auth 0.1 公告。" href=/v1.1/zh/blog/2017/0.1-auth/>使用 Istio 增强端到端安全</a></li><li role=none><a role=treeitem title="Istio 0.1 宣布。" href=/v1.1/zh/blog/2017/0.1-announcement/>初次了解 Istio</a></li></ul></div></div><div class=card><button class="header dynamic" id=card2 title="2018 年的博客文章。" aria-controls=card2-body><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#blog"/></svg>2018 年的博客文章</button><div class="body default" aria-labelledby=card2 role=region id=card2-body><ul role=tree aria-expanded=true class=leaf-section aria-labelledby=card2><li role=none><a role=treeitem title="发布 Istio 1.0.5 补丁版本。" href=/v1.1/zh/blog/2018/announcing-1.0.5/>Istio 1.0.5 发布</a></li><li role=none><a role=treeitem title="发布 Istio 1.0.4 补丁版本。" href=/v1.1/zh/blog/2018/announcing-1.0.4/>Istio 1.0.4 发布</a></li><li role=none><a role=treeitem title="如何在不部署 Sidecar 代理的情况下使用 Istio 进行流量管理。" href=/v1.1/zh/blog/2018/incremental-traffic-management/>增量式应用 Istio 第一部分,流量管理</a></li><li role=none><a role=treeitem title="描述了一个基于 Istio 的 Bookinfo 示例的简单场景。" href=/v1.1/zh/blog/2018/egress-mongo/>使用外部 MongoDB 服务</a></li><li role=none><a role=treeitem title="发布 Istio 1.0.3 补丁版本。" href=/v1.1/zh/blog/2018/announcing-1.0.3/>Istio 1.0.3 发布</a></li><li role=none><a role=treeitem title="发布 Istio 1.0.2 补丁版本." href=/v1.1/zh/blog/2018/announcing-1.0.2/>Istio 1.0.2 发布</a></li><li role=none><a role=treeitem title="发布 Istio 1.0.1 补丁版本。" href=/v1.1/zh/blog/2018/announcing-1.0.1/>Istio 1.0.1 发布</a></li><li role=none><a role=treeitem title="Istio 在 Twitch 举办了为期一天的直播庆祝 1.0 的发布。" href=/v1.1/zh/blog/2018/istio-twitch-stream/>Istio 在 Twitch 上全天直播</a></li><li role=none><a role=treeitem title="惠普如何在 Istio 上构建其下一代鞋类个性化平台。" href=/v1.1/zh/blog/2018/hp/>Istio 是惠普 FitStation 平台的改变者</a></li><li role=none><a role=treeitem title="Istio 1.0 已生产就绪。" href=/v1.1/zh/blog/2018/announcing-1.0/>宣布 Istio 1.0</a></li><li role=none><a role=treeitem title="使用 AppSwitch 自动接入应用并降低延迟。" href=/v1.1/zh/blog/2018/delayering-istio/>使用 AppSwitch 精简 Istio 层次</a></li><li role=none><span role=treeitem class=current title="描述 Istio 的授权功能以及如何在各种用例中使用它。">基于 Istio 的 Micro-Segmentation 授权</span></li><li role=none><a role=treeitem title="如何通过 Stackdriver 将 Istio 访问日志导出到 BigQuery、GCS、Pub/Sub 等不同的接收器。" href=/v1.1/zh/blog/2018/export-logs-through-stackdriver/>通过 Stackdriver 将日志导出到 BigQuery、GCS、Pub/Sub</a></li><li role=none><a role=treeitem title="描述如何配置 Istio 进行 HTTP Egress 流量监控和访问策略。" href=/v1.1/zh/blog/2018/egress-monitoring-access-control/>HTTP Egress 流量监控和访问策略</a></li><li role=none><a role=treeitem title="Istio v1alpha3 路由 API 介绍,动机及其设计原则。" href=/v1.1/zh/blog/2018/v1alpha3-routing/>Istio v1aplha3 路由 API 介绍</a></li><li role=none><a role=treeitem title="描述如何在AWS上使用网络负载均衡器配置 Istio Ingress。" href=/v1.1/zh/blog/2018/aws-nlb/>使用AWS NLB 配置 Istio Ingress</a></li><li role=none><a role=treeitem title="使用 Kubernetes 命名空间和 RBAC 为 Istio 构建软性多租户环境。" href=/v1.1/zh/blog/2018/soft-multitenancy/>Istio 的软性多租户支持</a></li><li role=none><a role=treeitem title=介绍更安全,低风险的部署和发布到生产。 href=/v1.1/zh/blog/2018/traffic-mirroring/>用于在生产环境进行测试的 Istio 流量镜像功能</a></li><li role=none><a role=treeitem title="描述基于 Istio 的 Bookinfo 示例的简单场景。" href=/v1.1/zh/blog/2018/egress-tcp/>使用外部 TCP 服务</a></li><li role=none><a role=treeitem title="描述基于 Istio Bookinfo 示例的简单场景。" href=/v1.1/zh/blog/2018/egress-https/>使用外部 Web 服务</a></li></ul></div></div></div></nav></div><div class=article-container><button tabindex=-1 id=sidebar-toggler title=折叠导航栏><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#pull"/></svg></button><nav aria-label=Breadcrumb><ol><li><a href=/v1.1/zh/>Istio</a></li><li><a href=/v1.1/zh/blog/ title="关于使用 Istio 的博客文章。">博客</a></li><li><a href=/v1.1/zh/blog/2018/ title="2018 年的博客文章。">2018 年的博客文章</a></li><li>基于 Istio 的 Micro-Segmentation 授权</li></ol></nav><article aria-labelledby=title><div class=title-area><div><h1 id=title>基于 Istio 的 Micro-Segmentation 授权</h1><p class=byline><span>作者</span>
<span class=attribution>Limin Wang</span><span> | </span><span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#calendar"/></svg><span>&nbsp;</span>2018年7月20日</span><span> | </span><span title="340 字"><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#clock"/></svg><span>&nbsp;</span>阅读大约需要 2 分钟</span></p></div></div><nav class=toc-inlined aria-label="Table of Contents"><div><hr><ol><li role=none aria-label=特点><a href=#%e7%89%b9%e7%82%b9>特点</a><ol><li role=none aria-label="RPC 级别授权"><a href=#rpc-%e7%ba%a7%e5%88%ab%e6%8e%88%e6%9d%83>RPC 级别授权</a><li role=none aria-label=具有条件的基于角色的访问控制><a href=#%e5%85%b7%e6%9c%89%e6%9d%a1%e4%bb%b6%e7%9a%84%e5%9f%ba%e4%ba%8e%e8%a7%92%e8%89%b2%e7%9a%84%e8%ae%bf%e9%97%ae%e6%8e%a7%e5%88%b6>具有条件的基于角色的访问控制</a><li role=none aria-label=高性能><a href=#%e9%ab%98%e6%80%a7%e8%83%bd>高性能</a><li role=none aria-label=使用/不使用主要标识><a href=#%e4%bd%bf%e7%94%a8-%e4%b8%8d%e4%bd%bf%e7%94%a8%e4%b8%bb%e8%a6%81%e6%a0%87%e8%af%86>使用/不使用主要标识</a></ol></li><li role=none aria-label=示例><a href=#%e7%a4%ba%e4%be%8b>示例</a><ol><li role=none aria-label="通过 RBAC &#43; 条件进行命名空间级别 segmentation"><a href=#%e9%80%9a%e8%bf%87-rbac-%e6%9d%a1%e4%bb%b6%e8%bf%9b%e8%a1%8c%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4%e7%ba%a7%e5%88%ab-segmentation>通过 RBAC + 条件进行命名空间级别 segmentation</a><li role=none aria-label=具有/不具有主要身份的服务/方法级别隔离><a href=#%e5%85%b7%e6%9c%89-%e4%b8%8d%e5%85%b7%e6%9c%89%e4%b8%bb%e8%a6%81%e8%ba%ab%e4%bb%bd%e7%9a%84%e6%9c%8d%e5%8a%a1-%e6%96%b9%e6%b3%95%e7%ba%a7%e5%88%ab%e9%9a%94%e7%a6%bb>具有/不具有主要身份的服务/方法级别隔离</a><ol><li role=none aria-label=使用经过身份验证的客户端身份><a href=#%e4%bd%bf%e7%94%a8%e7%bb%8f%e8%bf%87%e8%ba%ab%e4%bb%bd%e9%aa%8c%e8%af%81%e7%9a%84%e5%ae%a2%e6%88%b7%e7%ab%af%e8%ba%ab%e4%bb%bd>使用经过身份验证的客户端身份</a><li role=none aria-label=无身份客户><a href=#%e6%97%a0%e8%ba%ab%e4%bb%bd%e5%ae%a2%e6%88%b7>无身份客户</a></ol></li></ol></li><li role=none aria-label=概要><a href=#%e6%a6%82%e8%a6%81>概要</a><li role=none aria-label=相关内容><a href=#see-also>相关内容</a></li></ol><hr></div></nav><p>Micro-Segmentation 是一种安全技术,可在云部署中创建安全区域,并允许组织使用将工作负载彼此隔离并单独保护它们。
<a href=/v1.1/zh/docs/concepts/security/#授权>Istio 的授权功能</a>也称为 Istio 基于角色的访问控制,为 Istio 网格中的服务提供
Micro-Segmentation。它的特点是</p><ul><li>不同粒度级别的授权、包括命名空间级别、服务级别和方法级别。</li><li>服务间和最终用户到服务授权。</li><li>高性能,因为它在 Envoy 上本地执行。</li><li>基于角色的语义,使其易于使用。</li><li>灵活性高,因为它允许用户定义条件<a href=/v1.1/docs/reference/config/authorization/constraints-and-properties/>属性组合</a></li></ul><p>在这篇博客文章中,您将了解主要授权功能以及如何在不同情况下使用它们。</p><h2 id=特点>特点</h2><h3 id=rpc-级别授权>RPC 级别授权</h3><p>授权在各个 RPC 级别执行。具体来说,它控制“谁可以访问我的 <code>bookstore</code> 服务”,或者“谁可以在我的 <code>bookstore</code> 服务中访问
<code>getBook</code> 方法 ”。它不是为了控制对特定于应用程序的访问而设计的
资源实例,例如访问“存储桶 X ”或访问“第二层架上的第 3 本书”。今天这种应用特定的访问控制逻辑需要由应用程序本身处理。</p><h3 id=具有条件的基于角色的访问控制>具有条件的基于角色的访问控制</h3><p>授权是<a href=https://en.wikipedia.org/wiki/Role-based_access_control>基于角色的访问控制RBAC</a>系统,
将此与<a href=https://en.wikipedia.org/wiki/Attribute-based_access_control>基于属性的访问控制ABAC</a>对比系统。
与 ABAC 相比RBAC 具有以下优势:</p><ul><li><p><strong>角色允许对属性进行分组。</strong> 角色是权限组,用于指定允许的操作在系统上执行。用户根据组织内的角色进行分组。
您可以针对不同的情况定义角色并重用他们。</p></li><li><p><strong>关于谁有权访问,更容易理解和推理。</strong> RBAC 概念自然地映射到业务概念。例如,数据库管理员可能拥有对数据库后端服务的所有访问权限,
而 Web 客户端可能只能查看数据库后端服务前端服务。</p></li><li><p><strong>它减少了无意的错误。</strong> RBAC 策略使得复杂的安全更改变得更加容易。你不会有在多个位置重复配置,以后在需要进行更改时忘记更新其中一些配置。</p></li></ul><p>另一方面Istio 的授权系统不是传统的 RBAC 系统。它还允许用户使用定义<strong>条件</strong><a href=/v1.1/docs/reference/config/authorization/constraints-and-properties/>属性组合</a>。这给了 Istio 表达复杂的访问控制策略的灵活性。实际上,<strong>Istio 授权采用“RBAC + 条件”模型,具有 RBAC 系统的所有优点,并支持通常是 ABAC 系统提供的灵活性。</strong>你会在下面看到一些<a href=#示例>示例</a></p><h3 id=高性能>高性能</h3><p>由于其简单的语义, 在 Envoy 本地上执行 Istio 授权。在运行时,授权决策完全在 Envoy 过滤器内部完成,不依赖于任何外部模块。
这允许 Istio 授权实现高性能和可用性。</p><h3 id=使用-不使用主要标识>使用/不使用主要标识</h3><p>与任何其他 RBAC 系统一样Istio 授权具有身份识别功能。在 Istio 授权政策中,有一个主要的
身份称为 <code>user</code>,代表客户的主体。</p><p>除主要标识外,您还可以自己定义标识。例如,您可以将客户端标识指定为“用户 <code>Alice</code><code>Bookstore</code> 前端服务调用”,在这种情况下,
你有一个调用服务(<code>Bookstore frontend</code>)和最终用户(<code>Alice</code>)的组合身份。</p><p>要提高安全性,您应该启用<a href=/v1.1/zh/docs/concepts/security/#认证>认证功能</a>,并在授权策略中使用经过验证的身份。但是,
使用授权不强迫一定要有身份验证。Istio 授权可以使用或不使用身份。如果您正在使用遗留系统,您可能没有网格的双向 TLS 或 JWT 身份验证
设置。在这种情况下,识别客户端的唯一方法是,例如,通过 IP。您仍然可以使用 Istio 授权来控制允许哪些 IP 地址或 IP 范围访问您的服务。</p><h2 id=示例>示例</h2><p><a href=/v1.1/zh/docs/tasks/security/authz-http/>授权任务</a>向您展示如何操作使用 Istio 的授权功能来控制命名空间级别
和服务级别访问 <a href=/v1.1/zh/docs/examples/bookinfo/>Bookinfo 应用</a>。在本节中,您将看到有关如何实现的更多示例使用 Istio 授权进行
微分割。</p><h3 id=通过-rbac-条件进行命名空间级别-segmentation>通过 RBAC + 条件进行命名空间级别 segmentation</h3><p>假设你在 <code>frontend</code><code>backend</code> 命名空间中有服务。您想要允许所有服务在 <code>frontend</code> 命名空间中访问 <code>backend</code> 命名空间中标记
<code>external</code> 的所有服务。</p><pre><code class=language-yaml data-expandlinks=true>apiVersion: &#34;rbac.istio.io/v1alpha1&#34;
kind: ServiceRole
metadata:
name: external-api-caller
namespace: backend
spec:
rules:
- services: [&#34;*&#34;]
methods: [&#34;*”]
constraints:
- key: &#34;destination.labels[visibility]”
values: [&#34;external&#34;]
---
apiVersion: &#34;rbac.istio.io/v1alpha1&#34;
kind: ServiceRoleBinding
metadata:
name: external-api-caller
namespace: backend
spec:
subjects:
- properties:
source.namespace: &#34;frontend”
roleRef:
kind: ServiceRole
name: &#34;external-api-caller&#34;
</code></pre><p>上面的 <code>ServiceRole</code><code>ServiceRoleBinding</code> 表示“允许<em></em> 在 *条件*下执行<em>什么</em>
RBAC +条件)。特别:</p><ul><li><strong>“谁”</strong><code>frontend</code> 命名空间中的服务。</li><li><strong>“什么”</strong> 是在 <code>backend</code> 命名空间中调用服务。</li><li><strong>“条件”</strong> 是具有值 <code>external</code> 的目标服务的 <code>visibility</code> 标签。</li></ul><h3 id=具有-不具有主要身份的服务-方法级别隔离>具有/不具有主要身份的服务/方法级别隔离</h3><p>这是演示另一个服务/方法级别的细粒度访问控制的示例。第一步是定义一个 <code>book-reader</code> <code>ServiceRole</code>,它允许对 <code>bookstore</code> 服务中的 <code>/books/*</code> 资源进行 READ 访问。</p><pre><code class=language-yaml data-expandlinks=true>apiVersion: &#34;rbac.istio.io/v1alpha1&#34;
kind: ServiceRole
metadata:
name: book-reader
namespace: default
spec:
rules:
- services: [&#34;bookstore.default.svc.cluster.local&#34;]
paths: [&#34;/books/*”]
methods: [&#34;GET”]
</code></pre><h4 id=使用经过身份验证的客户端身份>使用经过身份验证的客户端身份</h4><p>假设你想把这个 <code>book-reader</code> 角色授予你的 <code>bookstore-frontend</code> 服务。如果您已启用
您的网格的<a href=/v1.1/zh/docs/concepts/security/#双向-tls-认证>双向 TLS 身份验证</a>,您可以使用服务帐户,以识别您的 <code>bookstore-frontend</code> 服务。授予 <code>book-reader</code> 角色到 <code>bookstore-frontend</code> 服务可以通过创建一个 <code>ServiceRoleBinding</code> 来完成,如下所示:</p><pre><code class=language-yaml data-expandlinks=true>apiVersion: &#34;rbac.istio.io/v1alpha1&#34;
kind: ServiceRoleBinding
metadata:
name: book-reader
namespace: default
spec:
subjects:
- user: &#34;cluster.local/ns/default/sa/bookstore-frontend”
roleRef:
kind: ServiceRole
name: &#34;book-reader&#34;
</code></pre><p>您可能希望通过添加“仅属于 <code>qualified-reviewer</code> 组的用户的条件来进一步限制此操作允许阅读书籍“。<code>qualified-reviewer</code> 组是经过身份验证的最终用户身份 <a href=/v1.1/zh/docs/concepts/security/#认证>JWT 身份验证</a>。在这种情况下,客户端服务标识的组合(<code>bookstore-frontend</code>)和最终用户身份(<code>qualified-reviewer</code>)在授权策略中使用。</p><pre><code class=language-yaml data-expandlinks=true>apiVersion: &#34;rbac.istio.io/v1alpha1&#34;
kind: ServiceRoleBinding
metadata:
name: book-reader
namespace: default
spec:
subjects:
- user: &#34;cluster.local/ns/default/sa/bookstore-frontend”
properties:
request.auth.claims[group]: &#34;qualified-reviewer”
roleRef:
kind: ServiceRole
name: &#34;book-reader&#34;
</code></pre><h4 id=无身份客户>无身份客户</h4><p>强烈建议在授权策略中使用经过身份验证的身份以确保安全性。但是,如果你有一个如果遗留系统不支持身份验证,您可能没有经过身份验证的身份验证。即使没有经过身份验证的身份,您仍然可以使用 Istio 授权来保护您的服务。以下示例表明您可以在授权策略中指定允许的源 IP 范围。</p><pre><code class=language-yaml data-expandlinks=true>apiVersion: &#34;rbac.istio.io/v1alpha1&#34;
kind: ServiceRoleBinding
metadata:
name: book-reader
namespace: default
spec:
subjects:
- properties:
source.ip: 10.20.0.0/9
roleRef:
kind: ServiceRole
name: &#34;book-reader&#34;
</code></pre><h2 id=概要>概要</h2><p>Istio 在命名空间级别,服务级别和方法级别粒度上提供授权功能。它采用“ RBAC + 条件”模型,使其成为易于使用和理解的 RBAC 系统,同时提供 ABAC 系统级别的灵活性。在 Envoy 本地上会执行 Istio 授权。虽然它通过与一起提供最好的安全性 <a href=/v1.1/zh/docs/concepts/security/#认证>Istio 认证功能</a>,也可以使用 Istio 授权为没有身份验证的旧系统提供访问控制。</p><nav id=see-also><h2>相关内容</h2><div class=see-also><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/docs/tasks/security/authz-http/>HTTP 服务的访问控制</a></p><p class=desc>展示为 HTTP 服务设置基于角色的访问控制方法。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/docs/tasks/security/authz-tcp/>TCP 服务的访问控制</a></p><p class=desc>展示如何为 TCP 服务设置基于角色的访问控制。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/docs/concepts/security/>安全</a></p><p class=desc>描述 Istio 的授权与鉴权功能。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/help/ops/security/debugging-authorization/>调试授权</a></p><p class=desc>展示授权功能的调试过程。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/docs/tasks/security/authz-permissive/>鉴权过程中的宽容模式</a></p><p class=desc>展示宽容模式的的鉴权过程。</p></div><div class=entry><p class=link><a data-skipendnotes=true href=/v1.1/zh/docs/tasks/security/rbac-groups/>基于组和列表类型声明的授权</a></p><p class=desc>有关如何在 Istio 中配置基于组的授权和配置列表类型声明的授权的教程。</p></div></div></nav></article><nav class=pagenav><div class=left><a title="使用 AppSwitch 自动接入应用并降低延迟。" href=/v1.1/zh/blog/2018/delayering-istio/><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#left-arrow"/></svg>使用 AppSwitch 精简 Istio 层次</a></div><div class=right><a title="如何通过 Stackdriver 将 Istio 访问日志导出到 BigQuery、GCS、Pub/Sub 等不同的接收器。" href=/v1.1/zh/blog/2018/export-logs-through-stackdriver/>通过 Stackdriver 将日志导出到 BigQuery、GCS、Pub/Sub<svg class="icon"><use xlink:href="/v1.1/img/icons.svg#right-arrow"/></svg></a></div></nav><div id=endnotes-container aria-hidden=true><h2>链接</h2><ol id=endnotes></ol></div></div><div class=toc-container><nav class=toc aria-label="Table of Contents"><div id=toc><ol><li role=none aria-label=特点><a href=#%e7%89%b9%e7%82%b9>特点</a><ol><li role=none aria-label="RPC 级别授权"><a href=#rpc-%e7%ba%a7%e5%88%ab%e6%8e%88%e6%9d%83>RPC 级别授权</a><li role=none aria-label=具有条件的基于角色的访问控制><a href=#%e5%85%b7%e6%9c%89%e6%9d%a1%e4%bb%b6%e7%9a%84%e5%9f%ba%e4%ba%8e%e8%a7%92%e8%89%b2%e7%9a%84%e8%ae%bf%e9%97%ae%e6%8e%a7%e5%88%b6>具有条件的基于角色的访问控制</a><li role=none aria-label=高性能><a href=#%e9%ab%98%e6%80%a7%e8%83%bd>高性能</a><li role=none aria-label=使用/不使用主要标识><a href=#%e4%bd%bf%e7%94%a8-%e4%b8%8d%e4%bd%bf%e7%94%a8%e4%b8%bb%e8%a6%81%e6%a0%87%e8%af%86>使用/不使用主要标识</a></ol></li><li role=none aria-label=示例><a href=#%e7%a4%ba%e4%be%8b>示例</a><ol><li role=none aria-label="通过 RBAC &#43; 条件进行命名空间级别 segmentation"><a href=#%e9%80%9a%e8%bf%87-rbac-%e6%9d%a1%e4%bb%b6%e8%bf%9b%e8%a1%8c%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4%e7%ba%a7%e5%88%ab-segmentation>通过 RBAC + 条件进行命名空间级别 segmentation</a><li role=none aria-label=具有/不具有主要身份的服务/方法级别隔离><a href=#%e5%85%b7%e6%9c%89-%e4%b8%8d%e5%85%b7%e6%9c%89%e4%b8%bb%e8%a6%81%e8%ba%ab%e4%bb%bd%e7%9a%84%e6%9c%8d%e5%8a%a1-%e6%96%b9%e6%b3%95%e7%ba%a7%e5%88%ab%e9%9a%94%e7%a6%bb>具有/不具有主要身份的服务/方法级别隔离</a><ol><li role=none aria-label=使用经过身份验证的客户端身份><a href=#%e4%bd%bf%e7%94%a8%e7%bb%8f%e8%bf%87%e8%ba%ab%e4%bb%bd%e9%aa%8c%e8%af%81%e7%9a%84%e5%ae%a2%e6%88%b7%e7%ab%af%e8%ba%ab%e4%bb%bd>使用经过身份验证的客户端身份</a><li role=none aria-label=无身份客户><a href=#%e6%97%a0%e8%ba%ab%e4%bb%bd%e5%ae%a2%e6%88%b7>无身份客户</a></ol></li></ol></li><li role=none aria-label=概要><a href=#%e6%a6%82%e8%a6%81>概要</a><li role=none aria-label=相关内容><a href=#see-also>相关内容</a></li></ol></div></nav></div></main><footer><div class=user-links><a class=channel title="Go download Istio 1.1.9 now" href=https://github.com/istio/istio/releases/tag/1.1.9 aria-label="Download Istio"><span>download</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#download"/></svg>
</a><a class=channel title="加入 Istio discussion board 参与讨论获取帮助" href=https://discuss.istio.io aria-label="Istio discussion board"><span>discuss</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#discourse"/></svg></a>
<a class=channel title="Stack Overflow 中列举了针对实际问题以及部署、配置和使用 Istio 的各项回答" href=https://stackoverflow.com/questions/tagged/istio aria-label="Stack Overflow"><span>stack overflow</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#stackoverflow"/></svg></a>
<a class=channel title="关注我们的 Twitter 来获取最新信息" href=https://twitter.com/IstioMesh aria-label=Twitter><span>twitter</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#twitter"/></svg></a><div class=tag>对于用户</div></div><div class=info><p class=copyright>中文内容由 ServiceMesher 社区维护,部分文档可能稍微滞后于英文版本,同步工作持续进行中<br>Istio 归档
1.1.9<br>&copy; 2019 Istio Authors, <a href=https://policies.google.com/privacy>隐私政策</a><br>归档于 2019年6月18日</p></div><div class=dev-links><a class=channel title="Istio 的代码在 GitHub 上开发" href=https://github.com/istio/community aria-label=GitHub><span>github</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#github"/></svg></a>
<a class=channel title="在 Slack 上与 Istio 社区交互讨论开发问题(仅限邀请)" href=https://istio.slack.com aria-label=slack><span>slack</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#slack"/></svg></a>
<a class=channel title="如果您想深入了解 Istio 的技术细节,请查看我们日益完善的设计文档" href=https://groups.google.com/forum/#!forum/istio-team-drive-access aria-label="team drive"><span>drive</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#drive"/></svg></a>
<a class=channel title="如果您想为 Istio 项目做出贡献,请考虑加入我们的工作组" href=https://github.com/istio/community/blob/master/WORKING-GROUPS.md aria-label="working groups"><span>working groups</span><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#working-groups"/></svg></a><div class=tag>对于开发者</div></div></footer><div id=scroll-to-top-container aria-hidden=true><button id=scroll-to-top title=回到顶部><svg class="icon"><use xlink:href="/v1.1/img/icons.svg#top"/></svg></button></div></body></html>