bambamboole / laravel-oidc-mautic
Mautic plugin that signs users in through any OpenID Connect provider, with claim-based access restrictions and role mapping
Package info
github.com/bambamboole/laravel-oidc-mautic
Type:mautic-plugin
pkg:composer/bambamboole/laravel-oidc-mautic
Requires
- php: ^8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.2
- mautic/core-lib: ^7.0
Requires (Dev)
- laravel/pint: ^1.16
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
README
A Mautic 7 plugin that signs users in through any OpenID Connect provider — such as an app running
bambamboole/laravel-oidc — and decides who may enter by
looking at the claims the provider returns.
- Authorization code flow with PKCE and
state, endpoints resolved from the issuer's discovery document. - Users are matched by username (the
emailclaim by default); optionally created on first login. - Required claims gate every login: each configured
claim=valueline must match the userinfo response. - Role mapping translates a provider role claim into a Mautic role; unmatched new users get the default role.
Install
composer require bambamboole/laravel-oidc-mautic php bin/console cache:clear php bin/console mautic:plugins:reload
Without Composer, copy this directory to docroot/plugins/LaravelOidcBundle and run the same two commands.
Configure
- Register a confidential client at your provider with the redirect URI
https://<mautic-host>/s/sso_login_check/LaravelOidc. - In Mautic go to Settings → Plugins → OpenID Connect, publish the plugin, and enter the issuer URL
(the one that serves
/.well-known/openid-configuration), client ID, and client secret. Under Features, choose whether unknown users are created automatically and which role they receive. - In Settings → Configuration → OpenID Connect, adjust scopes, claim-to-field mapping, the required claims, and the role mapping.
The login page then shows a Sign in with OpenID Connect button next to the password form.
Required claims
One rule per line; all rules must hold. A claim name may use dots to reach nested values.
roles=Super Admin # list claims match when they contain the value
email_verified # a bare claim requires the boolean true
hd=example.com # scalar claims must be equal
Users whose claims do not satisfy every rule are rejected with a message naming the unmet rules, even when they already exist in Mautic.
Role mapping
Set the role claim (for example roles) and map its values to Mautic role IDs:
Super Admin => 1
Support => 2
The first matching line wins. Existing users keep their role when nothing matches.
Notes
- The plugin trusts the userinfo endpoint reached with the freshly issued access token over TLS; it does not validate the ID token signature itself.
- Mautic requires a first and last name: when the provider sends neither
given_name/family_namenor anameclaim, the local part of the username is used for both.