Gatekeeper Pattern 把关(守门人)模式
Protect applications and services by using a dedicated host instance that acts as a broker between clients and the application or service, validates and sanitizes requests, and passes requests and data between them. This can provide an additional layer of security, and limit the attack surface of the system.
采用专用的主机实例,作为客户和应用程序或服务之间的代理保护的应用程序和服务,验证和清理的要求,并通过它们之间的请求数据。这种模式可以提供一个额外的安全层,并限制了对系统的攻击。
Context and Problem 情境和问题
Applications expose their functionality to clients by accepting and processing requests. In cloud-hosted scenarios, applications expose endpoints to which clients connect, and typically include the code to handle the requests from clients. This code may perform authentication and validation, some or all request processing, and is likely to accesses storage and other services on behalf of the client.
应用程序对通过接受和处理请求对客户端公开其功能。在云托管的情况下,应用程序暴露给客户端终结点,并通常包括来自客户端代码的请求。此代码可以执行认证和验证,一些或全部通过的请求,并有可能访问代表客户端的存储等服务。
If a malicious user is able to compromise the system and gain access to application’s hosting environment, the security mechanisms it uses such as credentials and storage keys, and the services and data it accesses, are exposed. As a result, the malicious user may be able to gain unrestrained access to sensitive information and other services.
如果恶意用户能够损害系统并访问应用程序的主机环境,诸如凭证和存储密钥,以及访问数据的服务,它使用安全机制暴露。其结果是,恶意用户可能能够获得对敏感信息和其他服务的无节制的访问。
Solution 解决方案
To minimize the risk of clients gaining access to sensitive information and services, decouple hosts or tasks that expose public endpoints from the code that processes requests and accesses storage. This can be achieved by using a façade or a dedicated task that interacts with clients and then hands off the request (perhaps through a decoupled interface) to the hosts or tasks that will handle the request. Figure 1 shows a high-level view of this approach.
为了尽量减少客户获取敏感信息和服务的风险,去耦揭露出从该处理请求和访问存储代码公共端点的主机或任务。这可以通过使用一个方面或与客户互动,然后分离请求(可能通过一个去耦接口)连接到主机或任务,将处理该请求的专用任务来实现。图1示出了这种方法的一个高层次的图。
Figure 1 - High level overview of this pattern 图1 -这个模式的高层次概述
The gatekeeper pattern may be used simply to protect storage, or it may be used as a more comprehensive façade to protect all of the functions of the application. The important factors are:
守门人模式可能只是为了保护存储,也可以作为一个更全面的外观模式保护所有应用程序的功能。重要因素是:
- Controlled validation. The Gatekeeper validates all requests, and rejects those that do not meet validation requirements.
- 控制验证。把关人模式验证了所有的请求,并拒绝那些不符合验证要求的请求。
- Limited risk and exposure. The Gatekeeper does not have access to the credentials or keys used by the trusted host to access storage and services. If the Gatekeeper is compromised, the attacker does not obtain access to these credentials or keys.
- 有限风险和暴露。守门人模式没有访问受信任的主机使用的凭据或键来访问存储和服务。如果守门人模式被攻破,攻击者不获得访问这些凭据或密钥。
- Appropriate security. The Gatekeeper runs in a limited privilege mode, whereas the remainder of the application runs in the full trust mode required to access storage and services. If the Gatekeeper is compromised, it cannot directly access the application services or data.
- 适当的安全。该看门人在有限的权限模式下运行,而应用程序的其余部分则运行在需要访问存储和服务的完全信任模式中。如果看门人被入侵,它不能直接访问应用程序服务或数据。
This pattern effectively acts like a firewall in a typical network topography. It allows the Gatekeeper to examine requests and make a decision about whether to pass the request on to the trusted host (sometimes called the Keymaster) that performs the required tasks. This decision will typically require the Gatekeeper to validate and sanitize the request content before passing it on to the trusted host.
这种模式有效扮演着在一个典型的网络防火墙。它允许把关审查请求并决定是否请求传递到受信任的主机(有时称为大师),完成要求的任务。这一决定将通常需要守门人模式验证和把关请求的内容在将它传递到受信任的主机之前。
Issues and Considerations 问题与思考
Consider the following points when deciding how to implement this pattern:
在决定如何实施这一模式时,请考虑以下几点:
- Ensure that the trusted hosts to which the Gatekeeper passes requests expose only internal or protected endpoints, and connect only to the Gatekeeper. The trusted hosts should not expose any external endpoints or interfaces.
- 确保所要传递的请求的受信任的主机只公开内部或受保护的端点,并只连接到“守门人”。受信任的主机不应公开任何外部端点或接口。
- The Gatekeeper must run in a limited privilege mode. Typically this means running the Gatekeeper and the trusted host in separate hosted services or virtual machines.
- 守关人模式必须在有限的特权模式下运行。通常,这意味着运行在单独的托管服务或虚拟机中的守关人模式和受信任的主机。
- The Gatekeeper should not perform any processing related to the application or services, or access any data. Its function is purely to validate and sanitize requests. The trusted hosts may need to perform additional validation of requests, but the core validation should be performed by the Gatekeeper.
- 守关人模式G不应该执行与应用程序或服务相关的任何处理,或访问任何数据。它的功能是纯粹的验证和审核请求。受信任的主机可能需要执行额外的请求验证,但核心验证应由守关人模式执行。
- Use a secure communication channel (HTTPS, SSL, or TLS) between the Gatekeeper and the trusted hosts or tasks where this is possible. However, some hosting environments may not support HTTPS on internal endpoints.
- 使用一个安全的通信通道(HTTPS、SSL,或TLS)在守门人模式和受信任的主机或任务之间,在任何可能的地方。然而,一些托管环境可能不支持在内部端点HTTPS。
- Adding the extra layer to the application to implement the Gatekeeper pattern is likely to have some impact on performance of the application due to the additional processing and network communication it requires.
- 添加额外的层的应用程序来实现的看门模式很可能有一定的影响,由于额外的处理和网络通信,它需要的应用程序的性能。
- The Gatekeeper instance could be a single point of failure. To minimize the impact of a failure, consider deploying additional instances and using an autoscaling mechanism to ensure sufficient capacity to maintain availability.
- 守门人的实例可能是一个单一的故障点。尽量减少失败的影响,考虑部署额外的实例和使用这个机制,确保有足够的能力保持可用性。
When to Use this Pattern 何时使用本模式
This pattern is ideally suited for:
这种模式非常适合:
- Applications that handle sensitive information, expose services that must have high a degree of protection from malicious attacks, or perform mission-critical operations that must not be disrupted.
- 处理敏感信息的应用程序,公开必须具有高度保护的恶意攻击的服务,或执行不可中断的任务关键操作的服务。
- Distributed applications where it is necessary to perform request validation separately from the main tasks, or to centralize this validation to simplify maintenance and administration.
- 分布式应用程序需要执行请求验证分别从主要任务,或集中验证简化维护和管理。
Example 例子
In a cloud-hosted scenario, this pattern can be implemented by decoupling the Gatekeeper role or virtual machine from the trusted roles and services in an application by using an internal endpoint, a queue, or storage as an intermediate communication mechanism. Figure 2 shows the basic principle when using an internal endpoint.
在云托管的情况下,这种模式可以实现的去耦的守门人角色或虚拟机从信任的角色和服务的应用程序通过使用一个内部端点,一个队列,或存储作为一个中间通信机制。图2显示了使用内部端点时的基本原则。
Figure 2 - An example of the pattern using Cloud Services web and worker roles 图2 -使用云服务的Web和工作角色的模式的一个例子
Related Patterns and Guidance 相关模式与指导
The following pattern may also be relevant when implementing this pattern:
当实现此模式时,下列模式也可能是相关的:
- Valet Key Pattern. When communicating between the Gatekeeper and trusted roles it is good practice to enhance security by using keys or tokens that limit permissions for accessing resources. The Valet Key pattern describes how to use a token or key that provides clients with restricted direct access to a specific resource or service.
- 代客主要模式。当守门人和受信任的角色之间的沟通是很好的做法,以提高安全性,通过使用密钥或令牌,限制访问资源的权限。代客主要模式描述了如何使用,提供客户限制直接访问特定的资源或服务标记或关键。
Gatekeeper Pattern 把关(守门人)模式的更多相关文章
- Java Listener pattern 监听者模式
Java Listener pattern 监听者模式 2016-5-12 监听者模式(观察者模式)能降低对象之间耦合程度.为两个相互依赖调用的类进行解耦. 便于进行模块化开发工作.不同模块的开发者可 ...
- 设计模式学习--迭代器模式(Iterator Pattern)和组合模式(Composite Pattern)
设计模式学习--迭代器模式(Iterator Pattern) 概述 ——————————————————————————————————————————————————— 迭代器模式提供一种方法顺序 ...
- Federated Identity Pattern 联合身份模式
Delegate authentication to an external identity provider. This pattern can simplify development, min ...
- [LeetCode] Word Pattern II 词语模式之二
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full mat ...
- Circuit Breaker Pattern(断路器模式)
Handle faults that may take a variable amount of time to rectify when connecting to a remote service ...
- Cache-Aside Pattern(缓存模式)
Load data on demand into a cache from a data store. This pattern can improve performance and also he ...
- 使用C# (.NET Core) 实现适配器模式 (Adapter Pattern) 和外观模式 (Facade Pattern)
本文的概念内容来自深入浅出设计模式一书 现实世界中的适配器(模式) 我带着一个国标插头的笔记本电脑, 来到欧洲, 想插入到欧洲标准的墙壁插座里面, 就需要用中间这个电源适配器. 面向对象的适配器 你有 ...
- 设计模式のCommand Pattern(命令模式)----行为模式
一.产生背景 熟悉计算机的同学应该清楚,用户发出各种命令,CPU执行命令,OS负责调度.命令模式(Command Pattern)是一种数据驱动的设计模式,它属于行为型模式.请求以命令的形式包裹在对象 ...
- 4.Factory Pattern(工厂模式)
工厂模式(Factory Pattern)定义: 定义了一个创建对象的接口,但由子类决定要实例化的类是哪一个.工厂方法让类把实例化推迟到子类. 针对实现编程,但是当我们每次使用new时候,不正是在针对 ...
随机推荐
- Pivot 和 Unpivot
在TSQL中,使用Pivot和Unpivot运算符将一个关系表转换成另外一个关系表,两个命令实现的操作是“相反”的,但是,pivot之后,不能通过unpivot将数据还原.这两个运算符的操作数比较复杂 ...
- OpenCASCADE Expression Interpreter by Flex & Bison
OpenCASCADE Expression Interpreter by Flex & Bison eryar@163.com Abstract. OpenCASCADE provide d ...
- 使用python抓取婚恋网用户数据并用决策树生成自己择偶观
最近在看<机器学习实战>的时候萌生了一个想法,自己去网上爬一些数据按照书上的方法处理一下,不仅可以加深自己对书本的理解,顺便还可以在github拉拉人气.刚好在看决策树这一章,书里面的理论 ...
- .NET平台开源项目速览(13)机器学习组件Accord.NET框架功能介绍
Accord.NET Framework是在AForge.NET项目的基础上封装和进一步开发而来.因为AForge.NET更注重与一些底层和广度,而Accord.NET Framework更注重与机器 ...
- 用scikit-learn学习BIRCH聚类
在BIRCH聚类算法原理中,我们对BIRCH聚类算法的原理做了总结,本文就对scikit-learn中BIRCH算法的使用做一个总结. 1. scikit-learn之BIRCH类 在scikit-l ...
- 多线程 异步 beginInvoke EndInvoke 使用
有许多耗时操作时,还要响应用户操作.这时候就需要用其他线程或者异步来搞.本来是改造公司的日志组件.因为多上了个国外大区的业务到来本系统来.这个系统其他地方都好就是日志,动不动就要死给我们看.有时候寻找 ...
- 【swift】BlockOperation和GCD实用代码块
//BlockOperation // // ViewController.swift import UIKit class ViewController: UIViewController { @I ...
- 【番外篇】ASP.NET MVC快速入门之免费jQuery控件库(MVC5+EF6)
目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...
- Alwayson的IP冲突
Alwayson的IP冲突 https://social.technet.microsoft.com/Forums/office/en-US/4d50cb1c-eef7-4dcc-b937-3c8eb ...
- ASP.NET Linux部署(2) - MS Owin + WebApi + Mono + Jexus
ASP.NET Linux部署(2) - MS Owin + WebApi + Mono + Jexus 本文承接我的上一篇博文: ASP.NET 5 Linux部署,那篇文章主要是针对最新的ASP. ...