2017 © Pedro Peláez
 

library auth

Powerful and extremely flexible authentication

image

solution10/auth

Powerful and extremely flexible authentication

  • Thursday, March 30, 2017
  • by alexgisby
  • Repository
  • 3 Watchers
  • 11 Stars
  • 98 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 10 Versions
  • 1 % Grown

The README.md

Solution10\Auth

Powerful and extremely flexible authentication, (*1)

Build Status Coverage Status Latest Stable Version Total Downloads License, (*2)

Key Features

  • Framework agnostic:

Can work with any framework and any ORM / database layer. Implement two classes to integrate with your tools of choice and Auth will do the rest.
[Learn more about Integration](http://github.com/solution10/auth/wiki/Integrating), (*3)

  • Multiple Instances:

No statics or manky global scope. Every auth instance is totally self contained and can talk to entirely different backends and session handlers.
[Learn more about Multiple Instances](http://github.com/solution10/auth/wiki/Instances), (*4)

  • Powerful Permissions:

Package based permissions allow you to define broad access control groups, and Overrides allow you to allow/disallow permissions on a per-user basis
[Learn more about Permissions](http://github.com/solution10/auth/wiki/Permissions), (*5)

Installation

Installation is as you'd expect, simply via a Composer requirement:, (*6)

{
    "require": {
        "solution10/auth": "^1.2"
    }
}

Note: Auth provides absolutely no storage capability (no database layer / access). You will need to provide this by implementing a StorageDelegate. This approach might seem awkward at first, but it allows you to take completely control over the logic of data-retrieval, whilst Auth handles the actual mechanics for you. Learn more about Integration, (*7)

Basic Usage

Your first step should be to complete everything in the Integration guide, but that doesn't make for a sexy demo, so we'll assume you've done that!, (*8)

Let's pretend that I have fully implemented a StorageDelegate called "PDOStorageDelegate"., (*9)

// The storage delegate handles reading/writing User data from
// your data store. That could be a database, REST service, whatever.
$storageDelegate = new PDOStorageDelegate();

// The session delegate handles maintaining state between
// page loads. Essentially, it's a front to the $_SESSION array,
// but if you do it different, you can re-implement!
$sessionDelegate = new Solution10\Auth\Driver\Session();

// Fire up a new instance called "MyAuth"
$auth = new Solution10\Auth\Auth('MyAuth', $sessionDelegate, $storageDelegate);

// Play with some API methods:
if ($auth->loggedIn()) {
    echo 'Hi, '.$auth->user()->username.', welcome to the site!';
}

As you may have noticed, we give auth instances names. This gives us a way of referencing them later. More on that in the Instances chapter., (*10)

Logging In

if ($auth->login($username, $password)) {
    echo 'User was logged in!';
} else {
    echo 'Please check your username and password.';
}

Logging Out

$auth->logout();

Checking Login State

if ($auth->loggedIn())) {
    echo "You're logged in!";
} else {
    echo "You are not logged in :(";
}

Getting the Current User

$user = $auth->user();

Forcing a Login

This should be used with extreme caution, it will allow you to log a user in without their password. Probably only useful after registration., (*11)

// The $user object needs to be a class that implements the
// Solution10\Auth\UserRepresentation interface.
// It's a tiny interface, but it just gives us enough info to
// do our work.

$user = new UserRepresentationInstance();

$user->forceLogin($user);

You can read more about UserRepresentation in the Integration guide, (*12)

PHP Requirements

  • PHP >= 5.4

Documentation

For a user guide: Check out the Wiki here on GitHub., (*13)

Author

Alex Gisby: GitHub, Twitter, (*14)

License

MIT, (*15)

Contributing

Contributors Notes, (*16)

The Versions

30/03 2017

dev-master

9999999-dev

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

30/03 2017

v1.3.1

1.3.1.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

26/03 2017

v1.3.0

1.3.0.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

26/03 2017

dev-feature/haspackage

dev-feature/haspackage

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

01/10 2016

v1.2.2

1.2.2.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

01/10 2016

dev-feature/housekeeping

dev-feature/housekeeping

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

23/11 2014

v1.2.1

1.2.1.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

07/11 2014

v1.2.0

1.2.0.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

29/10 2014

v1.1.0

1.1.0.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control

20/07 2014

v1.0.0

1.0.0.0

Powerful and extremely flexible authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alex Gisby

authentication component acl auth access control