noalyss
Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
include
lib
otp.class.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Noalyss
;
4
5
/*
6
* This file is part of NOALYSS.
7
*
8
* NOALYSS is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
12
*
13
* NOALYSS is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with NOALYSS; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
*/
22
// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
23
24
25
/**
26
* @file
27
* @brief class using OTP
28
*
29
*/
30
31
/**
32
* @brief generate OTP
33
*/
34
use chillerlan\Authenticator\{
35
Authenticator,
36
AuthenticatorOptions
37
};
38
use chillerlan\Authenticator\Authenticators\AuthenticatorInterface;
39
40
class
OTP
{
41
42
private
$authenticator
;
43
44
function
__construct
() {
45
$options =
new
AuthenticatorOptions;
46
$options->secret_length = 32;
47
$options->algorithm = AuthenticatorInterface::ALGO_SHA512;
48
$options->digits=6;
49
$this->authenticator =
new
Authenticator($options);
50
}
51
/**
52
* @brief build a secret key and returns it
53
* @return string random string of 32 char
54
*/
55
function
build_secret
() {
56
57
$secret
= $this->authenticator->createSecret();
58
return
$secret
;
59
60
}
61
62
/**
63
* @brief compute a code for auth. for the user passed in parameter
64
* @param $secret (string) secret stored in AC_USER
65
*/
66
function
compute_code
(
$secret
)
67
{
68
69
$this->authenticator->setSecret(
$secret
);
70
return
$this->authenticator->code();
71
}
72
public
function
get_authenticator
() {
73
return
$this->authenticator
;
74
}
75
76
public
function
set_authenticator
(
$authenticator
) {
77
$this->authenticator =
$authenticator
;
78
return
$this;
79
}
80
81
82
}
Noalyss\OTP
Definition
otp.class.php:40
Noalyss\OTP\get_authenticator
get_authenticator()
Definition
otp.class.php:72
Noalyss\OTP\compute_code
compute_code($secret)
compute a code for auth.
Definition
otp.class.php:66
Noalyss\OTP\set_authenticator
set_authenticator($authenticator)
Definition
otp.class.php:76
Noalyss\OTP\$authenticator
$authenticator
Definition
otp.class.php:42
Noalyss\OTP\build_secret
build_secret()
build a secret key and returns it
Definition
otp.class.php:55
Noalyss\OTP\__construct
__construct()
Definition
otp.class.php:44
Noalyss
Definition
invoice_pdf.class.php:3
$secret
$secret
Definition
otp-link.php:159
$authenticator
$authenticator
Definition
otp-link.php:163
Generated on Thu Jan 15 2026 10:14:39 for noalyss by
1.13.2