2017 © Pedro Peláez
 

library sentry-auth

Provides an authentication driver for Sentry as well as additional role based access control

image

kevbaldwyn/sentry-auth

Provides an authentication driver for Sentry as well as additional role based access control

  • Sunday, January 12, 2014
  • by ardani
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Introduction

Sentry Auth is designed to be a drop in replacement for the native Laravel Auth system. It provides the same native API as the Auth class but also adds Sentry's own API to it natively. It also binds the Sentry User and Group model APIs to your Eloquent Model, along with mapping the Sentry Hash API to Laravel's., (*1)

Installation

Add the following to your composer.json file, (*2)

"repositories": [
    {
        "type":"composer",
        "url" : "http://packages.purepixel.co.uk"
    }
]

And the requirement, (*3)

"kevbaldwyn/sentry-auth":"dev-master"

Then composer update, (*4)

Add the providers to app/config/app.php, (*5)

'providers' => array(

    ...

    'Cartalyst\Sentry\SentryServiceProvider', // Sentry must be defined first
    'KevBaldwyn\SentryAuth\SentryAuthServiceProvider'

    ...

Add Sentry Facade to app/config/app.php, (*6)

'aliases' => array( 
    ...

    'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry'
    ...

Configuration

The package uses a couple of config options to bind the User and Group Models., (*7)

sentry-auth/src/config/sentry.php, (*8)

'users' => array(

    'model' => 'KevBaldwyn\SentryAuth\Models\User'

)

You can then extend this class to create your own models:, (*9)

// app/models/User.php:
class User extends \KevBaldwyn\SentryAuth\Models\User {

    // your own model definition

}

Then update the model config, (*10)

// app/config/packages/kevbaldwyn/sentry-auth/sentry.php
'users' => array(

    'model' => 'User'

)

sentry-auth/src/config/sentry.php can be used to overwrite any sentry default config options by defining any sentry config options with the same keys as you'd find in cartalyst/sentry/src/config/config.php, (*11)

Examples

You can use all native Auth class methods the same way plus additionally you can call Sentry methods natively from the same Auth API, (*12)

$user = Auth::register(array(
    'email'    => 'john.doe@example.com',
    'password' => 'test',
));
// user will be an Eloquent Model with access to all of Sentry's user API
$activationCode = $user->getActivationCode();
var_dump($activationCode);

Auth::loginUsingId(1);
var_dump(Auth::user()->email);


$credentials = array(
    'email'    => 'john.doe@example.com',
    'password' => 'test',
);
Auth::once($credentials);


// Sentry User methods mapped directly to Eloquent model
User::findByCredentials(array(
        'email'      => 'john.doe@example.com',
        'password'   => 'test')
);

//$group = Group::create(array(
    'name'        => 'Users',
    'permissions' => array(
        'admin' => 1,
        'users' => 1,
    ),
));


$user = User::create(array(
    'email'    => 'john.doe@example.com',
    'password' => 'test',
));

// Assign the group to the user
$user->addGroup($group);

The Versions

12/01 2014

dev-master

9999999-dev

Provides an authentication driver for Sentry as well as additional role based access control

  Sources   Download

The Requires

 

by Kevin Baldwyn