https://github.com/ilzrv/laravel-steam-auth
Steam Auth for Laravel
https://github.com/ilzrv/laravel-steam-auth
laravel laravel-steam laravel-steam-auth steam steam-api steam-auth steam-authentication
Last synced: 11 months ago
JSON representation
Steam Auth for Laravel
- Host: GitHub
- URL: https://github.com/ilzrv/laravel-steam-auth
- Owner: ilzrv
- License: mit
- Created: 2020-03-29T19:00:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-16T17:11:02.000Z (over 1 year ago)
- Last Synced: 2025-07-02T21:45:54.600Z (12 months ago)
- Topics: laravel, laravel-steam, laravel-steam-auth, steam, steam-api, steam-auth, steam-authentication
- Language: PHP
- Homepage:
- Size: 55.7 KB
- Stars: 17
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Steam Auth for Laravel
[](https://packagist.org/packages/ilzrv/laravel-steam-auth)
[](https://packagist.org/packages/ilzrv/laravel-steam-auth)
[](https://github.com/ilzrv/laravel-steam-auth/actions/workflows/tests.yml)
[](https://app.codecov.io/github/ilzrv/laravel-steam-auth)
[](https://packagist.org/packages/ilzrv/laravel-steam-auth)
Package allows you to implement Steam authentication in your Laravel project.
## Requirements
* Laravel 9+
* PHP 8.1+
## Installation
#### Install the package
```bash
composer require ilzrv/laravel-steam-auth
```
#### Publish the config file
```bash
php artisan vendor:publish --provider="Ilzrv\LaravelSteamAuth\ServiceProvider"
```
#### Setup Steam API Key(s)
Add your Steam API key to your `.env` file. You can find it [here](https://steamcommunity.com/dev/apikey).
*if you want to use multiple API keys just list them separated by commas*
```
STEAM_AUTH_API_KEYS=YourSteamApiKey1,YourSteamApiKey2
```
## Tips
#### Client Settings
You can use any settings that your client supports, for example, a [Guzzle Proxy](https://docs.guzzlephp.org/en/latest/request-options.html#proxy):
```php
'socks5://user:password@192.168.1.1:1080',
]);
$steamAuthenticator = new SteamAuthenticator(
new Uri($request->getUri()),
$client,
$httpFactory,
);
// Continuation of your code...
}
```
#### Proxy Domain
If you want to make a proxy domain. Update `redirect_url` inside `steam-auth.php` to your absolute address like `https://auth.test/login`. You can use different domains for the local environment and for production like this:
```php
env('APP_ENV', 'production') == 'production'
? 'https://auth.test/login'
: null,
];
```
In the NGINX settings for proxy domain, you can specify the following:
```
server {
listen 443 ssl http2;
server_name auth.test;
return 301 https://general.test$uri$is_args$args;
}
```
## Basic example
In `routes/web.php`:
```php
Route::get('login', \App\Http\Controllers\Auth\SteamAuthController::class);
```
Create a controller `SteamAuthController.php`:
```php
getUri()),
$client,
$httpFactory,
);
try {
$steamAuthenticator->auth();
} catch (ValidationException|SteamResponseNotValidAuthenticationException) {
return $redirector->to(
$steamAuthenticator->buildAuthUrl()
);
}
$steamUser = $steamAuthenticator->getSteamUser();
$authManager->login(
$this->firstOrCreate($steamUser),
true
);
return $redirector->to('/');
}
private function firstOrCreate(SteamUserDto $steamUser): User
{
return User::firstOrCreate([
'steam_id' => $steamUser->getSteamId(),
], [
'name' => $steamUser->getPersonaName(),
'avatar' => $steamUser->getAvatarFull(),
'player_level' => $steamUser->getPlayerLevel(),
// ...and other what you need
]);
}
}
```