Skip to main content

Team membership from SSO

Team membership from SSO keeps Spanway teams in step with your directory. When a user signs in to the Admin UI with SSO, the identity provider can send the groups they belong to. The gateway reads those groups as team ids and adds the user to every matching team they are not yet a member of, so nobody has to open the Teams page to add them. The same mapping applies to the CLI sign-in and to JWT authenticated API calls.

Team membership from SSO groups is part of the free gateway, within the SSO user limit described in Admin UI SSO. The JWT path needs the license that JWT auth needs.

A real-world scenario​

A company has a data-science group and a platform group in its identity provider and two Spanway teams with the same ids, each with its own budget and models. When a new analyst joins the data-science group and signs in to the Admin UI for the first time, they should land in the data science team with its budget, and nobody should have to add them by hand.

Steps​

  1. Make sure the identity provider sends a groups claim. For the generic OIDC provider, request it with GENERIC_SCOPE="openid email profile groups" as described in Admin UI SSO.

  2. Create the teams with the ids the claim carries. In the Admin UI open Teams and create data-science and platform, or call POST /team/new. A group that names no team is ignored at sign-in.

  3. Tell the gateway which claim holds the groups. In the Admin UI open Settings, Admin Settings, the SSO Settings tab, choose Edit SSO Settings, turn on Use Team Mappings and set Team IDs JWT Field to groups, then Save. The change takes effect without a restart. The same change through the API:

    curl -s -X PATCH http://localhost:4000/update/sso_settings \
    -H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
    -d '{"team_mappings": {"team_ids_jwt_field": "groups"}}'

    The call changes only team_mappings. Every other SSO setting, the client id and secret included, keeps its stored value.

    Or set it in config.yaml, which also covers JWT authenticated API calls:

    general_settings:
    enable_jwt_auth: true
    spanway_jwtauth:
    team_ids_jwt_field: groups
    upsert_sso_user_to_team: true
  4. Ask the analyst to sign in to the Admin UI.

Expected result​

The analyst signs in and lands in the Admin UI as a member of data-science. On the Teams page they are listed as a member, their keys can use the team's models, and their spend counts against the team budget. GET /get/sso_settings shows "team_mappings": {"team_ids_jwt_field": "groups"} under values together with the provenance of each value.

team_ids_jwt_field supports dot notation for nested claims such as realm_access.roles. The values must be team ids that already exist. Adding the user to a group that names no team fails quietly and is only written to the debug log.

MethodPathSummary
GET/get/sso_settingsRead the Admin UI single sign-on configuration
PATCH/update/sso_settingsStore the Admin UI single sign-on configuration

Restrict the UI to one group​

ui_access_mode can require membership of a specific group for anyone signing in to the Admin UI.

general_settings:
ui_access_mode:
type: restricted_sso_group
restricted_sso_group: gateway-users
sso_group_jwt_field: groups

A user whose token does not list gateway-users in the groups claim is refused at sign-in. The simpler forms ui_access_mode: admin_only and ui_access_mode: all are described in Admin UI.

What is synchronised​

Sign-in adds missing team memberships but does not remove existing ones. For provisioning that also removes users and memberships when they leave a group, use SCIM. On JWT authenticated API calls, sync_user_role_and_teams: true together with jwt_spanway_role_map keeps the user's role and teams aligned with the token on every request.

Errors​

What you seeWhyFix
The user signs in but joins no team.The claim name is wrong, the provider did not send groups, or the group values are not team ids.Check the claim name in the SSO settings, request the groups scope, and compare the group values with the team ids on the Teams page.
500 Database not connected from /update/sso_settings.The gateway has no database.Connect a database. Without one, set the field in config.yaml.
500 saying to set STORE_MODEL_IN_DB.Settings cannot be stored because store_model_in_db is off.Set general_settings.store_model_in_db: true or STORE_MODEL_IN_DB=True.
403 User is not in the restricted SSO group: <group>.ui_access_mode is restricted_sso_group and the token does not list the group.Add the user to the group, or check sso_group_jwt_field names the claim the provider sends.
403 You must be a Spanway Enterprise user to use SSO for more than 5 users. ...Without a license, once the gateway holds more than 5 active users every SSO sign-in is refused, existing users included.Set an enterprise license, see Admin UI SSO.
A member who left the group is still in the team.Sign-in never removes memberships.Use SCIM for removals, or remove them on the Teams page.

Logs​

LevelLineMeaningAction
INFOSSO jwt_spanway_role_map matched role: <role>A sign-in mapped the person's groups to a role.None. The role change, if any, is in the audit log.