website/integrations/chat-communication-collaboration/mautic/index.md
Mautic provides free and open source marketing automation software available to everyone. Free email marketing and lead management software.
The following placeholders are used in this guide:
mautic.company is the FQDN of the Mautic installation.authentik.company is the FQDN of the authentik installation.mautic-provider is the SAML provider whose settings will be imported into Mautic.:::info This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application. :::
:::warning
Mautic and authentik both require X.509 certificates.
However, Mautic specifically requires the key to contain the phrase RSA or ENCRYPTED in its header.
See Troubleshooting if the following error occurs in Mautic:
Private key is invalid. It should begin with
-----BEGIN RSA PRIVATE KEY-----or-----BEGIN ENCRYPTED PRIVATE KEY-----
:::
To support the integration of Mautic with authentik, you need to create property mappings and an application/provider pair in authentik.
Because Mautic requires a first name and last name attribute, create two SAML provider property mappings:
SAML-FirstName-from-NameFirstNamenames = request.user.name.split(" ", 1)
if (len(names) == 1):
return ""
return names[0]
SAML-LastName-from-NameLastNamereturn request.user.name.split(" ", 1)[-1]
mautic-providerhttps://mautic.company/s/saml/login_checkmautic.companyPostmautic-provider.
mautic-provider\_authentik_meta.xml.:::info
When running behind an SSL-terminating reverse proxy (e.g. traefik): In Configuration > System Settings, make sure that:
https://:::
In Configuration > User/Authentication Settings, set the following values:
https://mautic.companymautic-provider\_authentik_meta.xml filehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress (as per provider > preview in authentik)http://schemas.goauthentik.io/2021/02/saml/username (as per provider > preview in authentik)FirstName (as per Provider > Preview in authentik)LastName (as per Provider > Preview in authentik)certificate.crt fileprivate_key.pem file
Click on Save.To confirm that authentik is properly configured with Mautic, open a new incognito/private window or another browser and login at mautic.company.
By using an incognito/private window or other browser, you can still access the configuration interface of Mautic if anything went wrong.
Uncaught PHP Exception TypeErrormautic.CRITICAL: Uncaught PHP Exception TypeError: "Mautic\UserBundle\Entity\User::getUserIdentifier(): Return value must be of type string, null returned" at /app/bundles/UserBundle/Entity/User.php line 335 {"exception":"[object] (TypeError(code: 0): Mautic\\UserBundle\\Entity\\User::getUserIdentifier(): Return value must be of type string, null returned at /app/bundles/UserBundle/Entity/User.php:335)"}
This message in Mautic's System Info > Log in with an error 500 on its login page indicates a problem with the mapping of the attributes. (See Mautic configuration > Email/Username/First Name/Last Name or Create property mappings > Step 2 or Create an application and provider in authentik > Step 2.)
Unable to verify Signature
This error occurs when logging in, and indicates that the certificate does not match the private key.
(E.g. when the certificate was generated without the RSA and only the private key was changed afterwards.)
Assertions must be signed
This error occurs when logging in, and indicates that the Sign assertions and Sign responses settings were not checked in authentik. (See Create an application and provider in authentik > Step 2.)
Private key is invalid. It should begin with
-----BEGIN RSA PRIVATE KEY-----or-----BEGIN ENCRYPTED PRIVATE KEY-----
The private key does not provide the header and footer which Mautic expects.
(E.g., Mautic requires the phrases RSA or ENCRYPTED in the header and footer.)
To fix this, a new certificate must be generated.
Therefore, follow these steps (where the placeholder Mautic Self-signed Certificate is used for the new certificate):
To avoid changing certificates in authentik, go to the authentik Admin interface and generate a new one:
Go to System > Certificates and click on Generate. Use the following values:
Mautic Self-signed CertificateRSAClick the caret (>) next to the newly generated certificate, then select Download certificate to get the Mautic Self-signed Certificate\_certificate.pem file and Download Private key to get the Mautic Self-signed Certificate\_private_key.pem file.
Make sure that the Mautic Self-signed Certificate\_private_key.pem is in PKCS#1 format.
To verify, use grep to check for RSA in the header and footer of the file:
grep "RSA PRIVATE KEY" "Mautic Self-signed Certificate_private_key.pem"
If the command returns the correct match (e.g., -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----), the key is in PKCS#1 format, and you can skip steps 4 to 6.
If the key is not in PKCS#1 format, add RSA after BEGIN and END in Mautic Self-signed Certificate\_private_key.pem as shown below and save the file as private_key_new.pem:
- -----BEGIN PRIVATE KEY-----
+ -----BEGIN RSA PRIVATE KEY-----
and
- -----END PRIVATE KEY-----
+ -----END RSA PRIVATE KEY-----
Regenerate the X.509-certificate by first creating a signing request, using the following command:
openssl req -new -key private_key_new.pem -out request.csr
This will prompt you to enter values for the certificate which you can choose freely. For some, you can use authentik's generated values:
authentikSelf-signedMautic Self-signed CertificateNext, generate the certificate with the (now) PKCS#1-compliant key and the previously generated signing request using the following command:
openssl x509 -req -days 365 -in request.csr -signkey private_key_new.pem -out certificate_new.pem
In authentik, navigate to System > Certificates and click Edit on the previously generated certificate. Click on the description below the text inputs to activate the inputs.
certificate_new.pem or, if steps 4 to 6 were skipped, Mautic Self-signed Certificate\_certificate.pemprivate_key_new.pem or, if steps 4 to 6 were skipped, Mautic Self-signed Certificate\_private_key.pemNavigate to Applications > Providers and Edit mautic-provider (which was created in Create an application and provider in authentik).
In Advanced protocol settings, change Signing Certificate to Mautic Self-signed Certificate
Save the provider, view it, and download the metadata file to mautic-provider\_authentik_meta.xml
In Mautic, navigate to Configuration > User/Authentication Settings and set the following values:
certificate_new.crt fileprivate_key_new.pem filemautic-provider\_authentik_meta.xml file