users-au / socialite-provider
Users.au OAuth2 Provider for Laravel Socialite
Requires
- php: ^8.5.12
- ext-json: *
- illuminate/support: ^12.70.0
- socialiteproviders/manager: ^4.10
Requires (Dev)
- guzzlehttp/guzzle: ^7.0
- mockery/mockery: ^1.4
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Users.au for Laravel Socialite
Your Socialite flow. Users.au as the identity provider.
Install Β· Configure Β· Screenshots Β· API endpoints Β· Users.au
Connect Users.au to an existing Laravel Socialite authentication flow. Configure the identity host and endpoints, retrieve the profile, and map it into your own application's user and authorization model.
composer require users-au/socialite-provider
| π Familiar Socialite API | ποΈ Configurable provider | π€ Your user model |
|---|---|---|
Socialite::driver('usersau') for redirects and callbacks. |
Identity host, OAuth endpoints and profile field mappings. | Keep control of account linking, local sign-in and permissions. |
Users.au in action
Users.au hosts the authentication experience on your identity domain. Enable the sign-in methods available to your project and connect them to your application through OAuth. These official product screenshots show the hosted experience.
| π Branded sign-in & social providers | π‘οΈ Multi-factor authentication |
|---|---|
![]() |
![]() |
Explore Users.au Β· Create a project Β· Image sources
Overview
This package provides:
- OAuth2 Authentication: Seamless integration with Users.au OAuth2 service
- Flexible Configuration: Configurable endpoints and user field mappings
- Standard Socialite Interface: Uses Laravel Socialite's familiar API
- Customizable User Mapping: Map Users.au user data to your application's user model
Features
- Support for OAuth2 authorization code flow
- Configurable host and endpoint URLs
- Custom user field mapping (id, nickname, name, email, avatar)
- Bearer token authentication for API requests
- Compatible with Laravel Socialite Manager
How it Works
- OAuth2 Flow: Implements the standard OAuth2 authorization code flow
- User Authentication: Redirects users to Users.au for authentication
- Token Exchange: Exchanges authorization code for access token
- User Data Retrieval: Fetches user information using the access token
- User Mapping: Maps Users.au user data to Laravel Socialite User object
API Endpoints
The Provider makes calls to three main Users.au OAuth2 endpoints:
1. Authorization Endpoint
URL: GET {host}/oauth/authorize
Purpose: Redirects user to Users.au for authentication
Query Parameters:
client_id={client_id}
redirect_uri={redirect_uri}
response_type=code
scope={scopes}
state={state}
Response: Redirects to your redirect_uri with authorization code
{redirect_uri}?code={authorization_code}&state={state}
2. Token Endpoint
URL: POST {host}/oauth/token
Purpose: Exchange authorization code for access token
Request Headers:
Content-Type: application/x-www-form-urlencoded
Request Payload:
grant_type=authorization_code
client_id={client_id}
client_secret={client_secret}
code={authorization_code}
redirect_uri={redirect_uri}
Expected Response:
{
"access_token": "your_access_token",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "your_refresh_token",
"scope": "..."
}
3. User Info Endpoint
URL: GET {host}/api/user
Purpose: Retrieve authenticated user's information
Request Headers:
Authorization: Bearer {access_token}
Expected Response:
{
"id": "user_unique_id",
"nickname": "user_nickname",
"name": "User Full Name",
"email": "user@example.com",
"avatar": "https://example.com/avatar.jpg"
}
Note: The user data structure can be customized using the userinfo_key configuration and custom field mappings (user_id, user_nickname, user_name, user_email, user_avatar).
Installation
composer require users-au/socialite-provider
Configuration
Please see the Base Installation Guide, then follow the provider specific instructions below.
Add configuration to config/services.php
'usersau' => [ 'client_id' => env('USERSAU_CLIENT_ID'), 'client_secret' => env('USERSAU_CLIENT_SECRET'), 'redirect' => env('USERSAU_REDIRECT_URI'), 'host' => env('USERSAU_HOST'), ],
Add provider event listener
Configure the package's listener to listen for SocialiteWasCalled events.
Add the event to your listen[] array in app/Providers/EventServiceProvider. See the Base Installation Guide for detailed instructions.
protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ // ... other providers \SocialiteProviders\Usersau\UsersauExtendSocialite::class.'@handle', ], ];
Register your exact callback URL in Users.au and keep the client secret in private server configuration. Leave scopes at the provider default unless your OAuth registration supports additional scopes. Your app owns local sign-in, account linking and server-side authorization after retrieving a Socialite user.
Usage
You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):
return Socialite::driver('usersau')->redirect();
Returned User fields
idnicknamenameemailavatar
Testing
This package includes comprehensive unit tests to ensure reliability and maintainability.
Running Tests
To run the test suite:
# Install dependencies composer install # Run all tests composer test # Or run PHPUnit directly ./vendor/bin/phpunit # Run tests with documentation format ./vendor/bin/phpunit --testdox # Run static analysis composer analyse # Run both tests and analysis composer check
Continuous Integration
This package uses GitHub Actions for continuous integration with the following workflows:
- Tests: Runs unit tests on the coordinated PHP 8.5.12 baseline
- Static Analysis: Runs PHPStan for type checking and code quality
- Code Style: Validates PHP syntax and PSR-4 compliance
All workflows run automatically on:
- Push to
mainormasterbranches - Pull requests to
mainormasterbranches
Test Structure
tests/
βββ ProviderTest.php # Main provider functionality tests
βββ UsersauExtendSocialiteTest.php # Extension registration tests
The tests use PHPUnit and Mockery for mocking dependencies, ensuring isolated unit tests without external dependencies.
Development
Requirements
- PHP ^8.5.12 and Laravel/Illuminate ^12.70.0
- Composer
- PHPUnit (for testing)
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Code Quality
This package follows PSR-4 autoloading standards and includes:
- Comprehensive unit tests
- Type hints and return types
- Proper error handling
- Documentation for all public methods
FAQ
How do I use Users.au with Laravel Socialite?
Install the provider with composer require users-au/socialite-provider, follow Installation and Configuration, then use Socialite::driver('usersau') for redirects and callbacks.
Which OAuth flow and endpoints does the provider use?
The standard OAuth2 authorization code flow. It calls GET {host}/oauth/authorize, POST {host}/oauth/token and GET {host}/api/user (with a Bearer access token). See API endpoints.
Which user fields are mapped to the Socialite user?
id, nickname, name, email and avatar. The field mappings are configurable.
When should I use the Socialite provider instead of the Laravel client?
Use the provider when you already have a Socialite flow and want to control account linking and local sign-in yourself. Use the Laravel client to add ready-made authentication routes and local user synchronization.
Choose your integration
| Project | Use it when you want to⦠|
|---|---|
| Next.js starter | Start a Next.js app with server-managed OAuth sessions and a protected dashboard. |
| Laravel starter | Start a Laravel app with Blade templates and Users.au integration. |
| Laravel client | Add local user synchronization and authentication routes to a Laravel app. |
| Socialite provider β this repo | Connect an existing Laravel Socialite authentication flow to Users.au. |
| Frontend client | Use public-client OAuth with PKCE in JavaScript, Vue or React. |
License and support
MIT Β· Open an issue Β· Users.au
Identity profile contract (2.0)
Provider 2 targets PHP ^8.5.12 / Laravel ^12.70.0 with Usersau Laravel SDK 2.1. It requests openid/profile/email by default. Consumers needing account-wide locale, timezone and theme also request preferences:read and preferences:write.
Socialite getId() uses the standard sub, getAvatar() uses picture, and getRaw() retains the scoped standard profile claims and urn:usersau:preferences. Missing optional claims remain absent; inconsistent sub/id values are rejected. UserInfo calls have bounded timeouts and do not follow redirects.
Use SDK UserProfile and IdentityClient for typed claims, versioned preference updates and token refresh. The provider owns OAuth transport, not application preference storage or browser theme state. See the shared protocol.


