What are session profiles?
Session profiles are resources created by the parent organization that allow sessions to be issued with limited capabilities. When a session is issued with a session profile, the profile’s capability is evaluated on every request made with that session. If the capability evaluates tofalse, the request is denied.
Session profiles are immutable - once created, they cannot be edited or deleted. Make sure the configuration is correct before creating a session profile.
Session profiles can be created using the CreateSessionProfile activity, via the public API or the Turnkey dashboard.
Session profile structure
TheCreateSessionProfile activity has the following parameters:
sessionProfileName(required): A human-readable name for the session profile. This name will also be used as thesession_typein the resulting session JWT.capability(required): A string of policy language that is evaluated on every request made with this session. If the capability evaluates totrue, the request is allowed. If it evaluates tofalse, the request is denied.expirationSeconds(optional): The maximum duration in seconds for sessions created with this profile. If not set, the expiration is determined by the value passed into the login activity intent.notes(optional): Notes for the session profile.
Capability
Thecapability field uses the same policy language as policy conditions and MFA conditions. It has access to the same keywords, including activity.type, activity.action, eth.tx, and others.
Examples:
Expiration
The final session expiration is determined by taking the minimum of the login intent’s expiration and the session profile’s expiration:- If both are set: the shorter of the two is used
- If only the intent expiration is set: the intent expiration is used
- If only the profile expiration is set: the profile expiration is used
- If neither is set: a default expiration is used (900 seconds / 15 minutes)
Issuing sessions with a session profile
To issue a session with a session profile, pass thesessionProfileId into any login activity:
STAMP_LOGINOTP_LOGINOAUTH_LOGIN
session_profile_id: the ID of the session profilecapability: the capability string from the profilesession_type: set to the session profile’s name (instead of the defaultSESSION_TYPE_READ_WRITE)
sessionProfileId is passed, the session is issued as a default read-write session with no capability restrictions.
Querying session profiles
Session profiles can be queried using:GetSessionProfile: retrieve a single session profile by IDGetSessionProfiles: list all session profiles for an organization