This repository has been archived by the owner on Mar 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
2,053 additions
and
1,584 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
src/Eloquent/Otis/Configuration/AbstractCounterBasedOtpConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
use Eloquent\Otis\Exception\InvalidPasswordLengthException; | ||
|
||
/** | ||
* An abstract base class for creating counter-based one-time password | ||
* authentication configurations. | ||
*/ | ||
abstract class AbstractCounterBasedOtpConfiguration | ||
extends AbstractOtpConfiguration | ||
implements CounterBasedOtpConfigurationInterface | ||
{ | ||
/** | ||
* Construct a new counter-based one-time password authentication | ||
* configuration. | ||
* | ||
* @param integer|null $digits The number of password digits. | ||
* @param integer|null $window The amount of counter increments to search through for a match. | ||
* @param integer|null $initialCounter The initial counter value. | ||
* @param integer|null $secretLength The length of the shared secret. | ||
* | ||
* @throws InvalidPasswordLengthException If the number of digits is invalid. | ||
*/ | ||
public function __construct( | ||
$digits = null, | ||
$window = null, | ||
$initialCounter = null, | ||
$secretLength = null | ||
) { | ||
if (null === $window) { | ||
$window = 10; | ||
} | ||
if (null === $initialCounter) { | ||
$initialCounter = 1; | ||
} | ||
|
||
parent::__construct($digits, $secretLength); | ||
|
||
$this->window = $window; | ||
$this->initialCounter = $initialCounter; | ||
} | ||
|
||
/** | ||
* Get the amount of counter increments to search through for a match. | ||
* | ||
* @return integer The amount of counter increments to search through for a match. | ||
*/ | ||
public function window() | ||
{ | ||
return $this->window; | ||
} | ||
|
||
/** | ||
* Get the initial counter value. | ||
* | ||
* @return integer The initial counter value. | ||
*/ | ||
public function initialCounter() | ||
{ | ||
return $this->initialCounter; | ||
} | ||
|
||
private $window; | ||
private $initialCounter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/Eloquent/Otis/Configuration/AbstractTimeBasedOtpConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
use Eloquent\Otis\Exception\InvalidPasswordLengthException; | ||
|
||
/** | ||
* An abstract base class for creating time-based one-time password | ||
* authentication configurations. | ||
*/ | ||
abstract class AbstractTimeBasedOtpConfiguration | ||
extends AbstractOtpConfiguration | ||
implements TimeBasedOtpConfigurationInterface | ||
{ | ||
/** | ||
* Construct a new time-based one-time password authentication | ||
* configuration. | ||
* | ||
* @param integer|null $digits The number of password digits. | ||
* @param integer|null $window The number of seconds each token is valid for. | ||
* @param integer|null $futureWindows The number of future windows to check. | ||
* @param integer|null $pastWindows The number of past windows to check. | ||
* @param integer|null $secretLength The length of the shared secret. | ||
* | ||
* @throws InvalidPasswordLengthException If the number of digits is invalid. | ||
*/ | ||
public function __construct( | ||
$digits = null, | ||
$window = null, | ||
$futureWindows = null, | ||
$pastWindows = null, | ||
$secretLength = null | ||
) { | ||
if (null === $window) { | ||
$window = 30; | ||
} | ||
if (null === $futureWindows) { | ||
$futureWindows = 1; | ||
} | ||
if (null === $pastWindows) { | ||
$pastWindows = 1; | ||
} | ||
|
||
parent::__construct($digits, $secretLength); | ||
|
||
$this->window = $window; | ||
$this->futureWindows = $futureWindows; | ||
$this->pastWindows = $pastWindows; | ||
} | ||
|
||
/** | ||
* Get the number of seconds each token is valid for. | ||
* | ||
* @return integer The number of seconds each token is valid for. | ||
*/ | ||
public function window() | ||
{ | ||
return $this->window; | ||
} | ||
|
||
/** | ||
* Get the number of future windows to check. | ||
* | ||
* @return integer The number of future windows to check. | ||
*/ | ||
public function futureWindows() | ||
{ | ||
return $this->futureWindows; | ||
} | ||
|
||
/** | ||
* Get the number of past windows to check. | ||
* | ||
* @return integer The number of past windows to check. | ||
*/ | ||
public function pastWindows() | ||
{ | ||
return $this->pastWindows; | ||
} | ||
|
||
private $window; | ||
private $futureWindows; | ||
private $pastWindows; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Eloquent/Otis/Configuration/CounterBasedOtpConfigurationInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
/** | ||
* The interface implemented by counter-based one-time password authentication | ||
* configurations. | ||
*/ | ||
interface CounterBasedOtpConfigurationInterface extends | ||
OtpConfigurationInterface | ||
{ | ||
/** | ||
* Get the amount of counter increments to search through for a match. | ||
* | ||
* @return integer The amount of counter increments to search through for a match. | ||
*/ | ||
public function window(); | ||
|
||
/** | ||
* Get the initial counter value. | ||
* | ||
* @return integer The initial counter value. | ||
*/ | ||
public function initialCounter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php // @codeCoverageIgnoreStart | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
|
32 changes: 32 additions & 0 deletions
32
src/Eloquent/Otis/Configuration/OtpConfigurationInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
/** | ||
* The interface implemented by one-time password authentication configurations. | ||
*/ | ||
interface OtpConfigurationInterface extends MfaConfigurationInterface | ||
{ | ||
/** | ||
* Get the number of password digits. | ||
* | ||
* @return integer The number of digits. | ||
*/ | ||
public function digits(); | ||
|
||
/** | ||
* Get the length of the shared secret. | ||
* | ||
* @return integer The secret length. | ||
*/ | ||
public function secretLength(); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Eloquent/Otis/Configuration/TimeBasedOtpConfigurationInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
* | ||
* Copyright © 2013 Erin Millard | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eloquent\Otis\Configuration; | ||
|
||
/** | ||
* The interface implemented by time-based one-time password authentication | ||
* configurations. | ||
*/ | ||
interface TimeBasedOtpConfigurationInterface extends OtpConfigurationInterface | ||
{ | ||
/** | ||
* Get the number of seconds each token is valid for. | ||
* | ||
* @return integer The number of seconds each token is valid for. | ||
*/ | ||
public function window(); | ||
|
||
/** | ||
* Get the number of future windows to check. | ||
* | ||
* @return integer The number of future windows to check. | ||
*/ | ||
public function futureWindows(); | ||
|
||
/** | ||
* Get the number of past windows to check. | ||
* | ||
* @return integer The number of past windows to check. | ||
*/ | ||
public function pastWindows(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php // @codeCoverageIgnoreStart | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php // @codeCoverageIgnoreStart | ||
<?php | ||
|
||
/* | ||
* This file is part of the Otis package. | ||
|
Oops, something went wrong.