Authentication
This project implements secure and flexible authentication practices for both traditional and OpenID Connect (OIDC) Single Sign-On (SSO) workflows. The backend integrates the excellent Django-AllAuth package to handle user registration, login, password management, and third-party authentication providers.
Authentication Method¶
All API endpoints in Onconova require a valid, authenticated user session. Authentication is managed via a session token, which must be included in the X-SESSION-TOKEN
HTTP header for every request.
A session token is issued by Django-AllAuth upon successful user authentication, whether through traditional username/email+password sign-in or supported Single Sign-On (SSO) providers. Requests that lack a valid session token, or include an expired or invalid token, will receive a 401 Unauthorized
HTTP response.
Authorized users only
Onconova does not support anonymous or unauthenticated API access.
How to Authenticate¶
-
Obtain a session token by logging in through the web interface or by using the API login endpoint:
Example JSON body:
Example response:
-
Include the
sessionToken
value in theX-SESSION-TOKEN
header in your subsequent API requests.Example Request with Token:
-
Provide your credentials to your provider's OIDC authorization endpoint and follow their OIDC flow to obtain either an
id_token
oraccess_token
value. Example request:Example response:
-
Obtain a session token by providing the
id_token
oraccess_token
value, as well as other provider details, to the Onconova API interface:Example JSON body:
{ "provider": "google", "token": { "client_id": "123.apps.googleusercontent.com", "id_token": "apJ2eXA52OivGlaKV1QiLC...", "access_token": "..." } }
Example response:
-
Include the
sessionToken
value in theX-SESSION-TOKEN
header in your subsequent API requests.Example Request with Token:
Token Expiration
Tokens are valid for a limited period or until manually revoked. After the expriration period, users must authenticate again to retrieve a new token.
Security Considerations
- Always keep your session tokens secure.
- Never expose API credentials or tokens in public code repositories.
- Use HTTPS connections for all API calls. HTTP connections will be redirected to HTTPS by default.
SSO through Identity Providers¶
The project currently supports the following OIDC identity providers:
- Microsoft
Both are integrated using Django-AllAuth’s social account providers. To enable SSO with a specific identity provider, the Onconova application must first be registered with the provider to define access permissions, data scope, and user consent options. Upon successful registration, the provider will issue an Application (client) ID and a Client Secret. These credentials, along with any additional provider-specific configuration parameters, are required by Onconova to establish and manage the OIDC authentication workflow.
Supported OIDC Flows
The Onconova client currently supports OIDC authentication using ID tokens and Access tokens. The Authorization Code flow (involving the exchange of authorization codes) is not supported.
Client-only
OIDC authentication is enabled exclusively for client-side authentication in Onconova. API requests must be authenticated either via a traditional login or with an OIDC access token. Importantly, no provider credentials are uploaded to or stored within the Onconova server, identity verification is handled entirely through the client’s interaction with the identity provider.
Google¶
To enable Google SSO:
-
Go to your organization's Google Cloud Console and navigate to the APIs and services page.
-
Create an new OAuth 2.0 Client ID
- Under Application type select Web application.
- Add your Onconova domain to Authorised JavaScript origins.
- Add the Onconova
/auth/callback
URL under Authorized redirect URLs: - Create a Client Secret.
-
Assign the Google Client ID to the
ONCONOVA_GOOGLE_CLIENT_ID
variable and the Client Secret to theONCONOVA_GOOGLE_SECRET
variable in the.env
file.
Microsoft¶
To enable Microsoft SSO through ID tokens:
-
Go to your organization's Microsoft Entra admin center and navigate to the APIs and services page.
-
Browse to Entra ID > App registrations > Onconova > Authentication.
-
Under Platform configurations, select Add a platform. In the pane that opens, select Web for a web application.
-
Under Redirect URIs, add the Onconova
/auth/callback
redirect URL: -
Under Implicit grant and hybrid flows, select the ID tokens checkbox.
-
Assign the Microsoft Client ID to the
ONCONOVA_MICROSOFT_CLIENT_ID
variable, the Client Secret to theONCONOVA_MICROSOFT_SECRET
variable, and the Tenant ID to theONCONOVA_MICROSOFT_TENANT_ID
variable in the.env
file.
Further reading¶
- Django-AllAuth homepage
- OpenID Connect on Google Cloud
- OpenID Connect on the Microsoft identity platform