security.md 9.6 KB
Newer Older
1 2
# Security (Authorization System)

3 4 5
Only the administrator account in the security center has permission to operate, which includes queue management, tenant management, user management, alarm group management, worker group management, token management and other functions. In the user management module, you can authorize resources, data sources, projects, etc.

Administrator login, default username/password: admin/dolphinscheduler123
6 7 8

## Create Queue

9
- The queue is used when executing programs such as spark and mapreduce, and the "queue" parameter needs to be used.
10 11
- The administrator enters the `Security Center->Queue Management` page and clicks the "Create Queue" button to create a new queue.

12
![create-queue](../../../img/new_ui/dev/security/create-queue.png)
13 14 15

## Add Tenant

16 17 18
- The tenant corresponds to the Linux user, which is used by the worker to submit the job. If linux does not have this user, it will cause the task to fail. You can automatically create a linux user when the user does not exist by modifying the parameters in the `worker.properties` configuration file. The parameter will require that the worker can run the command `worker.tenant.auto.create = true; worker.tenant.auto.create = truesudo`
- Tenant Code: **The tenant code is the user on Linux, unique and cannot be repeated**
- The administrator enters the `Security Center->Tenant Management` page, and clicks the `Create Tenant` button to create a tenant.
19

20
![create-tenant](../../../img/new_ui/dev/security/create-tenant.png)
21 22 23

## Create Normal User

24
Users are divided into **administrator users** and **ordinary users**
25

26 27 28
- Administrators have permissions such as authorization and user management, but do not have permissions to create projects and actions defined by workflows.
- Ordinary users can create projects and create, edit, and execute workflow definitions.
- **Note**: If the user switches tenants, all resources under the tenant to which the user belongs will be copied to the new tenant that is switched.
29

30
Go to the `Security Center -> User Management` page and click the `Create User` button to create a user, administrator only.
31

32
![create-user](../../../img/new_ui/dev/security/create-user.png)
33

34 35 36 37 38
### Edit user information

The administrator enters the `Security Center->User Management` page and clicks the `Edit` button to edit user information.

After logging in as an ordinary user, click the user information in the drop-down box of the user name to enter the user information page, and click the `Edit` button to edit the user information.
39

40
### Modify user password
41

42
The administrator enters the `Security Center -> User Management` page and clicks the `Edit` button. When editing user information, enter the new password to modify the user password.
43

44
After logging in as an ordinary user, click the user information in the user name drop-down box to enter the password modification page, enter the password and confirm the password and click the `Edit` button, then the password modification is successful.
45 46 47

## Create Alarm Group

48
The alarm group is a parameter set at startup. After the process ends, the status of the process and other information will be sent to the alarm group by email.
49

50
The administrator enters the `Security Center -> Alarm Group Management` page and clicks the `Create Alarm Group` button to create an alarm group.
51

52
![create-alarmInstance](../../../img/new_ui/dev/security/create-alarmInstance.png)
53 54 55

## Token Management

56
Since the back-end interface has a login check, token management provides a way to perform various operations on the system by calling the interface.
57

58
The administrator enters the `Security Center -> Token Management page`, clicks the `Create Token` button, selects the expiration time and user, clicks the `Generate Token` button, and clicks the `Submit` button, then create the selected user's token successfully.
59

60
![create-token](../../../img/new_ui/dev/security/create-token.png)
61

62 63 64
After a normal user logs in, click the user information in the username drop-down box, enter the token management page, select the expiration time, click the `Generate Token` button, and click the `Submit` button, then the user creates a token successfully.

Example of calling:
65 66

```java
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
/**
 * test token
 */
public  void doPOSTParam()throws Exception{
    // create HttpClient
    CloseableHttpClient httpclient = HttpClients.createDefault();
    // create http post request
    HttpPost httpPost = new HttpPost("http://127.0.0.1:12345/escheduler/projects/create");
    httpPost.setHeader("token", "123");
    // set parameters
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("projectName", "qzw"));
    parameters.add(new BasicNameValuePair("desc", "qzw"));
    UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(parameters);
    httpPost.setEntity(formEntity);
    CloseableHttpResponse response = null;
    try {
        // execute
        response = httpclient.execute(httpPost);
        // response status code 200
        if (response.getStatusLine().getStatusCode() == 200) {
            String content = EntityUtils.toString(response.getEntity(), "UTF-8");
            System.out.println(content);
        }
    } finally {
        if (response != null) {
            response.close();
94
        }
95
        httpclient.close();
96
    }
97
}
98 99 100 101
```

## Granted Permissions

102 103 104 105
- Granted permissions include project permissions, resource permissions, data source permissions, and UDF function permissions.
- Administrators can authorize projects, resources, data sources, and UDF functions that ordinary users do not create. Because the authorization methods of projects, resources, data sources and UDF functions are all the same, the project authorization is used as an example to introduce.
- Note: For projects created by the user, the user has all permissions. The item list and the selected items list are not displayed.
- The administrator enters the `Security Center -> User Management` page, and clicks the "Authorize" button of the user to be authorized, as shown in the following figure:
106

107
<p align="center">
108
  <img src="../../../img/auth-en.png" width="80%" />
109 110
</p>

111
- Select the project to authorize the project.
112 113

<p align="center">
114
   <img src="../../../img/auth-project-en.png" width="80%" />
115
</p>
116 117 118 119 120 121 122

- Resources, data sources, and UDF function authorization are the same as project authorization.

## Worker Grouping

Each worker node will belong to its own worker group, and the default group is "default".

123
When the task is executed, the task can be assigned to the specified worker group, and finally the worker node in the group will execute the task.
124

125
### Add or update worker group
126 127 128

- Open the `conf/worker.properties` configuration file on the worker node where you want to configure the groups and modify the `worker.groups` parameter.
- The `worker.groups` parameter is followed by the name of the group corresponding to the worker node, which is `default`.
129
- If the worker node corresponds to multiple groups, separate them with commas. Example:
130 131 132 133

```conf
worker.groups=default,test
```
134

135 136 137 138
- You can also change the worker group for the worker during execution, and if the modification is successful, the worker will use the new group and ignore the configuration in `worker.properties`. The step to modify work group as below: `Security Center -> Worker Group Management -> click 'New Worker Group' -> click 'New Worker Group' ->  enter 'Group Name' -> Select Exists Worker -> Click Submit`. 

## Environmental Management

139 140 141
- Configure the worker running environment online, a worker can specify multiple environments, each environment is equivalent to the `dolphinscheduler_env.sh` file.
- The default environment is the `dolphinscheduler_env.sh` file.
- When the task is executed, the task can be assigned to the specified worker group, and the corresponding environment can be selected according to the worker group, and finally the worker node in the group executes the environment and then executes the task.
142

143
### Add or update environment
144

145
The environment configuration is equivalent to the configuration in the `dolphinscheduler_env.sh` file.
146

147
![create-environment](../../../img/new_ui/dev/security/create-environment.png)
148

149 150 151
### Usage environment

Create a task node in the workflow definition, select the worker group and the environment corresponding to the worker group. When executing the task, the Worker will execute the environment first before executing the task.
152

153
![use-environment](../../../img/new_ui/dev/security/use-environment.png)
154

155 156
> NOTE: Please make sure you have associated the `Environments` with your `worker groups` if you can not select the `Environment Name` in workflow definition page or when triggering workflows.

157 158 159 160 161 162 163 164 165 166
## Cluster Management

> Add or update cluster
- Each process can be related to zero or several clusters to support multiple environment, now just support k8s.

> Usage cluster
- After creation and authorization, k8s namespaces and processes will associate clusters. Each cluster will have separate workflows and task instances running independently.

![create-cluster](../../../img/new_ui/dev/security/create-cluster.png)

167 168 169 170
## Namespace Management

> Add or update k8s cluster

171
- First enter the configuration of the k8s cluster connection into the table `t_ds_k8s` in the database for batch job and will removed later, the creation of the namespace now selects the cluster by drop-down options.
172 173 174 175 176

> Add or update namespace

- After creation and authorization, you can select it from the namespace drop down list when edit k8s task, If the k8s cluster name is `ds_null_k8s` means test mode which will not operate the cluster actually.

177
![create-environment](../../../img/new_ui/dev/security/create-namespace.png)
178 179