Introduced in SQLPage 0.35.0.
Accessing information about the current user, when logged in with SSO
This function can be used only when you have configured Single Sign-On with an OIDC provider.
The ID Token
When a user logs in through OIDC, your application receives an identity token from the identity provider.
This token contains information about the user, such as their name and email address.
The sqlpage.user_info_token()
function lets you access the entire contents of the ID token, as a JSON object.
You can then use your database's JSON functions to process that JSON.
If you need to access a specific claim, it is easier and more performant to use the
sqlpage.user_info()
function instead.
Example: Displaying User Information
select 'list' as component;
select key as title, value as description
from json_each(sqlpage.user_info_token());
This sqlite-specific example will show all the information available about the current user, such as:
sub
: A unique identifier for the username
: The user's full nameemail
: The user's email addresspicture
: A URL to the user's profile picture
Security Notes
- The ID token is automatically verified by SQLPage to ensure it hasn't been tampered with.
- The token is only available to authenticated users: if no user is logged in or sso is not configured, this function returns NULL
- If some information is not available in the token, you have to configure it on your OIDC provider, SQLPage can't do anything about it.
- The token is stored in a signed http-only cookie named
sqlpage_auth
. You can use the cookie component to delete it, and the user will be redirected to the login page on the next page load.
basic_auth_password
basic_auth_username
client_ip
cookie
current_working_directory
environment_variable
exec
fetch
fetch_with_meta
hash_password
header
headers
link
path
persist_uploaded_file
protocol
random_string
read_file_as_data_url
read_file_as_text
request_body
request_body_base64
request_method
run_sql
uploaded_file_mime_type
uploaded_file_name
uploaded_file_path
url_encode
user_info
user_info_token
variables
version