SimpleSAMLphp WordpressAuth
An authentication module for SimpleSAMLphp that uses the WordPress user database as its source: WordPress becomes a SAML 2.0 identity provider, including the password formats up to WordPress 6.8.
Since
2023
Licence
GPL-2.0
Technologies
The Challenge
Many organisations already have their users in WordPress but want them to sign in to other applications via SAML as well. WordPress itself is not an identity provider, and a second user directory would mean duplicate accounts and passwords.
The Solution
The module is an authentication source for SimpleSAMLphp that reads the WordPress database directly. SimpleSAMLphp handles the SAML side, WordPress remains the only user directory, and nothing has to change in WordPress itself.
How it works
Sign-in
Username or e-mail address with the WordPress password; the module builds on SimpleSAMLphp's UserPassBase class.
Password check
phpass hashes, bcrypt and the format from WordPress 6.8, where the password is pre-hashed with HMAC-SHA384 and then hashed with bcrypt. Unknown formats are rejected.
Attributes
uid, username, e-mail and display name, plus first and last name, profile photo and scopes from the user metadata of common plugins.
Database
The connection goes through PDO with the credentials from the SimpleSAMLphp configuration. The WordPress table prefix is detected automatically. All user input goes into the queries through prepared statements. The module is written for MySQL and MariaDB.
Demo application
A small service provider application in the repository shows the flow: sign in, view the delivered attributes styled or raw, sign out. Output is escaped there.
Use and licence
The prerequisites are SimpleSAMLphp and read access to the WordPress database. The code is on GitHub under the GPL-2.0, like WordPress itself.
Privacy
The module only reads, writes nothing to the WordPress database and passes only the configured attributes to the connected service providers.
Results
WordPress becomes the central sign-in for other applications, without a second user directory and with support for the current password formats.
Gallery
Images from the project's GitHub repository.