Skip to content

Commit

Permalink
Switched the root namespace and vendor prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Brecht-Precht committed Jan 18, 2021
1 parent 8069b78 commit b508173
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 102 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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"
}
}
```
Expand All @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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": "*"
},
Expand Down
8 changes: 5 additions & 3 deletions src/Exception/ParserException.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

namespace Markenwerk\OathServerSuite\Exception;
namespace ChromaX\OathServerSuite\Exception;

use Exception;

/**
* Class ParserException
*
* @package Markenwerk\OathServerSuite\Exception
* @package ChromaX\OathServerSuite\Exception
*/
class ParserException extends \Exception
class ParserException extends Exception
{

}
8 changes: 5 additions & 3 deletions src/Exception/ValidationFailedException.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

namespace Markenwerk\OathServerSuite\Exception;
namespace ChromaX\OathServerSuite\Exception;

use Exception;

/**
* Class ValidationFailedException
*
* @package Markenwerk\OathServerSuite\Exception
* @package ChromaX\OathServerSuite\Exception
*/
class ValidationFailedException extends \Exception
class ValidationFailedException extends Exception
{

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace Markenwerk\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider;
namespace ChromaX\OathServerSuite\SecretSharing\SharedSecretQrCodeProvider;

use Markenwerk\QrCodeSuite\QrEncode\QrCode\QrCode;
use Markenwerk\QrCodeSuite\QrEncode\QrEncoder;
use Markenwerk\QrCodeSuite\QrRender\QrCodeRendererPng;
use Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\Base\SharedSecretUrlEncoderInterface;
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCode;
use ChromaX\QrCodeSuite\QrEncode\QrEncoder;
use ChromaX\QrCodeSuite\QrRender\QrCodeRendererPng;
use ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\Base\SharedSecretUrlEncoderInterface;

/**
* Class SharedSecretQrCodeProvider
*
* @package Markenwerk\OathServerSuite\SharedSecretQrCodeProvider
* @package ChromaX\OathServerSuite\SharedSecretQrCodeProvider
*/
class SharedSecretQrCodeProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\Base;
namespace ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder\Base;

/**
* Interface SharedSecretUrlEncoderInterface
*
* @package Markenwerk\OathServerSuite\SharedSecretUrlEncoder\Base
* @package ChromaX\OathServerSuite\SharedSecretUrlEncoder\Base
*/
interface SharedSecretUrlEncoderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;
namespace ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;

use SKleeschulte\Base32;

/**
* Class HotpBase32SharedSecretUrlEncoder
*
* @package Markenwerk\OathServerSuite\SharedSecretUrlEncoder
* @package ChromaX\OathServerSuite\SharedSecretUrlEncoder
*/
class HotpBase32SharedSecretUrlEncoder implements Base\SharedSecretUrlEncoderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;
namespace ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;

/**
* Class HotpSharedSecretUrlEncoder
*
* @package Markenwerk\OathServerSuite\SharedSecretUrlEncoder
* @package ChromaX\OathServerSuite\SharedSecretUrlEncoder
*/
class HotpSharedSecretUrlEncoder implements Base\SharedSecretUrlEncoderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;
namespace ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;

use SKleeschulte\Base32;

/**
* Class TotpBase32SharedSecretUrlEncoder
*
* @package Markenwerk\OathServerSuite\SharedSecretUrlEncoder
* @package ChromaX\OathServerSuite\SharedSecretUrlEncoder
*/
class TotpBase32SharedSecretUrlEncoder implements Base\SharedSecretUrlEncoderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;
namespace ChromaX\OathServerSuite\SecretSharing\SharedSecretUrlEncoder;

/**
* Class TotpSharedSecretUrlEncoder
*
* @package Markenwerk\OathServerSuite\SharedSecretUrlEncoder
* @package ChromaX\OathServerSuite\SharedSecretUrlEncoder
*/
class TotpSharedSecretUrlEncoder implements Base\SharedSecretUrlEncoderInterface
{
Expand Down
9 changes: 4 additions & 5 deletions src/Validation/Oath/Base/OathBaseValidator.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\OathServerSuite\Validation\Oath\Base;
namespace ChromaX\OathServerSuite\Validation\Oath\Base;

/**
* Class OathValidator
*
* @package Markenwerk\OathServerSuite\Validation\Oath\Base
* @package ChromaX\OathServerSuite\Validation\Oath\Base
*/
abstract class OathBaseValidator
{
Expand Down Expand Up @@ -33,7 +33,7 @@ public function getPasswordLength()
protected function calculateValidHotp($sharedSecret, $counter)
{
$hmacHash = $this->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);
}

Expand All @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/Oath/HotpValidator.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\OathServerSuite\Validation\Oath;
namespace ChromaX\OathServerSuite\Validation\Oath;

/**
* Class HotpValidator
*
* @package Markenwerk\OathServerSuite\Validation\Oath
* @package ChromaX\OathServerSuite\Validation\Oath
*/
class HotpValidator extends Base\OathBaseValidator
{
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/Oath/TotpValidator.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\OathServerSuite\Validation\Oath;
namespace ChromaX\OathServerSuite\Validation\Oath;

/**
* Class TotpValidator
*
* @package Markenwerk\OathServerSuite\Validation\Oath
* @package ChromaX\OathServerSuite\Validation\Oath
*/
class TotpValidator extends Base\OathBaseValidator
{
Expand Down
6 changes: 3 additions & 3 deletions src/Validation/YubicoOtp/Parser.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Markenwerk\OathServerSuite\Validation\YubicoOtp;
namespace ChromaX\OathServerSuite\Validation\YubicoOtp;

use Markenwerk\OathServerSuite\Exception\ParserException;
use ChromaX\OathServerSuite\Exception\ParserException;

/**
* Class Parser
*
* Based on the official [YubiCloud PHP client](https://github.com/Yubico/yubico-php-client/blob/master/YubiCloud.php)
*
* @package Markenwerk\OathServerSuite\YubicoOtp
* @package ChromaX\OathServerSuite\YubicoOtp
*/
class Parser
{
Expand Down
11 changes: 6 additions & 5 deletions src/Validation/YubicoOtp/Validator.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

namespace Markenwerk\OathServerSuite\Validation\YubicoOtp;
namespace ChromaX\OathServerSuite\Validation\YubicoOtp;

use Markenwerk\CommonException\NetworkException\Base\NetworkException;
use Markenwerk\OathServerSuite\Exception\ParserException;
use ChromaX\CommonException\NetworkException\Base\NetworkException;
use ChromaX\OathServerSuite\Exception\ParserException;
use Exception;
use Yubikey\Validate;

/**
* Class Validator
*
* @package Markenwerk\OathServerSuite\YubicoOtp
* @package ChromaX\OathServerSuite\YubicoOtp
*/
class Validator
{
Expand Down Expand Up @@ -70,7 +71,7 @@ public function validate($otp, $publicId)
try {
$yubicoApi = new Validate($this->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();
Expand Down
Loading

0 comments on commit b508173

Please sign in to comment.