Download the PHP package chrisreedio/socialment without Composer
On this page you can find all versions of the php package chrisreedio/socialment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chrisreedio/socialment
More information about chrisreedio/socialment
Files in chrisreedio/socialment
Package socialment
Short Description Provides Socialite functionality for Filament.
License MIT
Homepage https://github.com/chrisreedio/socialment
Informations about the package socialment
Socialment - Socialite OAuth Support for Filament
About
Bring up-to-date and simple Socialite support to your Filament admin panel with this plugin. Adds OAuth buttons to your login page.
Ideal for Laravel and Filament users seeking a straightforward OAuth integration.
[!WARNING] Socialment is currently in beta. Please report any issues you encounter.
Caution is advised if you choose to use this package in production.
Azure AD support has been the only tested provider so far.
References
This package extends Laravel Socialite. Socialite currently supports authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket out of the box.
Refer to the Socialite documentation for more information on how to configure your application to use these providers.
Many other providers are available via the Socialite Providers website. Refer to the documentation for each provider for information on how to configure your application to use them.
Demo
For an example usage of this package, see ChrisReedIO/Socialment-Demo.
Installation
You can install the package via composer:
Usage
Initial Setup
You can easily perform the initial setup by running the following command:
Additionally, edit your panel's tailwind.config.js
content section to include the last line of the following:
If this step is forgotten, the styling of the plugin will not be applied.
Please continue to the next sections to continue the setup process.
Panel Configuration
Include this plugin in your panel configuration:
Provider Configuration
[!IMPORTANT] At this point, you'll need to configure your application to use the provider(s) you want to support.
Either configure the needed stock socialite providers or community maintained providers.
Refer to the Socialite documentation for more information.
This will usually involve installing a package and configuring your application's
config/services.php
file.
Socialment Configuration
Provider Configuration
[!WARNING] This method of provider configuration is now deprecated and will be removed in a future release.
Configuring providers in your panel configuration has many advantages and is the recommended method.
Whether you're using the default providers or adding your own, you'll need to configure them in the socialment.php
config file.
Configure the socialment.php
config file to specify providers in the following format:
Providers specified in the config file are global across all panels.
Per-Panel Provider Configuration
You should specify providers on a per-panel basis. To do this use the ->registerProvider
method on the plugin.
Sample Provider Configuration - Azure Active Directory
[!IMPORTANT] For this configured Azure provider, the redirect URI would be
https://DOMAIN/login/azure/redirect
The callback URI would be
https://DOMAIN/login/azure/callback
For example, the sample provider included in the stock socialment.php
config is Azure Active Directory.
To start, You would refer to the documentation for
the Azure Socialite Provider.
Normally, you would follow the providers documentation on the aforementioned link but to demostrate the process for Socialment, I'll include the steps here.
Per their documentation, you would install the community Azure provider via
Then you would configure your config/services.php
file to include the Azure provider's credentials:
In addition, you need to add this provider's event listener to your app/Providers/EventServiceProvider.php
file:
Finally, don't forget to add the needed environment variables to your .env
file:
The usage
section can usually be ignored as that is the main part this package should handle for you.
[!NOTE] It is in the plans to improve the handling of the sign in process to align more with Socialstream in allowing you to specify an
action
class or closure to handle the sign in process.This will allow for customized handling on a per provider, per application basis.
This package also uses the Blade Font Awesome package by Owen Voke.
Search for brand icons on the Font Awesome Website.
Visibility Override
By default, the plugin displays the configured providers at the bottom of the login form.
You can additionally override the visibility of the plugin by passing a boolean or closure to the visible
method:
Extras
You may publish and customize the views using
Login Callbacks
You may configure pre/post login hooks/callbacks by adding code similar to the following to the boot
method of a
service provider:
The user relation can be accessed via $connectedAccount->user
.
The ConnectedAccount
is passed instead of the User
so that you can easily know which social account was used for the
login.
Login Route for failed logins
If a login fails or encounters a InvalidStateException, the user will be redirected to the configured loginRoute
route.
This defaults to filament.admin.auth.login
but can be overriden on the plugin declaration in your panel provider
configuration:
You may also use a closure here to dynamically set the route:
Config
This is the contents of the published config file:
Frontend SPA Authentication
[!CAUTION] This feature is still in development and thus highly experimental.
Expect breaking changes and bugs. Use at your own risk.
The documentation will be updated as the feature is finalized.
This feature may be spun off into a separate package in the future.
This package includes support for authenticating with a Single Page Application (SPA) frontend. Both the Filament backend and SPA frontend must be hosted on the same domain.
The login session is shared so logging into either the SPA or the backend will log you into both.
Special CORS and session settings are required to make this work and caution must be taken to ensure that proper access controls (Policies / Panel Access / Etc) are in place.
Setup
You'll need to add the new spaAuth
routes to your routes/web
file.
Configuration Changes
You'll need to modify the config/cors.php
file.
You'll need to add the following to the paths
array:
Also ensure that the supports_credentials
is set to true
:
Environment Variables
We need to set a few ENV variables to ensure that the SPA authentication works properly.
The SESSION_DOMAIN
should be the shared domain between your SPA and your backend. It should begin with a period.
The SPA_URL
is the URL of your SPA application.
[!NOTE] Ths SPA functionality is a work in progress and is subject to change.
This documentation section will be updated as the feature is finalized.
Testing
[!NOTE] Tests have yet to be written for this package. They are on my TODO list. I'm also open to PRs.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Chris Reed
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of socialment with dependencies
filament/filament Version ^3.0
illuminate/contracts Version ^10.0|^11.0
laravel/socialite Version ^5.8
owenvoke/blade-fontawesome Version ^2.4
spatie/laravel-package-tools Version ^1.15.0