Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Jan-Hendrik Willms
Stud.IP
Commits
73c5eeb4
Commit
73c5eeb4
authored
1 year ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
fixes #3570
Closes #3570 Merge request
studip/studip!2460
parent
b015aa61
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/classes/TwoFactorAuth.php
+23
-13
23 additions, 13 deletions
lib/classes/TwoFactorAuth.php
with
23 additions
and
13 deletions
lib/classes/TwoFactorAuth.php
+
23
−
13
View file @
73c5eeb4
...
@@ -16,6 +16,7 @@ final class TwoFactorAuth
...
@@ -16,6 +16,7 @@ final class TwoFactorAuth
const
SESSION_DATA
=
'tfa/data'
;
const
SESSION_DATA
=
'tfa/data'
;
const
SESSION_CONFIRMATIONS
=
'tfa/confirmations'
;
const
SESSION_CONFIRMATIONS
=
'tfa/confirmations'
;
const
SESSION_FAILED
=
'tfa/failed'
;
const
SESSION_FAILED
=
'tfa/failed'
;
const
SESSION_TOKEN_SENT
=
'tfa/token-sent'
;
const
COOKIE_KEY
=
'tfa/authentication'
;
const
COOKIE_KEY
=
'tfa/authentication'
;
...
@@ -178,10 +179,11 @@ final class TwoFactorAuth
...
@@ -178,10 +179,11 @@ final class TwoFactorAuth
*/
*/
public
function
confirm
(
$action
,
$text
,
array
$data
=
[]):
void
public
function
confirm
(
$action
,
$text
,
array
$data
=
[]):
void
{
{
if
(
isset
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
])
if
(
isset
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
])
&&
is_array
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
])
&&
is_array
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
])
&&
in_array
(
$action
,
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
])
)
&&
in_array
(
$action
,
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
])
{
)
{
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
]
=
array_diff
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
]
=
array_diff
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
],
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
],
[
$action
]
[
$action
]
...
@@ -210,14 +212,21 @@ final class TwoFactorAuth
...
@@ -210,14 +212,21 @@ final class TwoFactorAuth
]);
]);
if
(
$this
->
secret
->
type
===
'email'
)
{
if
(
$this
->
secret
->
type
===
'email'
)
{
StudipMail
::
sendMessage
(
if
(
$this
->
secret
->
user
->
email
,
!
isset
(
$_SESSION
[
self
::
SESSION_TOKEN_SENT
])
_
(
'Ihr Zwei-Faktor-Token'
),
||
$_SESSION
[
self
::
SESSION_TOKEN_SENT
]
<
time
()
sprintf
(
)
{
_
(
'Bitte geben Sie dieses Token ein: %s'
),
StudipMail
::
sendMessage
(
$this
->
secret
->
getToken
()
$this
->
secret
->
user
->
email
,
)
_
(
'Ihr Zwei-Faktor-Token'
),
);
sprintf
(
_
(
'Bitte geben Sie dieses Token ein: %s'
),
$this
->
secret
->
getToken
()
)
);
$_SESSION
[
self
::
SESSION_TOKEN_SENT
]
=
time
()
+
TFASecret
::
getValidationDuration
(
'email'
);
}
}
}
PageLayout
::
setBodyElementId
(
'tfa-confirmation-screen'
);
PageLayout
::
setBodyElementId
(
'tfa-confirmation-screen'
);
...
@@ -295,8 +304,9 @@ final class TwoFactorAuth
...
@@ -295,8 +304,9 @@ final class TwoFactorAuth
if
(
$this
->
secret
->
validateToken
(
$token
))
{
if
(
$this
->
secret
->
validateToken
(
$token
))
{
$_SESSION
[
self
::
SESSION_FAILED
]
=
[];
$_SESSION
[
self
::
SESSION_FAILED
]
=
[];
unset
(
$_SESSION
[
self
::
SESSION_TOKEN_SENT
]);
if
(
$data
[
'global'
]
?
:
false
)
{
if
(
$data
[
'global'
]
?
?
false
)
{
$this
->
registerSecretInSession
();
$this
->
registerSecretInSession
();
if
(
Request
::
int
(
'tfa-trusted'
))
{
if
(
Request
::
int
(
'tfa-trusted'
))
{
...
@@ -304,7 +314,7 @@ final class TwoFactorAuth
...
@@ -304,7 +314,7 @@ final class TwoFactorAuth
}
}
}
}
if
(
$data
[
'confirm'
]
?
:
false
)
{
if
(
$data
[
'confirm'
]
?
?
false
)
{
if
(
!
isset
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
]))
{
if
(
!
isset
(
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
]))
{
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
]
=
[];
$_SESSION
[
self
::
SESSION_CONFIRMATIONS
]
=
[];
}
}
...
...
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