Squadbase
Squadbase Docs

User Authentication

With Squadbase’s built-in authentication, you can enable user sign-in, management, and role-based access control—without writing any code.

Squadbase provides built-in authentication so that you can handle user sign-in, management, and role-based access control without adding code. For apps whose visibility is not set to Public, only members added to the Squadbase team and invited to the project can access the application.

Adding members

To give someone access to an app deployed on Squadbase, follow these steps:

  1. From the dashboard Settings page, invite the member to your Team.
  2. The member accepts the invitation and joins the team.
  3. From the Project settings page, add the member to the project and assign a project role.

Managing member permissions

Squadbase offers two scopes of roles:

  • Team roles – govern actions at the team level.
  • Project roles – govern actions within a specific project.

Configuring team roles

Team roles are managed from the dashboard’s Settings page. Available roles:

  • Admin – Can change settings for any project.
  • Developer – Can create new projects, invite team members, and change project settings.
  • Contributor – Can deploy to projects they’ve been invited to.
  • Viewer – Can view projects they’ve been invited to.

Configuring project roles

Project roles are managed in the Settings tab of each project’s dashboard page.

Project role

You can use any string you like for a project role. In code, you can access the assigned roles like this:

import streamlit as st
import squadbase.streamlit as sq
 
user_info = sq.auth.get_user()
st.write(f"Hello, {user_info['firstName']} {user_info['lastName']}")
 
if "admin" in user_info['roles']:
  st.write("You are an admin")
else:
  st.write("You are not an admin")

Important: Retrieving user information only works after the app has been deployed to Squadbase.

For local development, provide mock data:

import streamlit as st
import squadbase.streamlit as sq
 
mock_user_data = {
    "username": "testuser",
    "firstName": "Test",
    "lastName": "User",
    "iconUrl": None,
    "email": "test@example.com",
    "roles": ["admin"]
}
 
user_info = sq.auth.get_user(mock_data=mock_user_data)
st.write(f"Hello, {user_info['firstName']} {user_info['lastName']}")
if "admin" in user_info['roles']:
  st.write("You are an admin")
else:
  st.write("You are not an admin")

For details on the authentication API, see REST API. SDKs are also available for each framework:

pypi.org

Streamlit Squadbase SDK

SDK for retrieving Squadbase auth data in Streamlit.

@squadbase/nextjs

npm

Next.js Squadbase SDK

SDK for retrieving Squadbase auth data in Next.js.

@squadbase/server

npm

JavaScript Server SDK

SDK for retrieving Squadbase auth data in JavaScript.

On this page