md_saml
Single Sign-on extension for TYPO3. It enables you, to log into the TYPO3 backend or the website frontend by using an Identity Provider (IdP), for example an ADFS server (Active Directory Federation Services). It is fully configurable by TypoScript.
TYPO3 login:
Frontend login:
composer req mediadreams/md_saml
or use the extension managerThe Service Provider (SP) and Identity Provider (IdP) can be configured by adapting the settings in TypoScript.
ext:md_saml/Configuration/TypoScript/setup.typoscript
to your
own extension and modify according your needs.openssl req -newkey rsa:3072 -new -x509 -days 3652 -nodes -out sp.crt -keyout sp.key
sp.crt
to
plugin.tx_mdsaml.settings.saml.sp.x509cert
and value of sp.key
to plugin.tx_mdsaml.settings.saml.sp.privateKey
Backend
plugin.tx_mdsaml.settings.be_users.saml.sp.entityId
baseurl
will be attached automatically/typo3/index.php?loginProvider=1648123062&mdsamlmetadata
plugin.tx_mdsaml.settings.be_users.saml.sp.assertionConsumerService.url
/typo3/index.php?loginProvider=1648123062&login-provider=md_saml&login_status=login&acs
saml.sp.assertionConsumerService.auto
Frontend
plugin.tx_mdsaml.settings.fe_users.active = 1
plugin.tx_mdsaml.settings.fe_users.saml.sp.entityId
baseurl
will be attached automatically/login/?loginProvider=1648123062&mdsamlmetadata
plugin.tx_mdsaml.settings.fe_users.saml.sp.assertionConsumerService.url
/login/?loginProvider=1648123062&login-provider=md_saml&login_status=login&acs&logintype=login
Note
All default settings, which are configured in plugin.tx_mdsaml.settings.saml
can be overwritten for backend or
frontend needs with properties in plugin.tx_mdsaml.settings.be_users.saml...
(backend) and
plugin.tx_mdsaml.settings.fe_users.saml...
(frontend).
As underlying SAML toolkit the library of OneLogin is used (no account with OneLogin is needed!). See full documentation for details on the configuration.
You are able to create new users, if they are not present at the time of login.
plugin.tx_mdsaml.settings.be_users.createIfNotExist
...plugin.tx_mdsaml.settings.fe_users.createIfNotExist
...You are able to update existing users, if they are already present at the time of login.
plugin.tx_mdsaml.settings.be_users.updateIfExist
...plugin.tx_mdsaml.settings.fe_users.updateIfExist
...Backend
plugin.tx_mdsaml.settings.be_users.createIfNotExist
plugin.tx_mdsaml.settings.be_users.updateIfExist
plugin.tx_mdsaml.settings.be_users.databaseDefaults
...plugin.tx_mdsaml.settings.be_users.databaseDefaults.usergroup = 123
will create a new user with usergroup 123 attached.Frontend
plugin.tx_mdsaml.settings.fe_users.createIfNotExist
plugin.tx_mdsaml.settings.fe_users.updateIfExist
plugin.tx_mdsaml.settings.fe_users.databaseDefaults
...plugin.tx_mdsaml.settings.fe_users.databaseDefaults.usergroup = 123
will create a new user with usergroup 123 attached.plugin.tx_mdsaml.settings.fe_users.databaseDefaults.pid
will be used as storage for newsly created fe_users.The returned value of the SSO provider can be anything. With the following configuration set the names of the returned values to the ones needed in TYPO3:
Backend
plugin.tx_mdsaml.settings.be_users.transformationArr
plugin.tx_mdsaml.be_users.settings.transformationArr.username = http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname
Frontend
plugin.tx_mdsaml.settings.fe_users.transformationArr
plugin.tx_mdsaml.settings.fe_users.transformationArr.username = http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname
The following steps are an example on how to configure an ADFS server as IdP (Identity Provider).
Since I don't have the configuration in english, the following section is available in german only. I am sorry for that!
Get SP (Service Provider) meta data. Log into TYPO3 (important!) and call /typo3/index.php?loginProvider=1648123062&mdsamlmetadata&loginType=backend
for the backend configuration and /typo3/index.php?loginProvider=1648123062&mdsamlmetadata&loginType=frontend
for the
frontend configuration.
Neue Vertrauensstellung der vertrauenden Seite
erstellen
Willkommen
Ansprüche unterstützen
auswählenStart
klickenDatenquelle auswählen
Daten über vertrauende Seite aus einer Datei importieren
auswählenWeiter
klickenAnzeigennamen angeben
Anzeige Name
eintragenWeiter
klickenZugriffssteuerungsrichtline auswählen
Wählen Sie eine Zugriffssteuerungsrichtlinie aus
, den Zugriff-OTP
auswählenWeiter
klickenBereit zum Hinzufügen der Vertrauensstellung
Weiter
klickenFertig stellen
Schließen
klickenDie Ansprucheaustellungsrichtlinie für diese Anwendung konfigurieren
prüfen
Neue Regel mit Regel hinzufügen ...
hinzufügen
Im Feld Anspruchsregelvorlage
die Option Ansprüche mithilfe einer benutzerdefinierten Regel senden
auswählen und Weiter
klicken
Im Feld Anspruchsregelname
den Wert Name Identifier
eingeben
Im Feld Benutzerdefinierte Regel
folgendes eingeben:
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname"] => issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer, Value = c.Value, ValueType = c.ValueType, Properties["http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/format"] = "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName");
Knopf Fertig stellen
klicken
Neue Regel hinzufügen mit klick auf Regel hinzufügen ...
Im Feld Anspruchsregelvorlage
den Wert Ansprüche mithilfe einer benutzerdefinierten Regel senden
auswählen und Weiter
klicken
Im Feld Anspruchsregelname
den Data Rule
eingeben
Im Feld Benutzerdefinierte Regel
folgendes eingeben:
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"] => issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname", "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", "distinguishedName", "memberOf"), query = ";mail,displayName,sn,sAMAccountName,distinguishedName,memberOf;{0}", param = c.Value);
Knopf Fertig stellen
klicken
Die Ansprucheaustellungsrichtlinie
mit OK
verlassen
ACHTUNG:
Die Reihenfolge der Regeln ist wichtig! Die erste muss die Name Identifier
Regel sein!
Als letztes muss noch im Reiter Bezeichner
der Vertrauensstellung
im Feld Bezeichner der vertrauenden Seite
der
Wert, der in plugin.tx_mdsaml.settings.mdsamlSpBaseUrl
eingegeben werden.
$GLOBALS['TYPO3_CONF_VARS']['BE']['cookieSameSite'] = 'lax'
errorHandling:
errorCode: 403
errorHandler: PHP
errorPhpClassFQCN: Mediadreams\MdSaml\Error\ForbiddenHandling
event to customize user data before insert/update on login
namespace XXX\XXX\EventListener;
use Mediadreams\MdSaml\Event\ChangeUserEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;
final class AddGroupChangeUserEventListener {
protected int $adminGroupUid = 3;
// SSO User Changes
public function __invoke(ChangeUserEvent $event): void
{
// get current data
$userData = $event->getUserData();
$email = $userData['email'] ?? null;
// some conditions, if true add group
if (1) {
$usergroups = GeneralUtility::intExplode(',', $userData['usergroup']);
$usergroups[] = $this->adminGroupUid;
// change some data
$userData['usergroup'] = implode(',', $usergroups);
// save new data
$event->setUserData($userData);
}
}
}
You must register the event listener in Services.yaml
unset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'][1433416747]);
If your login fails with the parameter ?commandLI=setCookie
(typo3/index.php?commandLI=setCookie), please make sure,
that you have set $GLOBALS['TYPO3_CONF_VARS']['BE']['cookieSameSite'] = 'lax'
.
If you find a bug, it would be nice if you add an issue on Github.
Thanks a lot to all who make this outstanding TYPO3 project possible!