2017 © Pedro Peláez
 

library laravel-steam-auth

Laravel Steam Auth

image

invisnik/laravel-steam-auth

Laravel Steam Auth

  • Tuesday, April 24, 2018
  • by invisnik
  • Repository
  • 9 Watchers
  • 117 Stars
  • 40,406 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 51 Forks
  • 2 Open issues
  • 28 Versions
  • 5 % Grown

The README.md

Steam authentication for Laravel

Code Climate Latest Stable Version Total Downloads License, (*1)

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., (*2)

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., (*3)

STEAM_API_KEY=SomeKindOfAPIKey

Config Files

Publish the config file., (*4)

php artisan vendor:publish --provider="Invisnik\LaravelSteamAuth\SteamServiceProvider"

Usage example

In config/steam-auth.php:, (*5)

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:, (*6)

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:, (*7)

Route::post('logout', 'Auth\LoginController@logout')->name('logout');

In AuthController:, (*8)

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, (*9)

// 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., (*10)

The Versions

24/04 2018

dev-master

9999999-dev

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

13/04 2018

v3.3.0

3.3.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

13/04 2018

dev-analysis-XVRgAV

dev-analysis-XVRgAV

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

06/04 2018

v3.2.1

3.2.1.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

27/02 2018

v3.2.0

3.2.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

01/09 2017

v3.1.2

3.1.2.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

27/08 2017

v3.1.1

3.1.1.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

13/08 2017

v3.1.0

3.1.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

10/08 2017

v3.0.0

3.0.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

16/05 2017

v2.3.5

2.3.5.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

09/05 2017

v2.3.4

2.3.4.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

25/03 2017

v2.3.3

2.3.3.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

25/01 2017

v2.3.2

2.3.2.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

07/11 2016

v2.3.1

2.3.1.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

07/11 2016

v2.3.0

2.3.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

25/06 2016

v2.2.0

2.2.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Brytkov

laravel auth steam

01/06 2016

v2.1.2

2.1.2.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

31/05 2016

v2.1.1

2.1.1.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

21/05 2016

v2.1.0

2.1.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

19/08 2015

v2.0.0

2.0.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

16/06 2015

v1.1.4

1.1.4.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

02/05 2015

v1.1.3

1.1.3.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

01/04 2015

v1.1.2

1.1.2.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

01/04 2015

v1.1.1

1.1.1.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

01/04 2015

v1.1.0

1.1.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

31/03 2015

v1.0.2

1.0.2.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

22/03 2015

v1.0.1

1.0.1.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam

20/03 2015

v1.0.0

1.0.0.0

Laravel Steam Auth

  Sources   Download

MIT

The Requires

 

by Nikita Brytkov

laravel auth steam