From e9f87c437dc7b40872d55235d4b421ed9424b6cb Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Oct 2020 23:38:56 +0100 Subject: [PATCH 01/23] Add a .gitattributes file Just exclude some non usefull files from vendor tarballs And exclude a future .github folder --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..02b13c8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +.gitattributes export-ignore +.gitignore export-ignore +.github export-ignore From a1dcbf13fdaaaad29e6a6f037a2e1b59a50ba0ea Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Oct 2020 23:43:45 +0100 Subject: [PATCH 02/23] Add some approximate PHP requirements --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 8da2271..9758520 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ } ], "require": { + "php": "^7.1 || ^8.0", "ext-openssl":"*" }, "autoload": { From 81531b754c25023ba918d1dcd1915f53905ddbd9 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Oct 2020 23:43:54 +0100 Subject: [PATCH 03/23] Add cool links to composer.json --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 9758520..9e8e88c 100644 --- a/composer.json +++ b/composer.json @@ -2,12 +2,17 @@ "name": "samyoul/u2f-php-server", "description": "Server side handling class for FIDO U2F registration and authentication", "license":"BSD-2-Clause", + "homepage": "https://github.com/Samyoul/U2F-php-server#readme", "authors": [ { "name": "Samuel Hawksby-Robinson", "email": "samuel@samyoul.com" } ], + "support": { + "issues": "https://github.com/Samyoul/U2F-php-server/issues", + "source": "https://github.com/Samyoul/U2F-php-server" + }, "require": { "php": "^7.1 || ^8.0", "ext-openssl":"*" From d93137119c807e5f717adbdd10074572a11d1a1a Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Oct 2020 23:44:14 +0100 Subject: [PATCH 04/23] Clean source files --- src/Registration.php | 6 ------ src/RegistrationRequest.php | 7 +------ src/SignRequest.php | 6 ------ src/U2FException.php | 6 ------ src/U2FServer.php | 7 +------ 5 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/Registration.php b/src/Registration.php index dbc1c9a..c1ac4d9 100644 --- a/src/Registration.php +++ b/src/Registration.php @@ -1,10 +1,4 @@ Date: Tue, 27 Oct 2020 23:49:27 +0100 Subject: [PATCH 05/23] Rename LICENCE.md to LICENCE --- LICENCE.md => LICENCE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENCE.md => LICENCE (100%) diff --git a/LICENCE.md b/LICENCE similarity index 100% rename from LICENCE.md rename to LICENCE From da93e90a7085a3253b2877c12dc0fba6a4237a71 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Oct 2020 23:50:10 +0100 Subject: [PATCH 06/23] Add support for phpunit --- .gitignore | 1 + composer.json | 9 +++++++++ phpunit.xml | 26 ++++++++++++++++++++++++++ test/VoidTest.php | 13 +++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 phpunit.xml create mode 100644 test/VoidTest.php diff --git a/.gitignore b/.gitignore index 2f238a8..378584b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # IntelliJ project files .idea *.iml +.phpunit.result.cache /vendor/ diff --git a/composer.json b/composer.json index 9e8e88c..22779ee 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,20 @@ "issues": "https://github.com/Samyoul/U2F-php-server/issues", "source": "https://github.com/Samyoul/U2F-php-server" }, + "scripts": { + "phpunit": "./vendor/bin/phpunit" + }, "require": { "php": "^7.1 || ^8.0", "ext-openssl":"*" }, + "require-dev": { + "phpunit/phpunit": "^7 || ^8 || ^9" + }, "autoload": { "psr-4": { "Samyoul\\U2F\\U2FServer\\": ["src/"] } + }, + "autoload-dev": { + "psr-4": { "Samyoul\\U2F\\U2FServer\\Tests\\": ["test/"] } } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..590d5ea --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,26 @@ + + + + + src + + + + + + + + + + + test/ + + + + diff --git a/test/VoidTest.php b/test/VoidTest.php new file mode 100644 index 0000000..e10ef0f --- /dev/null +++ b/test/VoidTest.php @@ -0,0 +1,13 @@ +assertTrue(true); + } +} From a34e9be9fb0a1d20a518e9db0bd9dd86e99f3640 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Oct 2020 23:55:00 +0100 Subject: [PATCH 07/23] Ignore .vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 378584b..8214d68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # IntelliJ project files .idea +.vscode *.iml .phpunit.result.cache /vendor/ From 779225da4d450faf4fddd95f1a4a6183dff840c6 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 30 Oct 2020 15:47:25 +0100 Subject: [PATCH 08/23] Improvements to README.md - Remove uses of compact function - Improve commands highlighting - Improve links - Use HTTPS everywhere - Replace double by single quotes - Use a better licence URL than a fixed one - Fix a typo --- README.md | 126 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 2f17a1f..667e2cc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # U2F-php-server [![Latest Stable Version](https://img.shields.io/packagist/v/samyoul/u2f-php-server.svg?style=flat-square)](https://packagist.org/packages/samyoul/u2f-php-server) -[![License](https://img.shields.io/badge/license-BSD_2_Clause-brightgreen.svg?style=flat-square)](LICENCE.md) +[![GitHub license](https://img.shields.io/github/license/Samyoul/U2F-php-server?style=flat-square)](LICENCE.md) Server-side handling of FIDO U2F registration and authentication for PHP. @@ -65,7 +65,7 @@ A few **things you need** to know before working with this: ### OpenSSL -This repository requires OpenSSL 1.0.0 or higher. For further details on installing OpenSSL please refer to the php manual http://php.net/manual/en/openssl.installation.php . +This repository requires OpenSSL 1.0.0 or higher. For further details on installing OpenSSL please refer to the [php manual](https://www.php.net/manual/en/openssl.installation.php). Also see [Compatibility Code](#compatibility-code), to check if you have the correct version of OpenSSL installed, and are unsure how else to check. @@ -73,7 +73,7 @@ Also see [Compatibility Code](#compatibility-code), to check if you have the cor My presumption is that if you are looking to add U2F authentication to a php system, then you'll probably are also looking for some client-side handling. You've got a U2F enabled USB device and you want to get the USB device speaking with the browser and then with your server running php. -1. Google already have this bit sorted : https://github.com/google/u2f-ref-code/blob/master/u2f-gae-demo/war/js/u2f-api.js +1. Google already have this bit sorted : [u2f-api.js](https://github.com/google/u2f-ref-code/blob/master/u2f-gae-demo/war/js/u2f-api.js) 2. [Mastahyeti](https://github.com/mastahyeti) has created a repo dedicated to Google's JavaScript Client-side API : https://github.com/mastahyeti/u2f-api ### HTTPS and SSL @@ -122,7 +122,7 @@ TODO the descriptions 1. When the browser loads the page the JavaScript fires the `u2f.sign(authenticationRequest, function(data){ // Callback logic })` function 1. The view will use JavaScript / Browser to poll the host machine's ports for a FIDO U2F device 1. Once the HID has been found the JavaScript / Browser will send the sign request with data. -1. The HID will prompt the user to authorise the sign request +1. The HID will prompt the user to authorize the sign request 1. On success the HID returns authentication data 1. The JavaScript receives the HID's returned data and passes it to the server 1. The application takes the returned data passes it to the `U2F::authenticate($authenticationRequest, $registrations, $authenticationResponse)` method @@ -135,10 +135,10 @@ For a full working code example for this repository please see [the dedicated ex You can also install it with the following: -```bash +```sh $ git clone https://github.com/Samyoul/U2F-php-server-examples.git $ cd u2f-php-server-examples -$ composer install +$ composer install ``` @@ -161,7 +161,8 @@ You'll only ever need to use this method call once per installation and only in ```php $jsRequest, + 'jsSignatures' => $jsSignatures, +]); ``` #### Registration Step 2: **Client-side, Talking To The USB** -Non-AJAX client-side registration of U2F key token. AJAX can of course be used in your application, but it is easier to demonstrate a linear process without AJAX and callbacks. +Non-AJAX client-side registration of U2F key token. AJAX can of course be used in your application, but it is easier to demonstrate a linear process without AJAX and callbacks. ```html @@ -214,35 +219,35 @@ Non-AJAX client-side registration of U2F key token. AJAX can of course be used i

U2F Registration

Please enter your FIDO U2F device into your computer's USB port. Then confirm registration on the device.

- +
- +