sync_user
This function is used to sync (save) a user's information to the Permit.io cloud and PDP (Policy Decision Point) upon user creation.
This function should be used for the initial creation of the user. This means that when you need to have the user synced between your authentication solution and Permit, this is the function you need to use.
Once the user has been synced with Permit, you should not use this sdk call to update the user's role.
Parameters
user
- An Hash object that contains the information about the user. The payload is defined below.
Hash Payload
key
- A unique id by which Permit will identify the user for permission checks.
You will later pass this Key to the permit.check()
API. You can use anything for this Key - the user email, a UUID or anything else as long as it's unique on your end. The user key must be url-friendly (slugified).
email
- optional - The email of the user. If synced, will be unique inside the environment.
first_name
- optional - First name of the user.
last_name
- optional - Last name of the user.
attributes
- optional - Arbitrary user attributes that will be used to enforce attribute-based access control policies.
user = {"key": "user-key", "email": "john@doe.com", "first_name": "John", "last_name": "Doe", "attributes": {"age": "26"}}
Implementation
new_user := permit.sync_user(user)