This documentation explains the main mechanism of authentication.


Main host mechanisms are located in apps.auth. Login is internally based on a token authentication: each user session is associated to a token.

There is a common access point, auth which can be used to log out, but to log in, each authentication mechanism use its own endpoint (auth_db and auth_xmpp so far). This way each endpoint can use its own schema validation while the common endpoint can be called for logout, allowing several auth mechanisms to be running at the same time.

title Authentication in Superdesk

boundary client
control "auth_**XXX**" as backend
note right of backend
    auth_**XXX** service uses __auth__ datasource
end note
database datalayer

backend <- client : **authenticate**\n(user credentials)

alt success
    backend -> backend: //create token//
    backend -> datalayer: //create session//
    backend -> client: **user**\n(user name, token, user id)

else bad credentials or failure
    backend -> client: HTTP error\n(401 or something else)


Adding a new authentication mechanism

Adding a new authentication mechanism is done by creating a new endpoint extending the basic service. The new endpoint should be named auth_XXX where XXX is a short name for the new mechanism.

The auth module provide the base features, with main service.

class apps.auth.service.AuthService(datasource=None, backend=None)

Authenticate user according to credentials

Parameters:documents – credentials for this authentication mechanism
Returns:authenticated user
Raise:CredentialsAuthError if authentication is invalid

Runs on delete of a session

Parameters:doc – A deleted auth doc AKA a session

Update current session with given data.

Parameters:updates – updates to be made

To implement its authentication mechanism, a module need to override the authenticate method.

When creating a service based on AuthService, the authentication module must use the auth datasource instead of its own endpoint name. This allow several auth methods to use the same session system and to logout from auth common endpoint.

Special case: auth_db

auth_db is used for the basic database login/password authentication. In some cases it may be desirable to replace this mechanism (e.g. this is the case with LDAP). This is done by using the same endpoint name, and avoiding the import of apps.auth.db module. The login/pass default login interface in the client will then stay unchanged.

Other uses of apps.auth

Following functions can be used:


Get authenticated session data.


Get user authenticated for current request.

Parameters:required (boolean) – if True and there is no user it will raise an error

Get authenticated user id.

Parameters:required (boolean) – if True and there is no user it will raise an error

Test if current user is administrator.

Parameters:required – raise an error if required and there is no user context

Superdesk OAuth

Superdesk OAuth support

New in version 1.9.

There is oauth resource for authenticating users by email. Email must be provided by trusted identity service, eg. Google.

The authentication flow with js client is:

  • Client opens server api url in a new window,.
  • There is a redirect to auth provider (eg. Google).
  • Once authenticated user is redirected back to server api url.
  • There user email from auth provider is used to authenticate user.
  • Template is rendered with session data which sends message to parent window and popup is closed.

Authenticate user via email.

This will create new session for user and render template with session data which is used by client to setup authentication.

Parameters:email – user email address

Superdesk Google OAuth

Superdesk Google Authentication

New in version 1.8.

You can use Google for authentication, first you have to create credentials in Google API console:

  • set your client URL as Authorized JavaScript origins:
  • set server URL + /api/login/google_authorized as Authorized redirect URIs:

Once configured you will find there Client ID and Client secret, use both to populate Google OAuth Settings.

Changed in version 1.9: There is no need to configure client, it reads config from server now.

Changed in version 1.9: Login url is /api/login/google_authorized instead of /login/google_authorized.

Superdesk SAML Auth