-
Notifications
You must be signed in to change notification settings - Fork 13
User profiles #1345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrejtonev
wants to merge
1
commit into
memgraph-3-5
Choose a base branch
from
user_profiles
base: memgraph-3-5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+266
−5
Open
User profiles #1345
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 200 additions & 0 deletions
200
pages/database-management/authentication-and-authorization/user-profiles.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
--- | ||
title: User profiles | ||
description: Learn how to manage user profiles and set resource limits for users in Memgraph Enterprise. | ||
--- | ||
|
||
# User profiles | ||
|
||
User profiles allow you to set resource limits for users in Memgraph Enterprise. You can define limits on the number of sessions and memory usage to control resource consumption and prevent abuse. | ||
|
||
User profiles provide a way to: | ||
- Set resource limits for individual users | ||
- Control the number of concurrent sessions per user | ||
- Limit query memory usage over all active | ||
- Monitor resource consumption in real-time | ||
- Enforce resource quotas to prevent system abuse | ||
|
||
## Prerequisites | ||
|
||
To use user profiles, you need: | ||
- Memgraph Enterprise Edition | ||
- The `PROFILE_RESTRICTION` privilege to manage profiles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where else is this mentioned in the docs? Explain how to achieve this prerequisite |
||
|
||
## Creating profiles | ||
|
||
You can create a profile with default unlimited limits: | ||
|
||
```cypher | ||
CREATE PROFILE profile_name; | ||
``` | ||
|
||
Or create a profile with specific limits: | ||
|
||
```cypher | ||
CREATE PROFILE profile_name LIMIT sessions 10, transactions_memory 100MB; | ||
``` | ||
|
||
### Available limits | ||
|
||
- **sessions**: Maximum number of concurrent sessions (default: unlimited) | ||
- **transactions_memory**: Maximum memory usage over all active transactions (default: unlimited) | ||
|
||
### Limit values | ||
|
||
You can specify limits in different formats: | ||
|
||
- **Unlimited**: `UNLIMITED` (default) | ||
- **Quantity**: A positive number (e.g., `10`) | ||
- **Memory**: A number with unit MB/KB (e.g., `100MB`, `512KB`) | ||
|
||
### Examples | ||
|
||
```cypher | ||
-- Create a profile with session limit only | ||
CREATE PROFILE session_limited LIMIT sessions 5; | ||
-- Create a profile with memory limit only | ||
CREATE PROFILE memory_limited LIMIT transactions_memory 50MB; | ||
-- Create a profile with both limits | ||
CREATE PROFILE strict_profile LIMIT sessions 3, transactions_memory 25MB; | ||
-- Create a profile with different memory units | ||
CREATE PROFILE small_profile LIMIT transactions_memory 1KB; | ||
``` | ||
|
||
## Managing profiles | ||
|
||
### Update a profile | ||
|
||
```cypher | ||
UPDATE PROFILE profile_name LIMIT sessions 5, transactions_memory 50MB; | ||
``` | ||
|
||
### Drop a profile | ||
|
||
```cypher | ||
DROP PROFILE profile_name; | ||
``` | ||
|
||
**Note**: When you drop a profile, all users assigned to that profile will have their limits reset and profile assignment cleared. | ||
|
||
|
||
### Clear a profile assignment | ||
|
||
```cypher | ||
CLEAR PROFILE FOR username; | ||
``` | ||
|
||
This removes the profile assignment, returning the user to unlimited resources. | ||
|
||
## Viewing profile assignments | ||
|
||
### Show profile for a user | ||
|
||
```cypher | ||
SHOW PROFILE FOR username; | ||
``` | ||
|
||
### Show users assigned to a profile | ||
|
||
```cypher | ||
SHOW USERS FOR PROFILE profile_name; | ||
``` | ||
|
||
## Monitoring resource usage | ||
|
||
### Show resource usage for a user | ||
|
||
```cypher | ||
SHOW RESOURCE USAGE FOR username; | ||
``` | ||
|
||
This command shows the current resource consumption and imposed limits for the specified user, including: | ||
- Number of active sessions | ||
- Current memory usage over all active transactions | ||
|
||
## Profile management | ||
|
||
User profiles are assigned directly to users and provide resource limits for those specific users. Each user can have one profile assigned at a time. | ||
|
||
### Profile assignment behavior | ||
|
||
**Important**: Profile assignment is a simple mapping between profile names and usernames. This means: | ||
|
||
- **Users don't need to exist** when you assign a profile to them | ||
- You can assign a profile to a username that hasn't been created yet | ||
- You can assign a profile to a SSO user that will never exist in Memgraph | ||
- The profile will be automatically applied when that user connects to the database | ||
- Dropping a profile **does remove the mapping** | ||
|
||
## Error handling | ||
|
||
The system provides clear error messages for invalid operations: | ||
|
||
- **Duplicate profile creation**: Error when trying to create a profile with an existing name | ||
- **Non-existent profile operations**: Error when trying to show, update, or drop non-existent profiles | ||
- **Invalid limit values**: Error for negative numbers or invalid memory units | ||
- **Invalid limit names**: Error for unsupported limit types | ||
|
||
**Note**: Assigning a profile to a non-existent user will **not** cause an error. The assignment will be stored and applied when the user connects to the database. | ||
|
||
## Best practices | ||
|
||
1. **Start with unlimited profiles**: Create profiles without limits first, then gradually add restrictions | ||
2. **Monitor usage**: Regularly check resource usage to understand actual consumption patterns | ||
|
||
## Examples | ||
|
||
### Complete workflow example | ||
|
||
```cypher | ||
-- 1. Create users | ||
CREATE USER developer1; | ||
CREATE USER developer2; | ||
-- 2. Create profiles with different restrictions | ||
CREATE PROFILE basic_profile LIMIT sessions 10; | ||
CREATE PROFILE strict_profile LIMIT sessions 3, transactions_memory 50MB; | ||
-- 3. Assign profiles | ||
SET PROFILE FOR developer1 TO basic_profile; | ||
SET PROFILE FOR developer2 TO strict_profile; | ||
-- 4. Verify assignments | ||
SHOW PROFILE FOR developer1; | ||
SHOW USERS FOR PROFILE basic_profile; | ||
-- 5. Monitor usage | ||
SHOW RESOURCE USAGE FOR developer1; | ||
-- 6. Update limits based on usage patterns | ||
UPDATE PROFILE strict_profile LIMIT sessions 5, transactions_memory 25MB; | ||
-- 7. Verify limits | ||
SHOW RESOURCE USAGE FOR developer2; | ||
``` | ||
|
||
## Syntax reference | ||
|
||
| Command | Description | | ||
|---------|-------------| | ||
| `CREATE PROFILE name [LIMIT limit_list]` | Create a new profile | | ||
| `UPDATE PROFILE name LIMIT limit_list` | Update existing profile limits | | ||
| `DROP PROFILE name` | Delete a profile | | ||
| `SHOW PROFILES` | List all profiles | | ||
| `SHOW PROFILE name` | Show specific profile details | | ||
| `SET PROFILE FOR user TO profile` | Assign profile to user | | ||
| `CLEAR PROFILE FOR user` | Remove profile assignment | | ||
| `SHOW PROFILE FOR user` | Show profile assigned to user | | ||
| `SHOW USERS FOR PROFILE name` | List users assigned to profile | | ||
| `SHOW RESOURCE USAGE FOR user` | Show current resource usage | | ||
|
||
### Limit syntax | ||
|
||
``` | ||
limit_list: limit_item [, limit_item]* | ||
limit_item: sessions number | transactions_memory memory_value | ||
memory_value: number (MB | KB) | ||
number: positive integer | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.