Reputation:
On the last weeks, I'm trying to implement a OpenID authentication on my laravel's website, but without success. I can't use laravel/socialite because the package doesn't support steam and think not support OpenID auths too.
Then, I found the community driven project for custom socialite adapters. But the adapters are a mess and uses obsolete dependencies.
A answer will help a lot of people. Help us :c
Upvotes: 12
Views: 3104
Reputation: 292
Socialite Steam Login
Composer Install
// This assumes that you have composer installed globally
composer require socialiteproviders/steam
SERVICE PROVIDER
Remove Laravel\Socialite\SocialiteServiceProvider from your providers[] array in config\app.php if you have added it already.
Add \SocialiteProviders\Manager\ServiceProvider::class to your providers[] array in config\app.php.
'providers' => [
// a whole bunch of providers
// remove 'Laravel\Socialite\SocialiteServiceProvider',
\SocialiteProviders\Manager\ServiceProvider::class, // add
];
Add the event and listeners
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
'SocialiteProviders\Steam\SteamExtendSocialite@handle',
],
];
ENVIRONMENT VARIABLES in ,env file
// other values above
STEAM_KEY=yourapikeyfortheservice
STEAM_REDIRECT_URI=https://example.com/login
sources:- http://socialiteproviders.github.io/providers/steam/
Hopefully, this helps with your steam login.
Upvotes: 0
Reputation: 1044
You need to use Laravel Steam Auth
Very easy setup:
Composer install
"invisnik/laravel-steam-auth": "2.*"
Add the service provider to app/config/app.php, within the providers array.
'providers' => [
Invisnik\LaravelSteamAuth\SteamServiceProvider::class,
]
php artisan vendor:publish
config/steam-auth.php
Route::get('dologin', 'Auth\SteamController@dologin');
Use this live code example, as code from readme not worked for me:
<?php
public function dologin(Request $request)
{
if ($this->steam->validate()) {
$info = $this->steam->getUserInfo();
if (! is_null($info)) {
$user = User::where('token', $info->get('steamID64'))->first();
if (! is_null($user)) {
//Update user data, as it change over time..
$user->nick = $info->get('personaname');
$user->name = $info->get('realname') ?: '';
$user->avatar = $info->get('avatarfull');
$user->update();
} else {
$user = User::create([
'nick' => $info->get('personaname'),
'name' => $info->get('realname') ?: '',
'avatar' => $info->get('avatarfull'),
'token' => $info->get('steamID64'),
]);
}
Auth::login($user, true);
return redirect('/'); // redirect to site
}
}
return $this->steam->redirect(); // redirect to Steam login page
}
Upvotes: 2