Download the PHP package tiqr/tiqr-server-libphp without Composer
On this page you can find all versions of the php package tiqr/tiqr-server-libphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiqr/tiqr-server-libphp
More information about tiqr/tiqr-server-libphp
Files in tiqr/tiqr-server-libphp
Package tiqr-server-libphp
Short Description php library for tiqr authentication.
License BSD-3-Clause
Informations about the package tiqr-server-libphp
tiqr-server-libphp
A PHP library for implementing a Tiqr authentication server
The library includes a test server, see its README for details. Read the included SECURITY.md for security considerations when using this library.
Introduction
This project is a PHP implementation of a library to implement a Tiqr server. This library is not a server by itself, instead it contains functionality that help Tiqr server implementations with several tasks. You need to write the code to provide the HTTP API for the Tiqr client, and to create the web interface that the user interacts with for enrolling and authentication. This library helps with a large part of this, including:
- Handling of authentications and registration flows of the Tiqr protocol (OCRA)
- Storing of user authentication and user secret data
- Sending of push notification (Firebase Cloud Messaging, Apple Push Notifications)
- Storing of application state (for state persistency during registration and authentication workflows)
When implementing Tiqr you will need to understand the Tiqr protocol. This is documented in the Tiqr protocol documentation.
Who should use this library?
Basically anyone who wants to implement a Tiqr server for their Tiqr client Apps (Android & iOS).
History
A brief overview of notable points in time of this project
- 2010: This project was initially created in 2010
- 2012: The project was moved from a local SVN to GitHub
- 2014: The UserSecretStorage and the Ocra implementation was created
- 2015: GCM push message support was added, and several cleanup tasks where performed
- 2019: FCM push message support was added
- 2020: PHP 5 support was dropped
- 2022: Unit & integration test coverage was added, added TestServer
- 2022: 3.3: Major refactoring of UserStorage and UserSecretStorage classes, addition of PSR Logging, removal of deprecated functionality, security hardening
- 2023: 4.0: Switch to composer autoloader, add PHP 8 support, remove APNS v1 and Zend library dependency
- 2024: 4.1: Update FCM to use HTTP v1 API for google PN's, add openssl encryption type for UserSecretStorage
Ecosystem
The tiqr-server-libphp uses external libraries sparingly. It uses libraries for sending push notifications and for generating QR code images.
The rest of the library code is vanilla PHP code.
For testing purposes we use additional dev-dependencies. They include well know testing tools like PHPUnit and Mockery.
TestServer
The library includes a TestServer README for more information.
Future strategy
- Having a robust test coverage on the code should have a high priority on every new feature created or bug fixed.
Using the library
If you seek to implement a Tiqr server yourself, you can look at how this library is used by the Tiqr GSSP. Tiqr is an important second factor authentication method in the OpenConext Stepup ecosystem and this library is used by the Tiqr GSSP.
Another example for using this library is the Tiqr TestServer that is included with the library
The API of the tiqr-server-libphp can be found in classes starting Tiqr_
in library/tiqr/Tiqr
. Notable classes found here are:
- Tiqr_Service the main service class implementing the utility functions to handle user enrollement and authentication from a Tiqr Server.
- Factories for creating UserSecretStorage.php for different storage backends.
Security
Please read the included SECURITY.md for important security considerations when using Tiqr and using this library.
Creating the Service
An example on how to configure, create and work with the Tiqr Service
.
Config
To create the Tiqr Service you need to provide it with configuration options for the Tiqr_StateStorage_PDO).
The documentation of all the configuration options can be found in the Tiqr_Service class.
The APNS and FCM configuration and the Token exchange configuration is only required for sending Push Notifications to iOS and Android clients. These push notifications are an optional alternative way to start an authentication for a know user and require you to release your own app, under your own name. When not using push notifications the user must always scan a QR code.
See this instructions for generating the firebase.projectId
and firebase.credentialsFile
Autoloading and composer
Add the library to your project using composer. I.e.:
and include the vendor/autoload.php
generated by composer:
Creation
Creating the Tiqr_Service
is now as simple as creating a new instance with the configuration
Example Usage
The service has 22 public methods that are used to enroll a new user, but also to run authentications. The purpose of this section is not to be an API documentation. But an example is shown on how the service methods behave.
For more comprehensible examples on how to work with the Tiqr library, have a look at the Tiqr TestServer implementation. It can be found TiqrFactory.
Logging
We put a lot of effort adding relevant logging to the library. Logging adheres to the PSR-3 logging standard. Services, Repositories and other helper classes in the library are configured with a LoggerInterface instance when they are instantiated. Your application should have a logging solution that can fit into that. Otherwise, we suggest looking at Monolog as a logging solution that is very flexible, and adheres to the PSR-3 standard.
In practice, when creating the Tiqr_Service, you need to inject your Logger in the constructor. The factory classes also ask for a logger instance, for example: when creating a user secret storage.
An example using Monolog (your framework will allow you to DI the logger into your own tiqr service implementation):
UserStorage and UserSecretStorage
The UserSecretStorage.php are used to store Tiqr user account data (UserStorage) and to store the user's OCRA secret (UserSecretStorage). The use of both classes is optional as you provide Tiqr_Service() with the userid and secret, these can come from anywhere. The 'file' type is more suitable for testing and development. The 'pdo' type is intended for production use.
The UserSecretStorage supports encrypting the user secret using e.g. an AES key. You can also provide your own encrpytion implementation. See UserSecretStorage.php for more information.
Example UserStorage and UserSecretStorage usage
Example using a single mysql 'user' table for user and user secret storage, the user's secret is stored encrypted using an AES key.
Create a user storage table in MySQL
Create and configure the UserStorage and UserSecretStorage classes
Running tests
A growing set of unit tests can and should be used when developing the tiqr-server-libphp project.
To run all te QA tests:
After composer install
, you can run the individual tests from the /qa/ci/
directory. E.g. to run phpunit tests only:
All versions of tiqr-server-libphp with dependencies
ext-gd Version *
ext-curl Version *
ext-json Version *
psr/log Version ^3.0
edamov/pushok Version ^0.16.0
ext-openssl Version *
chillerlan/php-qrcode Version ^3.4
google/apiclient Version ^2.14
cache/filesystem-adapter Version ^1