当前位置:网站首页>Authentication principle of Ranger plug-in
Authentication principle of Ranger plug-in
2022-07-01 00:35:00 【hncscwc】
ranger The next two articles on plug-in development introduce how to ranger Support a new service in , And develop corresponding client-side plug-ins . But know what it is and why , Behind the simple interface calls , How to perform permission verification internally . This article will briefly talk about its internal implementation principle .
【 Policy related classes in the plug-in 】
from ranger Of web The console can see :
A specific service , There may be several different policy repositories : Resource access control policy repository (Access), The resulting column access control policy repository (Masking), The resulting row access control policy repository (Row Level Filter)
Each policy repository can be configured with multiple policies
Each strategy contains different strategy conditions
Policy conditions include :
- Permissible conditions (Allow Conditions)
- Conditions excluded from the allowable conditions (Exclude from Allow Conditions)
- Veto conditions (Deny Conditions)
- Conditions excluded from veto conditions (Exclude from Deny Conditions)
These policy conditions can contain multiple policy entries , Each policy entry consists of roles 、 user 、 User group 、 The access types of resources consist of .
As shown in the figure below :

stay ranger Inside the plug-in , There are a series of related classes corresponding to this information . Class diagram information is shown in the following figure :

ServicePolicies
A collection of policies for a policy repository of a service .
RangerPolicy
Corresponding to a specific strategy , It contains several important class members :
- resources: One map surface ,key Name the resource ,value by RangerPolicyResource Instance object of , Records the resource information contained in the policy .
- policyItems: The set of policy entries in the allowed conditions in the corresponding policy
- denyPolicyItems: Set of policy entries corresponding to the veto condition in the policy
- allowException: Set of policy entries corresponding to the conditions excluded from the allowed conditions in the policy
- denyException: Set of policy entries corresponding to the conditions excluded in the veto conditions in the policy
Be careful :policyItems、denyPolicyItems、allowException、denyException Are different instance objects of the same class .
RangerPolicyResource
Corresponding to a specific resource , Its class members value Indicates a list of specific values for this resource . Because in web Console , Multiple values can be configured for the same resource .
RangerPolicyItem
Corresponding to a specific policy entry . Its class members users、groups、roles They are users 、 User group 、 Character list ;access It's a RangerPolicyItemAccess List of instance objects , Indicates which resource access types the policy entry contains ;conditions It's a RangerPolicyItemCondition List of instance objects , Indicates which custom condition policies the policy entry contains .
RangerPolicyItemAccess
Describe a specific resource access type . Its class members type Indicates the type of access .
RangerPolicyItemCondition
Policy entries for custom policy conditions .
【 Related classes in the authentication process 】
The above classes only describe permission related policies , These descriptions alone , It is not enough to complete the access control of resource permissions . therefore , stay ranger The internal implementation of the plug-in , It includes a policy engine to drive the completion of specific resource access control logic .
The authentication logic in the plug-in can be divided into these layers from top to bottom , Each layer corresponds to a set of related interfaces and implementation classes .

RangerBasePlugin
The entry of resource access control , Finally, you need to call the isAccessAllowed Interface for permission verification
RangerPolicyEngineImpl
The concrete implementation class of the policy engine , Realized RangerPolicyEngine Interface
RangerEngine
Policy repositories that contain services , And provide interfaces by type 、Tag、Zone Get the corresponding policy warehouse .
RangerPolicyRepository
Represents a strategy warehouse , There is usually only one class instance . But for ranger Some advanced uses of :SecurityZone、 be based on tag Permission verification of , There will be corresponding class instances .
RangerPolicyEvaluator
Abstract class of policy matching expression , from The dimension of strategy Provide authentication calculation interface , Internally, the specific authentication logic is completed by calling the interfaces of different policy items matching expression class instances .
RangerPolicyItemEvaluator
Abstract class of policy item expression , from The dimension of the policy entry Provide authentication calculation interface .
【 Authentication processing flow 】
Before authentication , The plug-in needs to be initialized first , During initialization, a thread will be started periodically from ranger Server pull strategy , Each pull strategy essentially sends one rest request ,ranger After the server receives the request , Press json Format organization sent to plug-ins .

After the plug-in receives the request, it will respond , While the local disk cache , Construct object instances of the above-mentioned related classes in memory .
After the policy is saved locally , The authentication process is shown in the figure below :

In our code, we just need to call RangerBasePlugin Provided isAccessAllowed、evalDataMaskPolicies、evalRowFilterPolicy These methods trigger permission verification .
stay RangerBasePlugin Within these methods , Unified call RangerPolicyEngineImpl Of evaluatePolicies Method to verify permissions . Different entrances , Corresponding to different policy types (POLICY_TYPE_ACCESS、POLICY_TYPE_DATAMASK、POLICY_TYPE_ROWFILTER)
adopt policyengine Interface to get the correct policy repository .
From the policy repository , Resources on request 、 Get matching policyEvaluator list .
Yes policyEvaluator List one call evaluator Perform permission matching , Once there is a definite result, it returns ( End cycle , No subsequent calls )
stay policyEvaluator Of evaluator Interface , Traverse policy entries in different policy conditions , And call the corresponding interface (isMatch), Get the policy entry that matches the access action , Then determine whether access is allowed , Finally, the authority verification result is obtained .
To sum up : This paper mainly introduces ranger Implementation classes related to policy and authentication in the plug-in , And the logic flow of authentication . In the process of source code research , I found that there are many small details , There is no explanation here . for example , How to sort multiple policies containing the same resource , How different strategy conditions in the same strategy interact ( Permissible conditions 、 Veto conditions 、 Exclusion conditions ) wait . These contents have no impact on the overall process , Later, I will take time to supplement .
Okay , That's all for this article , Originality is not easy. , give the thumbs-up , Looking at , Sharing is the best support , thank you ~
Recommended reading :
This article is from WeChat official account. - hncscwc(gh_383bc7486c1a).
If there is any infringement , Please contact the [email protected] Delete .
Participation of this paper “OSC Source creation plan ”, You are welcome to join us , share .
边栏推荐
- New trend of embedded software development: Devops
- 20220215 misc buctf easycap Wireshark tracks TCP flow hidden key (use of WinHex tool)
- Which is better, server rental or hosting services in the United States?
- 2022-2028 global ultra high purity electrolytic iron powder industry research and trend analysis report
- Oracle临时表详解
- Wechat official account development (1) introduction to wechat official account
- 20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking
- 2022-2028 global capsule shell industry research and trend analysis report
- Oracle-数据完整性
- 【2023联发科提前批笔试题】~ 题目及参考答案
猜你喜欢

剑指 Offer 19. 正则表达式匹配

2022-2028 global herbal diet tea industry research and trend analysis report

Confirm() method of window

2022-2028 global capsule shell industry research and trend analysis report

Oracle-表的创建与管理

SSM integration process (integration configuration, function module development, interface test)

BeanUtils. Copyproperties() vs. mapstruct

VR panorama adds contrast function to make the display of differentiation effect more intuitive!

SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding

20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute
随机推荐
Vulnerability discovery - App application vulnerability probe type utilization and repair
Longest valid bracket
【2023联发科提前批笔试题】~ 题目及参考答案
Introduction to ES6 promise, new features of ES7 and es8 async and await
How does the VR cloud exhibition hall bring vitality to offline entities? What are the functions?
给按钮的边框和文字设置不同的背景色
Rust book materials - yazhijia Library
How to specify the number of cycles in JSTL- How to loop over something a specified number of times in JSTL?
Is it safe to open a stock account of Huatai Securities online?
Integer to hexadecimal string PTA
剑指 Offer 18. 删除链表的节点
NE555波形发生器手把手教程之NE555内部结构(一)
Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
The difference between union and union all in MySQL
MySQL index test
ABAQUS 2022 software installation package and installation tutorial
PyTorch安装并使用gpu加速
2022-2028 global herbal diet tea industry research and trend analysis report
File reading and writing for rust file system processing - rust Practice Guide
2022-2028 global electric yacht industry research and trend analysis report