Developed with love by KnpLabs Hire us for your project!
26

SteamAuthenticationBundle

by knojector

A Symfony4 Bundle that provides authentication via Steam for your application

SteamAuthenticationBundle

A Symfony Bundle that provides authentication via Steam for your application.

Installation & Configuration

Just require the bundle via Composer and use the given flex recipe during the install process.

composer require knojector/steam-authentication-bundle


In your .env file a new entry for your Steam API key was generated. You can obtain your Steam API key here: https://steamcommunity.com/dev/apikey

login_route The route the user is redirected to after Steam Login

login_redirect The route the user is redirected to if the login was successfull

user_class Classname of your User Entity

request_validator_class Classname of RequestValidatorInterface class. If it isn't set then Knojector\SteamAuthenticationBundle\Security\Authentication\Validator\RequestValidator will be used.


Make sure your User Entity extends from the Knojector\SteamAuthenticationBundle\User\AbstractSteamUser class
```php
<?php

namespace App\Entity;

use Knojector\SteamAuthenticationBundle\User\AbstractSteamUser;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\Role\Role;

/**
* @author Knojector dev@knojector.xyz
*
* @ORM\Entity()
/
class User extends AbstractSteamUser
{
/
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

/**
 * @return int
 */
public function getId(): int
{
    return $this->id;
}

public function __construct()
{
    $this->roles = [];
}

/**
 * @return array
 */
public function getRoles(): array
{
    $roles = [];
    foreach ($this->roles as $role) {
        $roles[] = new Role($role);
    }

    return $roles;
}

}
```


Finally you just have to configure your firewall. A working example might looks like this
```yaml
security:
providers:
steam_user_provider:
id: Knojector\SteamAuthenticationBundle\Security\User\SteamUserProvider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
pattern: ^/
provider: steam_user_provider
steam: true
logout:
path: /logout
target: /


----------

To display the "Login via Steam" button just include this snippet in your template
```twig
{% include '@KnojectorSteamAuthentication/login.html.twig' with { 'btn': 1 } %}

You can choose between two images (1 or 2) that will be display as button. Or simply enter your own text.

MIT License

Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
knojector_steam_authentication:
api_key: ~
login_route: ~
login_redirect: ~
user_class: ~
request_validator_class: Knojector\SteamAuthenticationBundle\Security\Authentication\Validator\RequestValidator
  • Merge pull request #34 from Joaquinee/patch-1
    By web-flow, 14 days ago
  • Update SteamUserToken.php
    By web-flow, 7 months ago
  • Merge pull request #28 from knojector/feature/hf4
    By web-flow, 1 year ago
  • README changes
    By knojector, 1 year ago
  • Merge pull request #27 from knojector/feature/hf3
    By web-flow, 1 year ago
  • README changes
    By knojector, 1 year ago
  • README changes
    By knojector, 1 year ago
  • Merge pull request #26 from knojector/feature/hf2
    By web-flow, 1 year ago
  • README changes
    By knojector, 1 year ago
  • Merge pull request #25 from knojector/feature/hf1
    By web-flow, 1 year ago
  • README changes
    By knojector, 1 year ago
  • Merge pull request #24 from brnicot/master
    By web-flow, 1 year ago
  • Merge pull request #1 from brnicot/patch-1
    By web-flow, 1 year ago
  • Update README.md
    By web-flow, 1 year ago
  • Update login.html.twig
    By web-flow, 1 year ago
  • Merge pull request #23 from insideone/master
    By web-flow, 1 year ago
  • #22
    By , 1 year ago
  • Merge pull request #18 from knojector/fix/readme
    By web-flow, 2 years ago
  • add space
    By knojector, 2 years ago
  • Merge pull request #17 from knojector/fix/readme
    By web-flow, 2 years ago
  • Merge branch 'fix/readme' of https://github.com/knojector/SteamAuthenticationBundle into fix/readme
    By knojector, 2 years ago
  • add changes to readme
    By knojector, 2 years ago
  • Merge pull request #16 from knojector/feature/select-button-images
    By web-flow, 2 years ago
  • select between button images or choose own text
    By knojector, 2 years ago
  • Merge pull request #15 from knojector/fix/doc
    By web-flow, 2 years ago
  • fixed docs
    By knojector, 2 years ago
  • Merge pull request #14 from knojector/fix/readme
    By web-flow, 2 years ago
  • fixed typos
    By knojector, 2 years ago
  • Merge pull request #12 from LeoWyatt666/master
    By web-flow, 2 years ago
  • fix commentpermission
    By , 2 years ago