This document formally defines the token scope specification for Sourcegraph Accounts Management System (SAMS) :

  1. Components of a token scope, i.e. how do token scopes look?
  2. Token scope matching strategy, i.e. how authorization works?

These scopes are used for user access tokens, as well as SAMS Machine-to-machine (M2M) Authentication and Authorization.

Basic format

A scope is always consists of three parts: service, permission hierarchy, and action, and are separated by double colons ::, e.g. sams::user.roles::read, ssc::subscriptions::read:

  1. The total length of a scope cannot exceed 255 characters.
  2. Service: the slug of the service name, up to 30 characters.
  3. Permission hierarchy: the hierarchy of the permissions under the given service, up to 215 characters.
  4. Action: the allowed action for the given permission of the given service, up to 10 characters.

Scope alias

This is initially intended for making OIDC scopes be compatible with our design (profile -> sams::user.profile::read), but could also be a useful extension in the future, e.g. in the event of scope renaming efforts.

References