1e41f4b71Sopenharmony_ci# Application Permission Management Overview 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Introduction 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciApplication permissions are used to control the access to system resources (such as the Contacts) and system capabilities (such as the camera and microphone) to protect system data (including personal data) and functions. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciApplication permissions are used to protect: 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci- Data, including personal data (such as photos, Contacts, Calendar, and location) and device data (such as device ID, camera data, and microphone data). 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci- Functionalities, including device functionalities (such as accessing the camera or microphone, making a call, and connecting to the Internet) and application functionalities (such as displaying a floating window and creating a shortcut). 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Basic Principles for Using Permissions 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ciDetermine the permissions required by your application based on the use cases of your application. Comply with the following principles when applying for permissions during application development: 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci- All the permissions required by your application (including third-party libraries referenced by your application) must be declared one by one in the application's configuration file. For details, see [Declaring Permissions](declare-permissions.md). 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci- Request only the least required permissions for your application. Do not apply for unnecessary or obsolete permissions. Excess permission for an application may adversely affect user experience. When users have concern about the application security, they are reluctant to install or use the application. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci- When requesting a sensitive permission, also specify the reason why this permission is required. Sensitive permissions are permissions closely related to user privacy, including those related to the location, camera, microphone, Calendar, fitness, body sensors, media, files, images and videos. For details, see [Requesting User Authorization](request-user-authorization.md). 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci- Sensitive permissions must be dynamically requested before the related service feature is provided. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci- If a user refuses to grant a permission, other service features irrelevant to this permission can be used normally. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci## Authorization Mode 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ciPermissions can be classified into system_grant permissions and user_grant permissions based on the authorization mode. 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci### system_grant (System Authorization) 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ciA system_grant permission is authorized by the system. The application with this type of permission cannot access user or device sensitive information, and the operations allowed have controllable impact on the system or other applications. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ciFor an application with a system_grant permission, the system automatically grants the permission to the application during the installation process. 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci### user_grant (User Authorization) 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ciA user_grant permission must be authorized by the user. An application with this type of permission may access user or device sensitive information, and the operations allowed may have a critical impact on the system or other applications. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ciThis type of permissions must be declared in the application installation package and authorized by the user in a dialog box during the running of the application. The application has the permission only after user authorization. 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ciFor example, the permissions related to the microphone and camera in the [Permissions for All Applications](permissions-for-all.md) are user_grant permissions. The list of user_grant permissions must be presented on the application details page in the application market. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci## Permission Groups and Permissions 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ciA permission group consists of user_grant permissions that are logically related. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci It helps minimize the number of dialogs that are presented to the user when an application requests closely related permissions. A permission in a permission group is called a sub-permission of the group. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ciThe relationship between a permission group and its permissions is not fixed. For details about the permission groups supported by the system, see [Application Permission Groups](app-permission-group-list.md). 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci## Basic Concepts in the Permission Mechanism 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci- TokenID 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci Token identity (token ID or **TokenID**) uniquely identifies an application in the system. The AccessTokenManager (ATM) service manages the application Access Token (AT) information based on the token ID. The AT information includes the application ID, sub-user ID, application twin index, application Ability Privilege Level (APL), and permission grant status. When resources are required, the system uses the token ID as the unique identifier to obtain the application's permission grant status and performs authentication based on the information to control the resource access behavior of the application. 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci In addition, the system supports the multi-user feature and the App Twin feature. Different users and the twin applications of the same application have their own AT information with different token IDs. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci- APL 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci Both the applications and permissions are assigned with different APLs to prevent abuse of permissions. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci The APL defines the application's priority for requesting permissions. Applications of different APLs can request permissions of different APLs. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci- Application APL 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci Application APLs are classified into three levels in ascending order of seniority. 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci | APL| Description| 72e41f4b71Sopenharmony_ci | -------- | -------- | 73e41f4b71Sopenharmony_ci | normal | Default APL of an application.| 74e41f4b71Sopenharmony_ci | system_basic | Application that provides basic system services.| 75e41f4b71Sopenharmony_ci | system_core | Application that provides OS core abilities. <br>Only the APL of a system application or Mobile Device Management (MDM) application can be system_core.| 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci- Permission APL 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci Permissions are granted to applications based on the application APL. The permission APLs are also classified into three levels in ascending order of seniority. 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci | APL| Description| Available To| 82e41f4b71Sopenharmony_ci | -------- | -------- | -------- | 83e41f4b71Sopenharmony_ci | normal | Allows an application to access common system resources beyond the default rules, such as configuring Wi-Fi and invoking the camera to take photos.<br>Access to these resources (including data and functions) imposes low risks on user privacy and other applications.| Applications with the normal or higher APL.| 84e41f4b71Sopenharmony_ci | system_basic | Allows an application to access resources related to basic OS services (basic functions provided or preset by the system), such as system settings and identity authentication.<br>Access to these resources imposes low risks to user privacy and other applications.| <!--RP1-->Applications with the system_basic or system_core APL.<!--RP1End--> | 85e41f4b71Sopenharmony_ci | system_core | Allows an application to access OS core resources, which are critical to underlying core services. If these resources are corrupted, the OS cannot run properly.| - Applications with the system_core APL.<br>- System applications only.| 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci- ACL 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci Permission APLs and application APLs are in one-to-one correspondence. In principle, an application with a lower APL cannot request a permission with a higher APL. However, you can use the Access Control List (ACL) to enable an application to have permissions beyond its APL. 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci All the system permissions are defined with the **Enable via ACL** field. If the value is true, the application can be granted to an application with a lower APL via the ACL. For the definition of a permission, see <!--RP2-->[Permissions for System Applications](permissions-for-system-apps.md)<!--RP2End-->. 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci For example, to implement a special feature, application A with the normal APL requires permission P, whose APL is system_basic. If **Enable via ACL** is true for permission P, application A can request permission P via the ACL. 94