SAML Authentication
Available in Overleaf Extended CE is the ability to use a SAML server to manage users. The information in this page is valid for both Overleaf Toolkit Users and legacy docker-compose.yml users.
Configuration
Internally, Overleaf SAML module uses the passport-saml library, most of the following configuration options are passed through to passport-saml. If you are having issues configuring SAML, it is worth reading the README for passport-saml to get a feel for the configuration it expects.
The environment variable EXTERNAL_AUTH is required to enable the SAML authentication module. This environment variable specifies which external authentication methods are activated. The value of this variable is a list. If the list includes saml then SAML authentication will be activated.
For example: EXTERNAL_AUTH=ldap saml
When using the SAML authentication method, a user is redirected to the Identity Provider (IdP) authentication site. If the IdP successfully authenticates the user, the Overleaf users database is checked for a record containing a samlIdentifiers field structured as follows:
samlIdentifiers: [
{
externalUserId: "...",
providerId: "1",
userIdAttribute: "..."
}
]The externalUserId must match the value of the property specified by userIdAttribute in the user profile returned by the IdP server.
If no matching record is found, the database is searched for a user with the primary email address matching the email in the IdP user profile:
If such a user is found, the
hashedPasswordfield is deleted to disable local authentication, and thesamlIdentifiersfield is added.If no matching user is found, a new user is created with the email address and
samlIdentifiersfrom the IdP profile.
Note: Currently, only one SAML IdP is supported. The providerId field in samlIdentifiers is fixed to '1'.
Environment Variables
OVERLEAF_SAML_IDENTITY_SERVICE_NAMEDisplay name for the identity service, used on the login page (default:
Log in with SAML IdP).
OVERLEAF_SAML_USER_ID_FIELDThe value of this attribute will be used by Overleaf as the external user ID, defaults to
nameID.
OVERLEAF_SAML_EMAIL_FIELDName of the Email field in user profile, defaults to
nameID.
OVERLEAF_SAML_FIRST_NAME_FIELDName of the firstName field in user profile, defaults to
givenName.
OVERLEAF_SAML_LAST_NAME_FIELDName of the lastName field in user profile, defaults to
lastName
OVERLEAF_SAML_UPDATE_USER_DETAILS_ON_LOGINIf set to
true, updates the userfirst_nameandlast_namefield on login, and turn off the user details form on/user/settingspage.
OVERLEAF_SAML_ENTRYPOINT(required)Entrypoint URL for the SAML identity service.
Example:
https://idp.example.com/simplesaml/saml2/idp/SSOService.phpAzure Example:
https://login.microsoftonline.com/8b26b46a-6dd3-45c7-a104-f883f4db1f6b/saml2
OVERLEAF_SAML_ISSUER(required)The Issuer name.
OVERLEAF_SAML_AUDIENCEExpected saml response Audience, defaults to value of
OVERLEAF_SAML_ISSUER.
OVERLEAF_SAML_IDP_CERT(required)Path to a file containing the Identity Provider's public certificate, used to validate the signatures of incoming SAML responses. If the Identity Provider has multiple valid signing certificates, then it can be a JSON array of paths to the certificates.
Example (one certificate):
/var/lib/overleaf/certs/idp_cert.pemExample (multiple certificates):
["var/lib/overleaf/certs/idp_cert.pem", "/var/lib/overleaf/certs/idp_cert_old.pem"]
OVERLEAF_SAML_PUBLIC_CERTPath to a file containing public signing certificate used to embed in auth requests in order for the IdP to validate the signatures of the incoming SAML Request. It's required when setting up the metadata endpoint when the strategy is configured with a
OVERLEAF_SAML_PRIVATE_KEY. A JSON array of paths to certificates can be provided to support certificate rotation. When supplying an array of certificates, the first entry in the array should match the currentOVERLEAF_SAML_PRIVATE_KEY. Additional entries in the array can be used to publish upcoming certificates to IdPs before changing theOVERLEAF_SAML_PRIVATE_KEY.
OVERLEAF_SAML_PRIVATE_KEYPath to a file containing a PEM-formatted private key matching the
OVERLEAF_SAML_PUBLIC_CERTused to sign auth requests sent by passport-saml.
OVERLEAF_SAML_DECRYPTION_CERTPath to a file containing public certificate, used for the metadata endpoint.
OVERLEAF_SAML_DECRYPTION_PVKPath to a file containing private key matching the
OVERLEAF_SAML_DECRYPTION_CERTthat will be used to attempt to decrypt any encrypted assertions that are received.
OVERLEAF_SAML_SIGNATURE_ALGORITHMOptionally set the signature algorithm for signing requests, valid values are 'sha1' (default), 'sha256' (prefered), 'sha512' (most secure, check if your IdP supports it).
OVERLEAF_SAML_ADDITIONAL_PARAMSJSON dictionary of additional query params to add to all requests.
OVERLEAF_SAML_ADDITIONAL_AUTHORIZE_PARAMSJSON dictionary of additional query params to add to 'authorize' requests.
Example:
{"some_key": "some_value"}
OVERLEAF_SAML_IDENTIFIER_FORMATName identifier format to request from the identity provider (default:
urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress). If usingurn:oasis:names:tc:SAML:2.0:nameid-format:persistent, ensure theOVERLEAF_SAML_EMAIL_FIELDenvirionment variable is defined. Ifurn:oasis:names:tc:SAML:2.0:nameid-format:transientis required, you must also define theOVERLEAF_SAML_ID_FIELDenvironment variable, which can, for example, be set to the user's email address.
OVERLEAF_SAML_ACCEPTED_CLOCK_SKEW_MSTime in milliseconds of skew that is acceptable between client and server when checking OnBefore and NotOnOrAfter assertion condition validity timestamps. Setting to -1 will disable checking these conditions entirely. Default is 0.
OVERLEAF_SAML_ATTRIBUTE_CONSUMING_SERVICE_INDEXAttributeConsumingServiceIndexattribute to add to AuthnRequest to instruct the IdP which attribute set to attach to the response (link).
OVERLEAF_SAML_AUTHN_CONTEXTJSON array of name identifier format values to request auth context. Default:
["urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"].
OVERLEAF_SAML_FORCE_AUTHNIf
true, the initial SAML request from the service provider specifies that the IdP should force re-authentication of the user, even if they possess a valid session.
OVERLEAF_SAML_DISABLE_REQUESTED_AUTHN_CONTEXTIf
true, do not request a specific auth context. For example, you can this this totrueto allow additional contexts such as password-less logins (urn:oasis:names:tc:SAML:2.0:ac:classes:X509). Support for additional contexts is dependant on your IdP.
OVERLEAF_SAML_AUTHN_REQUEST_BINDINGIf set to
HTTP-POST, will request authentication from IdP via HTTP POST binding, otherwise defaults to HTTP-Redirect.
OVERLEAF_SAML_VALIDATE_IN_RESPONSE_TOIf
always, then InResponseTo will be validated from incoming SAML responses.If
never, then InResponseTo won't be validated (default).If
ifPresent, then InResponseTo will only be validated if present in the incoming SAML response.
OVERLEAF_SAML_WANT_ASSERTIONS_SIGNEDandOVERLEAF_SAML_WANT_AUTHN_RESPONSE_SIGNEDWhen set to
true(default), Overleaf expects the SAML Assertions, respectively the entire SAML Authentication Response, to be signed by the IdP. When both options arefalse, at least one of the assertions or the response must be signed.
OVERLEAF_SAML_REQUEST_ID_EXPIRATION_PERIOD_MSDefines the expiration time when a Request ID generated for a SAML request will not be valid if seen in a SAML response in the
InResponseTofield. Default: 28800000 (8 hours).
OVERLEAF_SAML_LOGOUT_URLbase address to call with logout requests (default:
entryPoint).Example:
https://idp.example.com/simplesaml/saml2/idp/SingleLogoutService.php
OVERLEAF_SAML_ADDITIONAL_LOGOUT_PARAMSJSON dictionary of additional query params to add to 'logout' requests.
OVERLEAF_SAML_IS_ADMIN_FIELDandOVERLEAF_SAML_IS_ADMIN_FIELD_VALUEWhen both environment variables are set, the login process updates
user.isAdmin = trueif the profile returned by the SAML IdP contains the attribute specified byOVERLEAF_SAML_IS_ADMIN_FIELDand its value either matchesOVERLEAF_SAML_IS_ADMIN_FIELD_VALUEor is an array containingOVERLEAF_SAML_IS_ADMIN_FIELD_VALUE, otherwiseuser.isAdminis set tofalse. If either of these variables is not set, then the admin status is only set totrueduring admin user creation in Launchpad.
Metadata for the Identity Provider
The current version of Overleaf CE includes and endpoint to retrieve Service Provider Metadata: http://my-overleaf-instance.com/saml/meta
The Identity Provider will need to be configured to recognize the Overleaf server as a "Service Provider". Consult the documentation for your SAML server for instructions on how to do this.
Below is an example of appropriate Service Provider metadata:
Note the certificates, AssertionConsumerService.Location, SingleLogoutService.Location and EntityDescriptor.entityID and set as appropriate in your IdP configuration, or send the metadata file to the IdP admin.
Last updated
Was this helpful?