# Cross-Domain Access Control Model in Industrial IoT Environment
## 3 Distributed Access Control Model Based on a Master-Slave Chain
### Cross-Domain Access Control Model  
#### 3.3.1 Access Control Based on Combination of Roles and Attribute  
The access control process is divided into three phases: identity registration, access request, and access control. In this study, the access request needed to be recognized and processed by the smart contract before access control. Therefore, before the access request control process started, the corresponding smart contracts needed to be deployed in the master-slave chain model.  
Intra-domain access control smart contract (IDSC): The intra-domain access control smart contract is deployed on the slave chain and is responsible for intra-domain access control. When an access request is received, the IDSC passes to call a resource strategy from the resource strategy database. Then the IDSC performs its matching Algorithm 1. If the match is successful, an access token is generated. If the match fails, an error result is returned.  
```
Input: Access requests \(Ar\) Resource strategy Database RSD Output: Access token Token
1.\(AttrSet=Ar.Cd.Attrs\);
2.\(StrSet=RSD.API.GetStr(Ar.Dt)\);
3.\(Successful\_Math=match(AttrSet,StrSet)\)
4.\(if(Successful\_Match==true)\)
5.return Token;
6.\(elseif(Successful\_Match==false)\)
7.\(return\)\(false\)
8.endif
```  
**Algorithm 1****Intra-Domain Access Control**  
Smart contracts that need to be deployed in the master chain:  
Cross-domain access control smart contract (CDSC): The cross-domain access control smart contract is deployed on the master chain and is responsible for cross-domain access control. When an access request is received, the CDSC first performs a role check, followed by calling a resource strategy from the resource strategy database. Then the CDSC performs its matching Algorithm 2. If the match is successful, an access token is generated. If the match fails, an error result is returned.  
With the above smart contracts, IIoT devices can then perform reliable and effective intra-domain access control and cross-domain access control. Due to the diversity of IIoT devices, different domains exist in different IIoT environments, so this paper proposes a cross-domain access control model based on a combination of roles and attributes. Each domain has a role identity, and all devices under that domain inherit the domain identity role. The entire access control process is divided into three main parts: device identity registration, access request, and access control. In the identity registration phase, the device needs to send registration information to IMS, including its device ID, attribute information, role information, etc. Following this, an access request is sent to the edge node, which then judges the access request. If it is an intra-domain access request, the access control smart contract is called to determine the result. If the request is cross-domain, the access request information is sent to the master chain node, which then communicates with the master chain node of the target domain to determine the access request result. Finally, the device is granted access to the target resource. More details about access control are described in Section 3.4.  
```
Input: Access requests \(Ar\) Resource strategy Database RSD Output: Access token Token
1.\(if(CheckRel(Ar.Cd_{i}.Rold))\);
2.\(AttrSet=Ar.Cd.Attrs\);
3.\(StrSet=RSD.API.GetStr(Ar.Dt)\);
4.\(Successful\_Math=match(AttrSet,StrSet)\)
5.\(if(Successful\_Match==true)\)
6.return Token;
7.\(elseif(Successful\_Match==false)\)
8.return false
9.\(Endif\)
10.else
11.\(return\) false
12.endif
```  
**Algorithm 2****Cross-Domain Access Control**