PHPackages                             teresko/palladium - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. teresko/palladium

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

teresko/palladium
=================

User authentication and registration component

v1.4.2(8y ago)4314.2k8[1 PRs](https://github.com/teresko/palladium/pulls)BSD-3-ClausePHPPHP &gt;=7.0CI failing

Since May 22Pushed 5y ago16 watchersCompare

[ Source](https://github.com/teresko/palladium)[ Packagist](https://packagist.org/packages/teresko/palladium)[ Docs](https://github.com/teresko/palladium)[ RSS](/packages/teresko-palladium/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (9)Dependencies (2)Versions (11)Used By (0)

Palladium
=========

[](#palladium)

**(work-in-progress: docs for 2.0)**

[![Build Status](https://camo.githubusercontent.com/edddba606c11bdd930e52ee3749d6f554b44990de246e3893198c9bbd0d06540/68747470733a2f2f7472617669732d63692e6f72672f74657265736b6f2f70616c6c616469756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/teresko/palladium)[![Packagist Version](https://camo.githubusercontent.com/58d448949ae8364c19779488202b954ab26ec0ad762814e810491a999e9c10b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74657265736b6f2f70616c6c616469756d2e737667)](https://packagist.org/packages/teresko/palladium)[![License](https://camo.githubusercontent.com/d51fa5658ecb8933a610eacedf7afc414879f596964d3d0614cd0cabd3482a24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74657265736b6f2f70616c6c616469756d2e737667)](https://github.com/teresko/palladium/blob/master/LICENSE.md)[![Code Climate](https://camo.githubusercontent.com/ed0907f046583f75c51096917fb165fef74cab1d9f4451d98a7fac52642fe41b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f74657265736b6f2f70616c6c616469756d2f6261646765732f6770612e737667)](https://codeclimate.com/github/teresko/palladium)[![Code Coverage](https://camo.githubusercontent.com/b9ce7f315adf773f1f3721e29a01a6da10d2b4fccb64351072cd99ca88e927c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74657265736b6f2f70616c6c616469756d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/teresko/palladium/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7917661acc8291cad52e79c7896682fc33aefcf0c1a25d33a36265cba31bf026/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74657265736b6f2f70616c6c616469756d2e737667)](https://scrutinizer-ci.com/g/teresko/palladium/?branch=master)[![Infection MSI](https://camo.githubusercontent.com/31578fac38bb9f4125e3ff62b048ac081fedb78326104fa5bcb5114d6d0470b7/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f74657265736b6f2f70616c6c616469756d2f6d6173746572)](https://infection.github.io)

Library for handling the user identification.

The purpose of this library is to locate user's [account](https://github.com/teresko/palladium/blob/master/docs/Concept/Account.md) (to be precise - its unique id) for a given proof of [identity](https://github.com/teresko/palladium/blob/master/docs/Concept/Identity.md) and to manage various types of identities. It consists of 4 different [services](https://github.com/teresko/palladium/blob/master/docs/Concept/Service.md): Identification, Registration, Search and Recovery.

Installation
------------

[](#installation)

You can add the library to your project using composer with following command:

```
composer require teresko/palladium
```

To use this package, it require PHP version 7.0+ and PDO.

You will also need to create a table, where to store the **identities**. The example schema is available [here](https://github.com/teresko/palladium/blob/master/resources/schema.sql). It currently contains only table definition for MySQL/MariaDB, but the library can be used with any RDBMS, that has a PDO driver.

Initialization
--------------

[](#initialization)

Palladium contains 4 services: `Registration`, `Identification`, `Search` and `Recovery`. Each of these services has two mandatory dependencies:

- repository (that implements `Palladium\Contract\CanPersistIdenity`)
- logger (that implements `Psr\Log\LoggerInterface`)

This gives you an option to replace the default [repository](https://github.com/teresko/palladium/blob/master/src/Palladium/Repository/Identity.php), if you want to alter or replace parts of persistence abstraction layer. As for logger - the recommended approach is to use [Monolog](https://packagist.org/packages/monolog/monolog), but it would work with any compatible logging system.

The default repository also comes with functionality for adding **custom identity types** and data mappers, that are used for either your or the built-in identity types. For usage details see %TODO% section.

#### Optional parameters

[](#optional-parameters)

In the constructor of `Identification` service there is an optional third and fourth parameter:

- lifespan of the cookie (in seconds), which defaults to 4 hours.
- hash cost (for BCrypt), which defaults to 12

In the constructor of `Registration` service there is an optional third parameter:

- hash cost (for BCrypt), which defaults to 12

#### Setting up the repository

[](#setting-up-the-repository)

As noted above, all 4 of the services expect a repository as a constructor dependency. If you are not replacing the bundled repository with your custome version, then you will need to initialize `Palladium\Repository\Identity` and pass it to the services.

The bundled repository itself has a single dependency: instance, that implements `Palladium\Contract\CanCreateMapper`. This contract (interface) is implemented by `Palladium\Component\MapperFactory`. And this factory has two dependencies: `PDO` instance and the name of table, where the **identities** will be stored.

```
