•
15 September 2025
•
1 min
I was in search of a free way to let people access our Mapbox account without giving company credentials. From there, I found Mapbox SSO which I configured with Auth0 to enable SSO (single-sign on) access to our company’s Mapbox.
System Overview:
redirect_url
pointing to Mapbox’s provided single sign-on URL. The link is an href to the Auth0 application which is a login form.Pre-user registration action (Auth0):
exports.onExecutePreUserRegistration = async (event, api) => {
// Define your allowlist of emails
const allowlist = [
(List of allowed emails)
];
// Check if the user's email is in the allowlist
if (!event.user.email || !allowlist.includes(event.user.email)) {
// If the email is not in the allowlist, deny access
const msg = 'Access denied: Your email is not in the allowlist.'
api.access.deny(msg, msg);
}
api.user.setUserMetadata("role", "admin")
};
Post-registration action (Auth0):
exports.onExecutePostLogin = async (event, api) => {
const role = event.user.user_metadata["role"]
api.samlResponse.setAttribute("role", role)
};
Link from the NextJS app:
<a href="<domain name from the Mapbox application>/authorize?response_type=code&client_id=<client id from the Mapbox application>redirect_uri=<Mapbox-provided Single Sign-on URL>">
Click here to redirect to SSO for MapBox
</a>
Note: In the “Application URIs” section of the Mapbox application settings, I set these two values:
Like it? Share it!