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
c28528dc
Commit
c28528dc
authored
2 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
garbage collect expired tfa tokens, fixes #2399
Closes #2399 Merge request
studip/studip!1592
parent
4fdab5cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/cronjobs/garbage_collector.class.php
+6
-0
6 additions, 0 deletions
lib/cronjobs/garbage_collector.class.php
lib/models/TFASecret.php
+18
-0
18 additions, 0 deletions
lib/models/TFASecret.php
with
24 additions
and
0 deletions
lib/cronjobs/garbage_collector.class.php
+
6
−
0
View file @
c28528dc
...
...
@@ -176,5 +176,11 @@ class GarbageCollectorJob extends CronJob
if
(
$removed
>
0
&&
$parameters
[
'verbose'
])
{
printf
(
_
(
'Gelöschte Terminblöcke: %u'
)
.
"
\n
"
,
$removed
);
}
// Remove expired tfa tokens
TFAToken
::
deleteBySQL
(
'mkdate < UNIX_TIMESTAMP() - ?'
,
[
TFASecret
::
getGreatestValidityDuration
()]
);
}
}
This diff is collapsed.
Click to expand it.
lib/models/TFASecret.php
+
18
−
0
View file @
c28528dc
...
...
@@ -58,6 +58,24 @@ class TFASecret extends SimpleORMap
$t
=
self
::
TYPES
[
$type
];
return
$t
[
'window'
]
*
$t
[
'period'
];
}
/**
* Returns the greatest validity duration for all defined types.
*
* @return int
*/
public
static
function
getGreatestValidityDuration
():
int
{
$validity_duration
=
0
;
foreach
(
self
::
TYPES
as
$type
)
{
$duration
=
$type
[
'window'
]
*
$type
[
'period'
];
if
(
$duration
>
$validity_duration
)
{
$validity_duration
=
$duration
;
}
}
return
$validity_duration
;
}
/**
* Overwrites the SORM setNew() method. This will create the secret string.
*
...
...
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