Authentication Provider

The Authentication Provider handles a authentication for a user.

The easiest way to use the Auth Manager is access to it through the container $container->get('authentication').

Otherwise just add the following parameter to the construct method of your Controller Tomahawk\Authentication\AuthenticationProviderInterface and it will get injected in through the Service Container.

Please note: Before getting started, make sure that the password field is a minimum of 60 characters.

Authentication Providers


Tomahawk ships with 2 Authentication Providers:

  • Memory - A simple provider that uses a username and password from the security config
  • Doctrine - A proider that uses the Doctrine ORM

Setting Up


Configuration

The config for Authentication Provider can be found in the app/config/security.php and will look like the following.

Creating a User model

Your User class needs to implement the Tomahawk\Authentication\User\UserInterface interface.

You should have a model which looks something like the following:

Authenticating Users


Manual Authentication

To authenticate a user to pass the username and password to the attempt method.

Please note: The username and password names must match those in the config.

Manual Authentication With Extra Checks

You might want to also check other parts of the account:

Checking If User Is Logged In

Checking If User Is Guest

Logout A User

Getting The Logged In User

Logging Out The User

Automatically Logging In A Users

If you already have the user model you can pass this the the auth manager to log them in: