invisnik/laravel-steam-auth
最新稳定版本:v4.4.0
Composer 安装命令:
composer require invisnik/laravel-steam-auth
包简介
Laravel Steam Auth
README 文档
README
This package is a Laravel 5 service provider which provides support for Steam OpenID and is very easy to integrate with any project that requires Steam authentication.
Requirements
- PHP 7.2+
- Laravel 5.8+
Installation
Via Composer
composer require invisnik/laravel-steam-auth
Steam API Key
Add your Steam API key to your .env file. You can get your API key here.
STEAM_API_KEY=SomeKindOfAPIKey
Config Files
Publish the config file.
php artisan vendor:publish --provider="Invisnik\LaravelSteamAuth\SteamServiceProvider"
Usage example
In config/steam-auth.php:
return [ /* * Redirect URL after login */ 'redirect_url' => '/auth/steam/handle', /* * Realm override. Bypass domain ban by Valve. * Use alternative domain with redirection to main for authentication (banned by valve). */ // 'realm' => 'redirected.com', /* * API Key (set in .env file) [http://steamcommunity.com/dev/apikey] */ 'api_key' => env('STEAM_API_KEY', ''), /* * Is using https? */ 'https' => false, ];
In routes/web.php:
Route::get('auth/steam', 'AuthController@redirectToSteam')->name('auth.steam'); Route::get('auth/steam/handle', 'AuthController@handle')->name('auth.steam.handle');
Note: if you want to keep using Laravel's default logout route, add the following as well:
Route::post('logout', 'Auth\LoginController@logout')->name('logout');
In AuthController:
namespace App\Http\Controllers; use Invisnik\LaravelSteamAuth\SteamAuth; use App\User; use Auth; class AuthController extends Controller { /** * The SteamAuth instance. * * @var SteamAuth */ protected $steam; /** * The redirect URL. * * @var string */ protected $redirectURL = '/'; /** * AuthController constructor. * * @param SteamAuth $steam */ public function __construct(SteamAuth $steam) { $this->steam = $steam; } /** * Redirect the user to the authentication page * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function redirectToSteam() { return $this->steam->redirect(); } /** * Get user info and log in * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function handle() { if ($this->steam->validate()) { $info = $this->steam->getUserInfo(); if (!is_null($info)) { $user = $this->findOrNewUser($info); Auth::login($user, true); return redirect($this->redirectURL); // redirect to site } } return $this->redirectToSteam(); } /** * Getting user by info or created if not exists * * @param $info * @return User */ protected function findOrNewUser($info) { $user = User::where('steamid', $info->steamID64)->first(); if (!is_null($user)) { return $user; } return User::create([ 'username' => $info->personaname, 'avatar' => $info->avatarfull, 'steamid' => $info->steamID64 ]); } }
Should you wish to use a login redirection URL that is differant from the one you specified in the config
// Inside your controller login method $this->steam->setRedirectUrl(route('login.route')); ... return $this->steam->redirect();
If you need another steamID you can use another package to convert the given steamID64 to another type like xPaw/SteamID.
invisnik/laravel-steam-auth 适用场景与选型建议
invisnik/laravel-steam-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 161.61k 次下载、GitHub Stars 达 167, 最近一次更新时间为 2015 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「auth」 「laravel」 「steam」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 invisnik/laravel-steam-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 invisnik/laravel-steam-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 invisnik/laravel-steam-auth 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Multiauth package
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Laravel Steam Auth - TruckersMP
This package provides a flexible way to add Role-based Permissions to Laravel 6.x
Email Toolkit Plugin for CakePHP
Steam Login package for Laravel 5.5+
统计信息
- 总下载量: 161.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 168
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-16