From b5081733c6ea768798a05be27c4223c2bb6aae7f Mon Sep 17 00:00:00 2001 From: Martin Brecht-Precht Date: Mon, 18 Jan 2021 17:47:34 +0100 Subject: [PATCH] Switched the root namespace and vendor prefix --- LICENSE | 2 +- README.md | 44 +++++++++---------- composer.json | 14 +++--- src/Exception/ParserException.php | 8 ++-- src/Exception/ValidationFailedException.php | 8 ++-- .../SharedSecretQrCodeProvider.php | 12 ++--- .../Base/SharedSecretUrlEncoderInterface.php | 4 +- .../HotpBase32SharedSecretUrlEncoder.php | 4 +- .../HotpSharedSecretUrlEncoder.php | 4 +- .../TotpBase32SharedSecretUrlEncoder.php | 4 +- .../TotpSharedSecretUrlEncoder.php | 4 +- .../Oath/Base/OathBaseValidator.php | 9 ++-- src/Validation/Oath/HotpValidator.php | 4 +- src/Validation/Oath/TotpValidator.php | 4 +- src/Validation/YubicoOtp/Parser.php | 6 +-- src/Validation/YubicoOtp/Validator.php | 11 ++--- .../SharedSecretQrCodeProviderTest.php | 30 ++++++------- .../SharedSecretUrlEncoderTest.php | 20 ++++----- test/Validation/Oath/ValidatorTest.php | 4 +- test/Validation/YubicoOtp/ParserTest.php | 6 +-- test/Validation/YubicoOtp/ValidatorTest.php | 6 +-- 21 files changed, 106 insertions(+), 102 deletions(-) diff --git a/LICENSE b/LICENSE index efdbef2..2ee9c3a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH +Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a5b08d9..4d25bba 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # PHP Oath Server Suite -[![Build Status](https://travis-ci.org/markenwerk/php-oath-server-suite.svg?branch=master)](https://travis-ci.org/markenwerk/php-oath-server-suite) -[![Test Coverage](https://codeclimate.com/github/markenwerk/php-oath-server-suite/badges/coverage.svg)](https://codeclimate.com/github/markenwerk/php-oath-server-suite/coverage) +[![Build Status](https://travis-ci.org/chroma-x/php-oath-server-suite.svg?branch=master)](https://travis-ci.org/chroma-x/php-oath-server-suite) +[![Test Coverage](https://codeclimate.com/github/chroma-x/php-oath-server-suite/badges/coverage.svg)](https://codeclimate.com/github/chroma-x/php-oath-server-suite/coverage) [![Dependency Status](https://www.versioneye.com/user/projects/571f771cfcd19a0045442330/badge.svg)](https://www.versioneye.com/user/projects/571f771cfcd19a0045442330) [![SensioLabs Insight](https://img.shields.io/sensiolabs/i/8f5a3440-ec20-448b-b459-057eecbc5d4a.svg)](https://insight.sensiolabs.com/projects/8f5a3440-ec20-448b-b459-057eecbc5d4a) -[![Code Climate](https://codeclimate.com/github/markenwerk/php-oath-server-suite/badges/gpa.svg)](https://codeclimate.com/github/markenwerk/php-oath-server-suite) -[![Latest Stable Version](https://poser.pugx.org/markenwerk/oath-server-suite/v/stable)](https://packagist.org/packages/markenwerk/oath-server-suite) -[![Total Downloads](https://poser.pugx.org/markenwerk/oath-server-suite/downloads)](https://packagist.org/packages/markenwerk/oath-server-suite) -[![License](https://poser.pugx.org/markenwerk/oath-server-suite/license)](https://packagist.org/packages/markenwerk/oath-server-suite) +[![Code Climate](https://codeclimate.com/github/chroma-x/php-oath-server-suite/badges/gpa.svg)](https://codeclimate.com/github/chroma-x/php-oath-server-suite) +[![Latest Stable Version](https://poser.pugx.org/chroma-x/oath-server-suite/v/stable)](https://packagist.org/packages/chroma-x/oath-server-suite) +[![Total Downloads](https://poser.pugx.org/chroma-x/oath-server-suite/downloads)](https://packagist.org/packages/chroma-x/oath-server-suite) +[![License](https://poser.pugx.org/chroma-x/oath-server-suite/license)](https://packagist.org/packages/chroma-x/oath-server-suite) A collection of classes to provide second factor authentication like Yubico OTP (Yubikey), Oath (TOTP, HOTP, GoogleAuthenticator) server-side. @@ -24,7 +24,7 @@ For more information about the Yubico OTP authentication mechanism read the „W ```{json} { "require": { - "markenwerk/oath-server-suite": "~4.0" + "chroma-x/oath-server-suite": "~4.0" } } ``` @@ -46,7 +46,7 @@ To use Yubico OTP you need YubiCloud access. You can get free API credentials fr #### Validating a Yubico one time password ```{php} -use Markenwerk\CommonException\NetworkException\Base\NetworkException; +use ChromaX\CommonException\NetworkException\Base\NetworkException; $otp = $_POST['otp']; $userPublicId = 'fetchedFromDatabaseOrSimilar'; @@ -77,9 +77,9 @@ To allow authentication the client and server has to share a secret. Usually the ##### TOTP (Time-based One-time Password Algorithm) ```{php} -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\TotpBase32SharedSecretUrlEncoder; -use Markenwerk\QrCodeSuite\QrEncode\QrEncoder; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\TotpBase32SharedSecretUrlEncoder; +use ChromaX\QrCodeSuite\QrEncode\QrEncoder; // Initialize Oath URL encoder for TOTP (Time-based One-time Password Algorithm) $contentEncoder = new TotpBase32SharedSecretUrlEncoder(); @@ -114,9 +114,9 @@ $sharedSecretQrProvider->provideQrCode('/path/to/the/qrcode.png'); ##### HOTP (HMAC-based One-time Password Algorithm) ```{php} -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\HotpBase32SharedSecretUrlEncoder; -use Markenwerk\QrCodeSuite\QrEncode\QrEncoder; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\HotpBase32SharedSecretUrlEncoder; +use ChromaX\QrCodeSuite\QrEncode\QrEncoder; // Initialize Oath URL encoder for HOTP (HMAC-based One-time Password Algorithm) $contentEncoder = new HotpBase32SharedSecretUrlEncoder(); @@ -190,9 +190,9 @@ if ($validator->isValid()) { ##### TOTP (Time-based One-time Password Algorithm) ```{php} -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\TotpSharedSecretUrlEncoder; -use Markenwerk\QrCodeSuite\QrEncode\QrEncoder; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\TotpSharedSecretUrlEncoder; +use ChromaX\QrCodeSuite\QrEncode\QrEncoder; // Initialize Oath URL encoder for TOTP (Time-based One-time Password Algorithm) $contentEncoder = new TotpSharedSecretUrlEncoder(); @@ -227,9 +227,9 @@ $sharedSecretQrProvider->provideQrCode('/path/to/the/qrcode.png'); ##### HOTP (HMAC-based One-time Password Algorithm) ```{php} -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; -use Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\HotpSharedSecretUrlEncoder; -use Markenwerk\QrCodeSuite\QrEncode\QrEncoder; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider\SharedSecretQrCodeProvider; +use ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\HotpSharedSecretUrlEncoder; +use ChromaX\QrCodeSuite\QrEncode\QrEncoder; // Initialize Oath URL encoder for HOTP (HMAC-based One-time Password Algorithm) $contentEncoder = new HotpSharedSecretUrlEncoder(); @@ -299,14 +299,14 @@ if ($validator->isValid()) { ## Exception handling PHP Oath Server Suite provides different exceptions – some provided by the PHP Common Exceptions project – for proper handling. -You can find more information about [PHP Common Exceptions at Github](https://github.com/markenwerk/php-common-exceptions). +You can find more information about [PHP Common Exceptions at Github](https://github.com/chroma-x/php-common-exceptions). --- ## Contribution Contributing to our projects is always very appreciated. -**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/markenwerk/php-oath-server-suite/blob/master/CONTRIBUTING.md) document.** +**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-oath-server-suite/blob/master/CONTRIBUTING.md) document.** ## License diff --git a/composer.json b/composer.json index 7f089ea..24b154d 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "markenwerk/oath-server-suite", + "name": "chroma-x/oath-server-suite", "type": "library", "description": "A collection of classes to provide second factor authentication like Yubico OTP (Yubikey), Oath (TOTP, HOTP, GoogleAuthenticator) server-side.", "keywords": [ @@ -11,25 +11,25 @@ "yubico", "google authenticator" ], - "homepage": "http://markenwerk.net/", + "homepage": "http://chroma-x.de/", "license": "MIT", "authors": [ { "name": "Martin Brecht-Precht", - "email": "mb@markenwerk.net", - "homepage": "http://markenwerk.net" + "email": "mb@chroma-x.de", + "homepage": "http://chroma-x.de" } ], "autoload": { "psr-4": { - "Markenwerk\\OathServerSuite\\": "src/" + "ChromaX\\OathServerSuite\\": "src/" } }, "require": { "php": ">=5.3", "lib-curl": "*", - "markenwerk/common-exceptions": "~3.0", - "markenwerk/qr-code-suite": "~4.0", + "chroma-x/common-exceptions": "~3.0", + "chroma-x/qr-code-suite": "~4.0", "enygma/yubikey": "~3.0", "skleeschulte/base32": "*" }, diff --git a/src/Exception/ParserException.php b/src/Exception/ParserException.php index 34a2530..2f8a9ce 100644 --- a/src/Exception/ParserException.php +++ b/src/Exception/ParserException.php @@ -1,13 +1,15 @@ hashHmac($sharedSecret, $counter); - $hmacHashTruncated = $this->truncateHash($hmacHash, $this->passwordLength); + $hmacHashTruncated = self::truncateHash($hmacHash, $this->passwordLength); return str_pad($hmacHashTruncated, $this->passwordLength, '0', STR_PAD_LEFT); } @@ -45,8 +45,7 @@ protected function calculateValidHotp($sharedSecret, $counter) private function hashHmac($secret, $counter) { $binCounter = pack('N*', 0) . pack('N*', $counter); - $hash = hash_hmac('sha1', $binCounter, $secret, true); - return $hash; + return hash_hmac('sha1', $binCounter, $secret, true); } /** diff --git a/src/Validation/Oath/HotpValidator.php b/src/Validation/Oath/HotpValidator.php index 54e8e61..3374f95 100644 --- a/src/Validation/Oath/HotpValidator.php +++ b/src/Validation/Oath/HotpValidator.php @@ -1,11 +1,11 @@ yubiCloudSecretKey, $this->yubiCloudClientId); $response = $yubicoApi->check($otp); - } catch (\Exception $exception) { + } catch (Exception $exception) { throw new NetworkException('YubiCloud webservice access failed.', 0, $exception); } $this->valid = $response->success(); diff --git a/test/SecretSharing/SharedSecretQrCodeProvider/SharedSecretQrCodeProviderTest.php b/test/SecretSharing/SharedSecretQrCodeProvider/SharedSecretQrCodeProviderTest.php index f15e9eb..43e78f2 100644 --- a/test/SecretSharing/SharedSecretQrCodeProvider/SharedSecretQrCodeProviderTest.php +++ b/test/SecretSharing/SharedSecretQrCodeProvider/SharedSecretQrCodeProviderTest.php @@ -1,31 +1,31 @@ getQrEncoder() ->setLevel(QrEncoder::QR_CODE_LEVEL_LOW) ->setTempDir(__DIR__ . '/tmp/'); @@ -56,7 +56,7 @@ public function testHotpBase32ProvideQrCode() public function testTotpBase32ProvideQrCode() { // Init QR code renderer - $sharedSecretQrCodeProvider = new SharedSecretQrCodeProvider(new TotpBase32SharedSecretUrlEncoder(), 'Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretQrCodeProvider = new SharedSecretQrCodeProvider(new TotpBase32SharedSecretUrlEncoder(), 'Awesome Application', self::SHARED_SECRET, 'ChromaX'); $sharedSecretQrCodeProvider->getQrEncoder() ->setLevel(QrEncoder::QR_CODE_LEVEL_LOW) ->setTempDir(__DIR__ . '/tmp/'); @@ -87,7 +87,7 @@ public function testTotpBase32ProvideQrCode() public function testHotpProvideQrCode() { // Init QR code renderer - $sharedSecretQrCodeProvider = new SharedSecretQrCodeProvider(new HotpSharedSecretUrlEncoder(), 'Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretQrCodeProvider = new SharedSecretQrCodeProvider(new HotpSharedSecretUrlEncoder(), 'Awesome Application', self::SHARED_SECRET, 'ChromaX'); $sharedSecretQrCodeProvider->getQrEncoder() ->setLevel(QrEncoder::QR_CODE_LEVEL_LOW) ->setTempDir(__DIR__ . '/tmp/'); @@ -118,7 +118,7 @@ public function testHotpProvideQrCode() public function testTotpProvideQrCode() { // Init QR code renderer - $sharedSecretQrCodeProvider = new SharedSecretQrCodeProvider(new TotpSharedSecretUrlEncoder(), 'Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretQrCodeProvider = new SharedSecretQrCodeProvider(new TotpSharedSecretUrlEncoder(), 'Awesome Application', self::SHARED_SECRET, 'ChromaX'); $sharedSecretQrCodeProvider->getQrEncoder() ->setLevel(QrEncoder::QR_CODE_LEVEL_LOW) ->setTempDir(__DIR__ . '/tmp/'); diff --git a/test/SecretSharing/SharedSecretUrlEncoder/SharedSecretUrlEncoderTest.php b/test/SecretSharing/SharedSecretUrlEncoder/SharedSecretUrlEncoderTest.php index 3afb02d..84360cc 100644 --- a/test/SecretSharing/SharedSecretUrlEncoder/SharedSecretUrlEncoderTest.php +++ b/test/SecretSharing/SharedSecretUrlEncoder/SharedSecretUrlEncoderTest.php @@ -1,46 +1,46 @@ encode('Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'ChromaX'); $this->assertEquals(self::EXPECTED_HOTP_BASE32_SHARED_SECRET_URL, $sharedSecretUrl); } public function testTotpBase32UrlEncode() { $sharedSecretUrlEncoder = new TotpBase32SharedSecretUrlEncoder(); - $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'ChromaX'); $this->assertEquals(self::EXPECTED_TOTP_BASE32_SHARED_SECRET_URL, $sharedSecretUrl); } public function testHotpUrlEncode() { $sharedSecretUrlEncoder = new HotpSharedSecretUrlEncoder(); - $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'ChromaX'); $this->assertEquals(self::EXPECTED_HOTP_SHARED_SECRET_URL, $sharedSecretUrl); } public function testTotpUrlEncode() { $sharedSecretUrlEncoder = new TotpSharedSecretUrlEncoder(); - $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'Markenwerk'); + $sharedSecretUrl = $sharedSecretUrlEncoder->encode('Awesome Application', self::SHARED_SECRET, 'ChromaX'); $this->assertEquals(self::EXPECTED_TOTP_SHARED_SECRET_URL, $sharedSecretUrl); } diff --git a/test/Validation/Oath/ValidatorTest.php b/test/Validation/Oath/ValidatorTest.php index 6b88905..43daff6 100644 --- a/test/Validation/Oath/ValidatorTest.php +++ b/test/Validation/Oath/ValidatorTest.php @@ -1,11 +1,11 @@ assertEquals(false, $validator->isValid()); // Parser $parser = $validator->getOtpParser(); - $this->assertInstanceOf('\Markenwerk\OathServerSuite\Validation\YubicoOtp\Parser', $parser); + $this->assertInstanceOf('\ChromaX\OathServerSuite\Validation\YubicoOtp\Parser', $parser); } }