2017 © Pedro Peláez
 

symfony-bundle simple-security-bundle

A simple security bundle for user authentication

image

tom32i/simple-security-bundle

A simple security bundle for user authentication

  • Thursday, November 24, 2016
  • by Tom32i
  • Repository
  • 6 Watchers
  • 0 Stars
  • 209 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 4 Open issues
  • 18 Versions
  • 1 % Grown

The README.md

Tom32iSimpleSecurityBundle

A simple security bundle for user authentication, (*1)

Installation:

Install the bundle:

Add the bundle to composer:

php composer.phar require tom32i/simple-security-bundle

Register the bundle in app/AppKernel.php:

$bundles = array(
    new Tom32i\Bundle\SimpleSecurityBundle\Tom32iSimpleSecurityBundle(),
);

Add routing in app/config/routing.yml:

login_check:
    pattern:   /login-check

logout:
    pattern:   /logout

simple_security:
    resource: "@Tom32iSimpleSecurityBundle/Controller/"
    type:     annotation
    prefix:   /

Create your custom user class:

Extends Tom32i\Bundle\SimpleSecurityBundle\Entity\User., (*2)

<?php

namespace Acme\DemoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Tom32i\Bundle\SimpleSecurityBundle\Entity\User as SimpleSecurityUser;

/**
 * User
 *
 * @ORM\Table
 * @ORM\Entity
 */
class User extends SimpleSecurityUser
{
    const ROLE_USER  = 'ROLE_USER';

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();

        $this->addRole(static::ROLE_USER);
    }

    /**
     * Get available roles (used for validation)
     *
     * @return array    
     */
    static public function getAvailableRoles()
    {
        return [static::ROLE_USER];
    }
}

Configure security:

Set up encorder and provider for your custom user class Acme\DemoBundle\Entity\User:, (*3)

security:
    encoders:
        # Choose an encoder for your User class:    
        Acme\DemoBundle\Entity\User: sha512

    providers:
        default:
            entity:
                # Register your entity as an User provider:
                class:    Acme\DemoBundle\Entity\User
                property: username

    firewalls:
        default:
            pattern:    ^/
            form_login:
                login_path: /login
                check_path: /login-check
                # Set the credentials parameters to match the Login form:
                username_parameter: "login[username]"
                password_parameter: "login[password]"
            logout:
                path:   /logout
            anonymous: true
            remember_me:
                key:      "%secret%"
                lifetime: 31536000
                path:     /
                domain:   ~
                # ... and the "Remember me" parameter as well:
                remember_me_parameter: "login[remember_me]"

    access_control:
        # Allow anonymous users to access login, register and forgot password routes:
        - { path: ^/(login|register|forgot-password), roles: IS_AUTHENTICATED_ANONYMOUSLY }

The Versions

24/11 2016

dev-symfony3

dev-symfony3 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/05 2015

0.3.x-dev

0.3.9999999.9999999-dev https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/05 2015

dev-0.3-fix

dev-0.3-fix https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/05 2015

v0.3.5

0.3.5.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/05 2015

dev-master

9999999-dev https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/05 2015

dev-0.3-old

dev-0.3-old https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/05 2015

v0.4.4

0.4.4.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/12 2014

v0.4.3

0.4.3.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/12 2014

v0.3.4

0.3.4.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

15/12 2014

v0.3.3

0.3.3.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

15/12 2014

v0.4.2

0.4.2.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

08/12 2014

v0.3.2

0.3.2.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

08/12 2014

v0.4.1

0.4.1.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

04/12 2014

v0.4.0

0.4.0.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

02/12 2014

v0.3.1

0.3.1.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

29/11 2014

v0.3.0

0.3.0.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

18/11 2014

v0.2.0

0.2.0.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

authentication user security

28/09 2014

v0.1.0

0.1.0.0 https://github.com/Tom32i/SimpleSecurityBundle

A simple security bundle for user authentication

  Sources   Download

MIT

The Requires

 

user security