当前位置:网站首页>安全保障基于软件全生命周期-Istio的授权机制
安全保障基于软件全生命周期-Istio的授权机制
2022-07-28 12:49:00 【taoli-qiao】
Istio 的授权功能为网格中的工作负载提供网格、命名空间和工作负载级别的访问控制。授权架构如下所示:

每个 Envoy 代理都运行一个授权引擎,该引擎在运行时授权请求。当请求到达代理时,授权引擎根据当前授权策略评估请求上下文,并返回授权结果 ALLOW 或 DENY。 运维人员使用 .yaml 文件指定 Istio 授权策略。需要注意:拒绝策略优先于允许策略。
授权策略配置规则如下所示:
要配置授权策略,请创建一个 AuthorizationPolicy 自定义资源。一个授权策略包括选择器(selector),动作(action) 和一个规则(rules)列表:
selector 字段指定策略的目标
action 字段指定允许还是拒绝请求
rules 指定何时触发动作
rules 下的 from 字段指定请求的来源
rules 下的 to 字段指定请求的操作
rules 下的 when 字段指定应用规则所需的条件
下面通过实际例子来看看AuthorizationPolicy的规则。这里要沿用上一篇博客在foo和bar namespace下面创建的httpbin和sleep服务。
案例一:允许所有请求的AuthorizationPolicy,spec中不配置任何规则,即允许所有请求。
kubectl apply -f - <<EOF
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: allow-nothing
namespace: foo
spec:
{}
EOF创建该AuthorizationPolicy后,从bar.sleep访问foo.httpbin和foo.sleep访问foo.httpbin都能成功
kubectl exec "$(kubectl get pod -l app=sleep -n bar -o jsonpath={.items..metadata.name})" -c sleep -n bar -- curl http://httpbin.foo:8000/headers
kubectl exec "$(kubectl get pod -l app=sleep -n foo -o jsonpath={.items..metadata.name})" -c sleep -n foo -- curl http://httpbin.foo:8000/headers

案例二:创建另外一个AuthorizationPolicy, 只控制了rule/to即允许访问foo namespace下的httpbin的GET请求。故创建下面的Policy后,通过上面的命令访问仍然能访问成功。
kubectl apply -f - <<EOF
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: "httpbin-viewer"
namespace: foo
spec:
selector:
matchLabels:
app: httpbin
action: ALLOW
rules:
- to:
- operation:
methods: ["GET"]
EOF案例三:接着再创建一个定义了From的AuthorizationPolicy,允许bar namespace下的sa=sleep的来源访问foo下面的httpbin的GET请求。
kubectl apply -f - <<EOF
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: "httpbin-viewer"
namespace: foo
spec:
selector:
matchLabels:
app: httpbin
action: ALLOW
rules:
- from:
- source:
principals: ["cluster.local/ns/bar/sa/sleep"]
to:
- operation:
methods: ["GET"]
EOF再次用上面的命令访问,可以看到如果用foo namespace下的sa访问提示access deny。

上面通过实际例子演示了如何通过配置AuthorizationPolicy来控制应用于应用间访问授权。更多AuthorizationPolicy的配置规则可查看官网信息。
边栏推荐
- JWT 登录认证 + Token 自动续期方案,写得太好了!
- 掌握常见的几种排序-选择排序
- 30 day question brushing plan (III)
- 对“Image Denoising Using an Improved Generative Adversarial Network with Wasserstein Distance“的理解
- How to play a data mining game entry Edition
- Cool operation preheating! Code to achieve small planet effect
- How to check if the interface cannot be adjusted? I didn't expect that the old bird of the 10-year test was planted on this interview question
- DXF读写:标注样式组码中文说明
- Generation of tables and contingency tables (cross tables) of R language factor data: use the summary function to analyze the list, view the chi square test results, and judge whether the two factor v
- R language Visual scatter diagram, geom using ggrep package_ text_ The repl function avoids overlapping labels between data points (add labels to specific areas of the visual image using the parameter
猜你喜欢

SQL每日一练(牛客新题库)——第4天:高级操作符

用非递归的方法实现二叉树中的层遍历,先序遍历,中序遍历和后序遍历

产品经理:岗位职责表

Intra prediction and transform kernel selection based on Neural Network

面经整理,助力秋招,祝你称为offer收割机

【ECMAScript6】Promise

Can second uncle cure young people's spiritual internal friction?

What is the reason why the words behind word disappear when typing? How to solve it?

严格模式——let和const——箭头函数——解构赋值——字符串模板symbol——Set和Map——生成器函数

30天刷题计划(四)
随机推荐
111. The sap ui5 fileuploader control realizes local file upload and encounters a cross domain access error when receiving the response from the server
C语言:随机生成数+归并排序
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的边框颜色
Half wave rectification light LED
DOJNOIP201708奶酪题解
用非递归的方法实现二叉树中的层遍历,先序遍历,中序遍历和后序遍历
C语言:归并排序
解决跨越的几种方案
Operator3-设计一个operator
Jenkins -- continuous integration server
vite在项目中配置路径别名
POJ1860货币兑换题解
P1797重型运输 题解
C language: random number + quick sort
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置draw_quantiles参数添加指定分位数横线(例如,50%分位数、中位数)
Remember to use pdfbox once to parse PDF and obtain the key data of PDF
leetcode(442)数组中重复的数据
Rust from introduction to mastery 01 introduction
Excellent performance! Oxford, Shanghai, AI Lab, Hong Kong University, Shangtang, and Tsinghua have joined forces to propose a language aware visual transformer for reference image segmentation! Open
Humiliation, resistance, reversal, 30 years, China should win Microsoft once