digitalstate/platform-sso-linkedin-bundle
Install the Bundle Add the package via Composer:
composer require digitalstate/platform-sso-linkedin-bundle
Enable the bundle in config/bundles.php:
return [
// ...
DigitalState\PlatformSsoLinkedinBundle\DigitalStatePlatformSsoLinkedinBundle::class => ['all' => true],
];
Configure LinkedIn SSO
Navigate to System -> Configuration -> Integrations -> LinkedIn Settings in the OroPlatform admin panel.
https://your-app.com/linkedin/connect (adjust domain).r_liteprofile, email_address).First Use Case: Enable LinkedIn Login
System -> Users & Roles -> SSO Providers.linkedin.Initiate Login The bundle injects a "Login with LinkedIn" button on the login page (if configured).
ds_sso_linkedin.connect route.OAuth Handshake
authorization_code.Token Exchange & User Data Fetch
authorization_code for an access token (via LinkedIn\OAuth2\Client).id, email, firstName, lastName) using the access token.User Mapping
DsSSOBundle's user provider to map LinkedIn data to your platform’s user model.# config/packages/ds_sso_linkedin.yaml
ds_sso_linkedin:
user_provider:
property_mappings:
email: email
first_name: firstName
last_name: lastName
Post-Auth Redirect
/).Custom User Fields
Extend the user provider to map additional LinkedIn fields (e.g., profilePicture):
// src/Provider/CustomLinkedInUserProvider.php
namespace App\Provider;
use DigitalState\PlatformSsoLinkedinBundle\Provider\LinkedInUserProvider;
use Oro\Platform\Security\Authentication\UserProviderInterface;
class CustomLinkedInUserProvider extends LinkedInUserProvider
{
public function loadUserByLinkedInData(array $data)
{
$user = parent::loadUserByLinkedInData($data);
$user->setCustomField($data['pictureUrls']['narrow48']); // Example
return $user;
}
}
Register in config/packages/ds_sso_linkedin.yaml:
ds_sso_linkedin:
user_provider: App\Provider\CustomLinkedInUserProvider
Role Assignment Assign roles dynamically based on LinkedIn data (e.g., premium users):
ds_sso_linkedin:
role_assigner:
enabled: true
roles:
- 'ROLE_PREMIUM' # Assign if LinkedIn profile has a specific field
Error Handling
monolog:
$this->logger->error('LinkedIn OAuth failed', ['error' => $e->getMessage()]);
templates/ds_sso_linkedin/login.html.twig).Testing
$this->mock(OAuth2\Client::class)
->shouldReceive('getAccessToken')
->andReturn(new OAuth2\AccessToken(['access_token' => 'mock_token']));
Callback URL Mismatch
http/https).LinkedIn Settings).Auth tab).Token Expiry
ds_sso_linkedin:
token_refresh:
enabled: true
Scope Restrictions
r_emailaddress scope requires premium approval.r_liteprofile and prompt users to manually add their email.User Data Changes
Enable Debug Mode
Add to config/packages/dev/ds_sso_linkedin.yaml:
ds_sso_linkedin:
debug: true
var/log/dev.log.Common Errors
| Error | Cause | Solution |
|---|---|---|
invalid_client |
Wrong Client ID/Secret | Recheck LinkedIn Developer Portal |
redirect_uri_mismatch |
Callback URL mismatch | Update in both OroPlatform and LinkedIn |
insufficient_scope |
Missing required scopes | Add scopes in LinkedIn Settings |
user_not_found |
No matching user in your DB | Implement custom user provider |
Database Issues
sso_provider and sso_user tables exist (run migrations if needed):
php bin/console doctrine:migrations:execute
Custom User Provider
Override DigitalState\PlatformSsoLinkedinBundle\Provider\LinkedInUserProvider to:
headline to a custom user field.Pre/Post Auth Events
Listen to events in services.yaml:
services:
App\EventListener\LinkedInAuthListener:
tags:
- { name: kernel.event_listener, event: ds_sso_linkedin.pre_auth, method: onPreAuth }
- { name: kernel.event_listener, event: ds_sso_linkedin.post_auth, method: onPostAuth }
UI Customization
{# templates/ds_sso_linkedin/login_button.html.twig #}
<button class="your-custom-class">
{{ 'ds_sso_linkedin.login_with_linkedin'|trans }}
</button>
Webhook Integration
// In your post-auth listener
$this->linkedinApi->shareContent(['comment' => 'Just logged in via SSO!']);
How can I help you explore Laravel packages today?