PEG REST API on Privacera Self-Managed Deployment¶
For the Privacera Self-Managed deployment, the PEG API endpoints are available at:
Text Only | |
---|---|
Please check with your installation team for the value of <privacera_hostname>
and confirm if any custom configuration has been applied.
API Endpoints¶
The PEG REST API includes the following endpoints:
Endpoint | Description | Authentication |
---|---|---|
/api/peg/v2/protect | Encrypts single data item using specified scheme | JWT |
/api/peg/v2/unprotect | Decrypts single data item with optional presentation scheme | JWT |
/api/peg/v2/mask | Masks single data item | JWT |
/api/peg/v2/multi/protect | Encrypts multiple data items with multiple schemes | JWT |
/api/peg/v2/multi/unprotect | Decrypts multiple data items with multiple schemes and optional presentation schemes | JWT |
/api/peg/v2/multi/mask | Masks multiple data items with multiple schemes | JWT |
/api/public/crypto/schemes/byuser | Gets a list of schemes on which the user has permissions | JWT |
Authentication¶
The PEG API uses JWT tokens for authentication. For detailed instructions on generating and using JWT tokens, see JWT Tokens for Encryption.
When making API requests, include the JWT token in the Authorization header:
Bash | |
---|---|
API Request Parameters¶
Common Parameters¶
Parameter | Description |
---|---|
scheme | The encryption scheme to use (e.g., "SYSTEM_EMAIL", "SYSTEM_SSN") |
data | The data to encrypt, decrypt, or mask |
presentationScheme | Optional. The presentation scheme to apply during decryption |
user | Optional. Username for impersonation if authorized |
schemes | Array of scheme names (for multi endpoints) |
datas | Array of data items (for multi endpoints) |
presentationSchemes | Optional. Array of presentation schemes (for multi/unprotect) |
API Examples¶
1. Single Data Protection (/api/peg/v2/protect
)¶
Request:
Bash | |
---|---|
Response:
2. Single Data Unprotection (/api/peg/v2/unprotect
)¶
Request:
Bash | |
---|---|
Response:
3. Single Data Masking (/api/peg/v2/mask
)¶
Request:
Bash | |
---|---|
Response:
4. Multi-Data Protection (/api/peg/v2/multi/protect
)¶
Request:
Response:
JSON | |
---|---|
5. Multi-Data Unprotection (/api/peg/v2/multi/unprotect
)¶
Request:
Response:
JSON | |
---|---|
6. Multi-Data Masking (/api/peg/v2/multi/mask
)¶
Request:
Response:
JSON | |
---|---|
7. Get Available Schemes (/api/public/crypto/schemes/byuser
)¶
Request:
Bash | |
---|---|
Response:
User Impersonation¶
The PEG API supports user impersonation, allowing authorized users to perform encryption operations on behalf of other users.
Requirements for Impersonation¶
For a user to impersonate another user, the following conditions must be met:
- The authenticated user (the user whose JWT token is used) must have the Impersonate permission for the relevant scheme in the scheme policy
- The impersonated user (specified in the
user
parameter) must exist in the system - The impersonated user must have access to the relevant encryption scheme via a scheme policy
Using Impersonation¶
To impersonate another user, include the user
parameter in your API request:
Bash | |
---|---|
In this example: - The authentication and authorization is performed using the JWT token of the calling user - The operation is recorded in audit logs as performed by user_being_impersonated
- Any scheme policy checks are performed against the user_being_impersonated
user's permissions
Common Use Cases¶
User impersonation is particularly useful for:
- Service applications that need to perform encryption/decryption operations on behalf of multiple end users
- Administrative tools that manage data for various users in the system
- Batch processing systems that handle operations for different user accounts
Related Terminology¶
As described in the Terminology and Roles documentation:
- Authentication User: The user who has access to the PEG service and can impersonate other users (must have the Impersonate permission)
- Impersonated User: The user on whose behalf the operation is performed (must exist in the system and have appropriate scheme permissions)
Error Handling¶
Common Error Codes¶
Status Code | Description |
---|---|
400 | Bad Request - Invalid parameters or data format |
401 | Unauthorized - Invalid or expired JWT token |
403 | Forbidden - Insufficient permissions for the operation |
404 | Not Found - Scheme not found |
500 | Internal Server Error - Server-side failure |
Partial Success in Bulk Operations¶
For bulk operations, if an error occurs with one element, the API will still process other elements and return a "Partial Success" status.
Example response with partial success:
JSON | |
---|---|
Related Resources¶
- Prev topic: Apache Ranger Java API User Guide