Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TOTP server for technical site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN OT
TOTP server for technical site
Commits
013ea1e3
Commit
013ea1e3
authored
2 years ago
by
Tomasz Wolniewicz
Browse files
Options
Downloads
Patches
Plain Diff
code ordering
parent
ed923b8f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+14
-0
14 additions, 0 deletions
Dockerfile
otp_server.php
+8
-7
8 additions, 7 deletions
otp_server.php
otp_server_config/otp_config-template.php
+6
-0
6 additions, 0 deletions
otp_server_config/otp_config-template.php
with
28 additions
and
7 deletions
Dockerfile
0 → 100644
+
14
−
0
View file @
013ea1e3
FROM
php:8.1-apache
WORKDIR
/var/www/html
RUN
docker-php-ext-install mysqli
COPY
--from=docker.io/library/composer:latest /usr/bin/composer /usr/bin/composer
COPY
composer.json .
RUN
apt-get update
RUN
apt-get
install
-y
git
RUN
composer update
COPY
otp_server.php otp_server.php
COPY
config/ config
COPY
otp_server_config/ /var/otp_server_config
EXPOSE
80
This diff is collapsed.
Click to expand it.
web/
otp
-
server.php
→
otp
_
server.php
+
8
−
7
View file @
013ea1e3
...
...
@@ -13,12 +13,12 @@
*/
session_start
();
require_once
(
'
../
vendor/autoload.php'
);
require_once
(
'
../../
config/config.php'
);
require_once
(
'vendor/autoload.php'
);
require_once
(
'config/config.php'
);
require_once
(
DB_CONFIG_LOCATION
);
use
OTPHP\TOTP
;
$mysqli
=
new
mysqli
(
DB_HOST
,
USER
,
PASSWORD
,
DB
_DATABASE
);
$mysqli
=
new
mysqli
(
DB_HOST
,
USER
,
PASSWORD
,
OTP
_DATABASE
);
if
(
$mysqli
->
connect_error
)
{
die
(
"Not connected"
);
}
...
...
@@ -26,6 +26,7 @@ $mysqli->set_charset('utf8');
$mysqli
->
query
(
"SET time_zone='+00:00'"
);
if
(
empty
(
$_GET
[
'user'
]))
{
print
(
'no username argument'
);
exit
;
}
...
...
@@ -40,7 +41,7 @@ if ($result) {
}
else
{
$r
=
$result
->
fetch_row
();
$otpSecret
=
$r
[
0
];
$otpLastCode
=
$r
[
1
];
$otpLastCode
=
intval
(
$r
[
1
]
)
;
$verified
=
$r
[
2
];
$out
=
0
;
// the user exists in the database - this is a temporary code value
}
...
...
@@ -48,11 +49,11 @@ if ($result) {
exit
;
}
$otpCode
=
filter_var
(
$_GET
[
'otp'
],
FILTER_SANITIZE_NUMBER_INT
);
$otpCode
=
isset
(
$_GET
[
'otp'
])
?
intval
(
filter_var
(
$_GET
[
'otp'
],
FILTER_SANITIZE_NUMBER_INT
)
)
:
0
;
// check if any code has been passed and if so update the result code accordingle - again this value is temporary
if
(
$otpCode
==
''
&&
$out
==
0
)
{
if
(
$otpCode
==
0
&&
$out
==
0
)
{
if
(
$verified
==
1
)
{
$out
=
3
;
}
else
{
...
...
@@ -63,7 +64,7 @@ if ($otpCode == '' && $out == 0) {
if
(
$out
==
0
)
{
// the otp code must have been provided and the user exists in the DB, the secret is taken form the DB
$otpObject
=
TOTP
::
create
(
$otpSecret
);
$otpTestCode
=
$otpObject
->
now
();
$otpTestCode
=
intval
(
$otpObject
->
now
()
)
;
if
(
$otpCode
===
$otpTestCode
)
{
if
(
$otpCode
===
$otpLastCode
)
{
$out
=
4
;
...
...
This diff is collapsed.
Click to expand it.
otp_server_config/otp_config-template.php
0 → 100644
+
6
−
0
View file @
013ea1e3
<?php
define
(
'DB_HOST'
,
'edugain-db'
);
define
(
'DB_DATABASE'
,
'edugain'
);
define
(
'USER'
,
'otp'
);
define
(
'PASSWORD'
,
'xxxx'
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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