2017 © Pedro Peláez
 

library auth

a simple authenticate package.

image

wscore/auth

a simple authenticate package.

  • Saturday, November 4, 2017
  • by asaokamei
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

WScore.Auth

A simple authentication package., (*1)

License

MIT License, (*2)

PSR

PSR-1, PSR-2, and PSR-4., (*3)

Installation

composer require "wscore/auth: ^0.3"

Getting Started

Auth requires UserProviderInterface object to access to user information., (*4)

$auth = new Auth(new UserProvider);

To authenticate a user, get user-id ($id) and user-password ($pw) from a login form, and, (*5)

if ($auth->login($id, $pw)) {
    echo 'login success!';
}

to check for login later on,, (*6)

$auth->isLogin();

You can retrieve login information such as;, (*7)

$user = $auth->getLoginUser(); // login user entity returned by UserProvider's getUserInfo() method.
$mail = $auth->getLoginId(); // get login user's id. maybe an email? 

Force Login

forceLogin method allow to login as a user without a password, for purposes, such as system administration., (*8)

$auth->forceLogin($id);

then, you can check if the login is force or not., (*9)

$auth->isLoginBy(Auth::BY_FORCED); // check for login method. 

UserProvider

The Auth requires a user provider object implementing UserProviderInterface. The interface has 4 APIs; that are, (*10)

  • getUserById($id): for retrieving a user entity for $id (a login user).
  • getUserByIdAndPw($id, $pw): for retrieving a user entity for $id and valid $pw.
  • getUserType(): for retrieving a key-string to identify the user-provider.

Remember-Me Option

To use Remember-me option, use setRememberMe method, as, (*11)

$auth = new Auth(...);
$auth->setRememberMe(new MyRememberMe());
  • $remember object implementing RememberMeInterface,
  • RememberCookie object,

then, when login, supply 3rd argument when login as, (*12)

$auth->login($id, $pw, true);

to save the $id and a remember-me token to cookie if login is successful., (*13)

The Versions

04/11 2017

0.3.0.x-dev

0.3.0.9999999-dev

a simple authenticate package.

  Sources   Download

MIT

by Asao

04/11 2017

0.3.0

0.3.0.0

a simple authenticate package.

  Sources   Download

MIT

by Asao

27/03 2016

dev-master

9999999-dev

a simple authenticate package.

  Sources   Download

MIT

by Asao

27/03 2016

0.2.0

0.2.0.0

a simple authenticate package.

  Sources   Download

MIT

by Asao

27/03 2016

dev-dev-0.2

dev-dev-0.2

a simple authenticate package.

  Sources   Download

MIT

by Asao

10/03 2015

0.1.0

0.1.0.0

a simple authenticate package.

  Sources   Download

MIT

by Asao