Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
otphp
Commits
e5b4eed8
Unverified
Commit
e5b4eed8
authored
3 years ago
by
Spomky
Browse files
Options
Download
Patches
Plain Diff
Bugs fixed
parent
b668f63d
11.2.x
11.0.x
11.1.x
dependabot/composer/phpunit/phpunit-tw-9.5.26or-tw-10.0.0
11.1.0
v11.0.2
v11.0.1
v11.0.0
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
doc/UPGRADE_v10-v11.md
+2
-0
doc/UPGRADE_v10-v11.md
doc/index.md
+3
-11
doc/index.md
src/HOTP.php
+3
-3
src/HOTP.php
src/OTPInterface.php
+1
-1
src/OTPInterface.php
src/TOTP.php
+2
-2
src/TOTP.php
with
11 additions
and
17 deletions
+11
-17
doc/UPGRADE_v10-v11.md
+
2
−
0
View file @
e5b4eed8
# Upgrade from `v10.x` to `v11.x`
# Upgrade from `v10.x` to `v11.x`
Congratulation, you have nothing to do!
\ No newline at end of file
This diff is collapsed.
Click to expand it.
doc/index.md
+
3
−
11
View file @
e5b4eed8
...
@@ -18,10 +18,8 @@ Support for the version 9 will end when PHP 7.1 will not be maintained (1 Dec 20
...
@@ -18,10 +18,8 @@ Support for the version 9 will end when PHP 7.1 will not be maintained (1 Dec 20
# Prerequisites
# Prerequisites
This library needs at least
`PHP 7.1`
for v9.0 and
`PHP 7.2`
for v10.0.
This library needs at least
`PHP 8.0`
.
It has been successfully tested using
`PHP 7.1`
,
`PHP 7.2`
,
`PHP 7.3`
.
It has been successfully tested using
`PHP 8.0`
and
`PHP 8.1`
.
Nightly branch (
`PHP 8.0`
) fails as dependencies are not yet compatible.
# Installation
# Installation
...
@@ -31,13 +29,6 @@ The preferred way to install this library is to rely on Composer:
...
@@ -31,13 +29,6 @@ The preferred way to install this library is to rely on Composer:
composer require spomky-labs/otphp
composer require spomky-labs/otphp
```
```
By default, documentation and test environment are excluded.
If you want to test the library or get the documentation, please add
`--prefer-source`
option:
```
sh
composer require spomky-labs/otphp
--prefer-source
```
# TOTP or HOTP?
# TOTP or HOTP?
This library supports both
`TOTP`
and
`HOTP`
.
This library supports both
`TOTP`
and
`HOTP`
.
...
@@ -107,3 +98,4 @@ $otp->verify($input); // Returns true if the input is verified, otherwise false.
...
@@ -107,3 +98,4 @@ $otp->verify($input); // Returns true if the input is verified, otherwise false.
*
[
From `v8.3` to `v9.x`
](
UPGRADE_v8-v9.md
)
*
[
From `v8.3` to `v9.x`
](
UPGRADE_v8-v9.md
)
*
[
From `v9.x` to `v10.x`
](
UPGRADE_v9-v10.md
)
*
[
From `v9.x` to `v10.x`
](
UPGRADE_v9-v10.md
)
*
[
From `v10.x` to `v11.x`
](
UPGRADE_v10-v11.md
)
This diff is collapsed.
Click to expand it.
src/HOTP.php
+
3
−
3
View file @
e5b4eed8
...
@@ -41,7 +41,7 @@ final class HOTP extends OTP implements HOTPInterface
...
@@ -41,7 +41,7 @@ final class HOTP extends OTP implements HOTPInterface
/**
/**
* If the counter is not provided, the OTP is verified at the actual counter.
* If the counter is not provided, the OTP is verified at the actual counter.
*/
*/
public
function
verify
(
string
$otp
,
null
|
int
$counter
=
null
,
null
|
int
|
float
$window
=
null
):
bool
public
function
verify
(
string
$otp
,
null
|
int
$counter
=
null
,
null
|
int
$window
=
null
):
bool
{
{
Assertion
::
greaterOrEqualThan
(
$counter
,
0
,
'The counter must be at least 0.'
);
Assertion
::
greaterOrEqualThan
(
$counter
,
0
,
'The counter must be at least 0.'
);
...
@@ -81,12 +81,12 @@ final class HOTP extends OTP implements HOTPInterface
...
@@ -81,12 +81,12 @@ final class HOTP extends OTP implements HOTPInterface
$this
->
setCounter
(
$counter
);
$this
->
setCounter
(
$counter
);
}
}
private
function
getWindow
(
null
|
int
|
float
$window
):
int
|
float
private
function
getWindow
(
null
|
int
$window
):
int
{
{
return
abs
(
$window
??
0
);
return
abs
(
$window
??
0
);
}
}
private
function
verifyOtpWithWindow
(
string
$otp
,
int
$counter
,
null
|
int
|
float
$window
):
bool
private
function
verifyOtpWithWindow
(
string
$otp
,
int
$counter
,
null
|
int
$window
):
bool
{
{
$window
=
$this
->
getWindow
(
$window
);
$window
=
$this
->
getWindow
(
$window
);
...
...
This diff is collapsed.
Click to expand it.
src/OTPInterface.php
+
1
−
1
View file @
e5b4eed8
...
@@ -15,7 +15,7 @@ interface OTPInterface
...
@@ -15,7 +15,7 @@ interface OTPInterface
* Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default
* Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default
* value or false is returned.
* value or false is returned.
*/
*/
public
function
verify
(
string
$otp
,
null
|
int
$input
=
null
,
null
|
int
|
float
$window
=
null
):
bool
;
public
function
verify
(
string
$otp
,
null
|
int
$input
=
null
,
null
|
int
$window
=
null
):
bool
;
/**
/**
* @return string The secret of the OTP
* @return string The secret of the OTP
...
...
This diff is collapsed.
Click to expand it.
src/TOTP.php
+
2
−
2
View file @
e5b4eed8
...
@@ -55,7 +55,7 @@ final class TOTP extends OTP implements TOTPInterface
...
@@ -55,7 +55,7 @@ final class TOTP extends OTP implements TOTPInterface
/**
/**
* If no timestamp is provided, the OTP is verified at the actual timestamp.
* If no timestamp is provided, the OTP is verified at the actual timestamp.
*/
*/
public
function
verify
(
string
$otp
,
null
|
int
$timestamp
=
null
,
null
|
int
|
float
$window
=
null
):
bool
public
function
verify
(
string
$otp
,
null
|
int
$timestamp
=
null
,
null
|
int
$window
=
null
):
bool
{
{
$timestamp
=
$this
->
getTimestamp
(
$timestamp
);
$timestamp
=
$this
->
getTimestamp
(
$timestamp
);
...
@@ -126,7 +126,7 @@ final class TOTP extends OTP implements TOTPInterface
...
@@ -126,7 +126,7 @@ final class TOTP extends OTP implements TOTPInterface
$this
->
setParameter
(
'epoch'
,
$epoch
);
$this
->
setParameter
(
'epoch'
,
$epoch
);
}
}
private
function
verifyOtpWithWindow
(
string
$otp
,
int
$timestamp
,
int
|
float
$window
):
bool
private
function
verifyOtpWithWindow
(
string
$otp
,
int
$timestamp
,
int
$window
):
bool
{
{
$window
=
abs
(
$window
);
$window
=
abs
(
$window
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets