Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Feeds
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MickGe
Feeds
Commits
580eccd3
Commit
580eccd3
authored
4 years ago
by
Andrew Dolgov
Browse files
Options
Downloads
Patches
Plain Diff
throttle login attempts, controlled by Config::AUTH_MIN_INTERVAL
parent
b9268fcc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
classes/config.php
+4
-0
4 additions, 0 deletions
classes/config.php
plugins/auth_internal/init.php
+26
-0
26 additions, 0 deletions
plugins/auth_internal/init.php
with
30 additions
and
0 deletions
classes/config.php
+
4
−
0
View file @
580eccd3
...
...
@@ -167,6 +167,9 @@ class Config {
const
ENABLE_PLUGIN_INSTALLER
=
"ENABLE_PLUGIN_INSTALLER"
;
// allow installing first party plugins using plugin installer in prefs
const
AUTH_MIN_INTERVAL
=
"AUTH_MIN_INTERVAL"
;
// minimum amount of seconds required between authentication attempts
// default values for all of the above:
private
const
_DEFAULTS
=
[
Config
::
DB_TYPE
=>
[
"pgsql"
,
Config
::
T_STRING
],
...
...
@@ -220,6 +223,7 @@ class Config {
Config
::
SESSION_NAME
=>
[
"ttrss_sid"
,
Config
::
T_STRING
],
Config
::
CHECK_FOR_PLUGIN_UPDATES
=>
[
"true"
,
Config
::
T_BOOL
],
Config
::
ENABLE_PLUGIN_INSTALLER
=>
[
"true"
,
Config
::
T_BOOL
],
Config
::
AUTH_MIN_INTERVAL
=>
[
5
,
Config
::
T_INT
],
];
private
static
$instance
;
...
...
This diff is collapsed.
Click to expand it.
plugins/auth_internal/init.php
+
26
−
0
View file @
580eccd3
...
...
@@ -150,6 +150,32 @@ class Auth_Internal extends Auth_Base {
if
(
$user
)
{
// don't throttle app passwords
if
(
!
$service
&&
get_schema_version
()
>=
145
)
{
if
(
$user
->
last_auth_attempt
)
{
$last_auth_attempt
=
strtotime
(
$user
->
last_auth_attempt
);
if
(
$last_auth_attempt
&&
time
()
-
$last_auth_attempt
<
Config
::
get
(
Config
::
AUTH_MIN_INTERVAL
))
{
Logger
::
log
(
E_USER_NOTICE
,
"Too many authentication attempts for
{
$user
->
login
}
, throttled."
);
// start an empty session to deliver login error message
if
(
session_status
()
!=
PHP_SESSION_ACTIVE
)
session_start
();
$_SESSION
[
"login_error_msg"
]
=
"Too many authentication attempts, throttled."
;
$user
->
last_auth_attempt
=
Db
::
NOW
();
$user
->
save
();
return
false
;
}
}
$user
->
last_auth_attempt
=
Db
::
NOW
();
$user
->
save
();
}
$salt
=
$user
[
'salt'
]
??
""
;
$login
=
$user
[
'login'
];
$pwd_hash
=
$user
[
'pwd_hash'
];
...
...
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