This repository includes a sample project to illustrate the usage of the JobRouter® Authentication Factor API.

Overview

JR 2FA Example Plugin

This repository includes a sample project to illustrate the usage of the JobRouter® Authentication Factor API.

It can be used as a starting point for developing a custom 2nd authentication factor for the JobRouter® 2FA workflow, and also provides a practical reference and examples for the API methods and functionality.



Project status

🔥 The Authentication Factor API is still in a very early alpha state. Before moving into a mature beta phase, that API is likely to change and custom plugins may stop working.
We encourage everyone to experiment with it and give us feedback about it.

Requirements

  • Composer 2

General usage

Clone this repository and run composer install, or create an empty repository and install the API stubs as documented in the Authentication Factor API package.

Create a new directory for your custom plugin and implement the required classes according to the example project and this documentation.

The finished plugin must then be included in the /plugins directory of your JobRouter®.
(E.g.: /jobrouter/plugins/com.example.authentication)

Naming convention

Your plugin is identified by an author (e.g. your company, developer or publisher) and a plugin name which should be used consistently throughout your files and code (exemplified here with the author Example and plugin name Authentication):

  • Plugin root directory: com. . (com.example.authentication)
  • Plugin class namespace: \ (Example\Authentication)
  • Authenticator class namespace: \ \Factor (Example\Authentication\Factor)
  • Prefix for language constants: CONST_AUTHOR_PLUGIN_NAME_ (CONST_EXAMPLE_AUTHENTICATION_)

Project structure

2fa-example-plugin
├─ com.example.authentication       -> plugin root
|  ├─ Factor
|  |  └─ ExampleAuthenticator.php   -> authenticator class
|  ├─ languages
|  |  ├─ english.php                -> English translations
|  |  |  ...                        -> additional translations
|  └─ Plugin.php                    -> plugin class
├─ vendor
|  ├─ jobrouter
|  |  └─ authentication-factor-api  -> Authentication Factor API package
|  |     |  ...
|  |  ...
├─ README.md
|  ...

Plugin class

The Plugin class registers your custom plugin within an internal registry so it can be used in your JobRouter®. Refer to the example Plugin.php file for details on its class structure and implementation.

This class must provide a public load method. Instantiate an ExtensionTypeOperator object using the $registry object passed in the method call, then call registerTranslations on this object with the path to your plugin /languages directory as a parameter, and registerAuthenticationFactor with the following parameters:

  • The internal identifier of your Authenticator (e.g. example_authenticator)
  • Fully qualified class name of your Authenticator (e.g. Example\\Authentication\\Factor\\ExampleAuthenticator)

Please note that stubs are not provided for PluginInterface, ExtensionRegistry and ExtensionTypeOperator as they are not part of the public API and may change in the future. You may have to update projects based on this version of the API to reflect these changes in upcoming releases.

Authenticator class

The Authenticator class contains the logic and execution of your custom authentication method. The provided ExampleAuthenticator.php demonstrates this with an example of 2FA via e-mail. All methods in this example are available via the Authentication Factor API.

In this example, a random numeric PIN is generated, sent to the user via e-mail and saved in a session variable, which is then checked against the PIN entered by the user in the next step of the authentication process. You will also find examples of the Exception types available for the 2FA process and how to work with the Runtime, Logger and User objects provided by the API.

Refer to the documentation of the API stubs for further descriptions on the provided methods and those required by the AuthenticationFactorInterface.

Internationalization (i18n)

You can use language constants in your classes to display strings according to the current user's language. Create a /languages/ .php file for any language you want to support and define your constants there. Take care to follow the naming convention described above to avoid potential conflicts.

The priority in which languages are loaded is user language -> system language -> English as fallback, in case none of the other languages are found in /languages.

You might also like...
Two-Factor Authentication for all your users out-of-the-box.

Two Factor On-premises Two-Factor Authentication for all your users out of the box. use Illuminate\Support\Facades\Auth; use Laragear\TwoFactor\TwoFac

PHP library for Two Factor Authentication (TFA / 2FA)
PHP library for Two Factor Authentication (TFA / 2FA)

PHP library for Two Factor Authentication PHP library for two-factor (or multi-factor) authentication using TOTP and QR-codes. Inspired by, based on b

Library to manage HTTP authentication with PHP. Includes ServiceProviders for easy Laravel integration.

Intervention HttpAuth Library to manage HTTP authentication with PHP. Includes ServiceProviders for easy Laravel integration. Installation You can ins

It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

Single file PHP that can serve as a JWT based authentication provider to the PHP-CRUD-API project

Single file PHP that can serve as a JWT based authentication provider to the PHP-CRUD-API project

A Simple method to create laravel authentication for an existing laravel project.
A Simple method to create laravel authentication for an existing laravel project.

Laravel Simple Auth A Simple method to create laravel authentication for an existing laravel project. Indroduction Why I created this kind of package?

Authentication REST-API built with Lumen PHP Framework

Authentication REST-API built with Lumen PHP Framework Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expre

Laravel passport authentication API endpoints

Basic sample code for Laravel/Passport to authenticate users via API

Owner
JobRouter
JobRouter
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

Rinvex Authy Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest AP

Rinvex 34 Feb 14, 2022
PHP library for Two Factor Authentication (TFA / 2FA)

PHP library for Two Factor Authentication PHP library for two-factor (or multi-factor) authentication using TOTP and QR-codes. Inspired by, based on b

Rob Janssen 896 Dec 30, 2022
Vendor-Agnostic Two-Factor Authentication

Multi-Factor Designed to be a vendor-agnostic implementation of various Two-Factor Authentication solutions. Developed by Paragon Initiative Enterpris

Paragon Initiative Enterprises 139 Dec 21, 2022
Redirects any user which hasn't setup two factor authentication yet to /2fa/

force-two-factor Redirects any user which hasn't setup two factor authentication yet to /2fa/. Use together with the forked two-factor plugin at https

Aiwos 0 Dec 24, 2021
PHP class to generate and verify Google Authenticator 2-factor authentication

Google Authenticator PHP class Copyright (c) 2012-2016, http://www.phpgangsta.de Author: Michael Kliewe, @PHPGangsta and contributors Licensed under t

Michael Kliewe 2.1k Jan 2, 2023
Secure WordPress login with two factor authentication

This plugin allows you to secure your WordPress login with two factor authentication. The users will have to enter a one time password every time they log in.

Volodymyr Kolesnykov 6 Nov 2, 2022
A simple two factor authentication for laravel applications

Laravel 2fa A simple two factor authentication for laravel applications. Installation Require via composer Update database Replace authentication trai

Rezkonline 1 Feb 9, 2022
Laravel Two-Factor Authentication

This package allow you to enable two-factor authentication in your Laravel applications very easily, without the need to add middleware or any modification to your routes. It stores tokens in your database in a distinct table, so you don't need to alter your users table. Notify users about their token via mail, SMS or any custom channel.

null 7 Jun 24, 2022
Google Two-Factor Authentication Package for Laravel

Google2FA for Laravel Google Two-Factor Authentication Package for Laravel Google2FA is a PHP implementation of the Google Two-Factor Authentication M

Antonio Carlos Ribeiro 785 Dec 31, 2022
Multi-factor Authentication using a Public PGP key for web based applications

PGPmfa() a PHP Class for PGP Multi-factor Authentication using a Public PGP key for web based applications Multi-factor Authentication with PGP Second

null 2 Nov 27, 2022