Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
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
Container registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
7eef427a
Commit
7eef427a
authored
11 years ago
by
Peter Rotich
Committed by
Peter Rotich
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Split AuthLockoutBackends into two backends - for staff and user.
Monitor failed login attempts and enforce timeouts
parent
4d729b2c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.auth.php
+72
-5
72 additions, 5 deletions
include/class.auth.php
with
72 additions
and
5 deletions
include/class.auth.php
+
72
−
5
View file @
7eef427a
...
...
@@ -332,10 +332,40 @@ class AccessDenied {
* Simple authentication backend which will lock the login form after a
* configurable number of attempts
*/
class
Auth
Lockout
Backend
extends
AuthenticationBackend
{
abstract
class
Auth
Strike
Backend
extends
AuthenticationBackend
{
function
authenticate
(
$username
,
$password
=
null
)
{
global
$cfg
,
$ost
;
return
static
::
authStrike
(
$username
,
$password
);
}
function
signOn
()
{
return
static
::
authStrike
(
'Unknown'
);
}
function
login
(
$user
,
$bk
)
{
return
false
;
}
function
supportsAuthentication
()
{
return
false
;
}
function
getAllowedBackends
(
$userid
)
{
return
array
();
}
abstract
function
authStrike
(
$username
,
$password
=
null
);
}
/*
* Backend to monitor staff's failed login attempts
*/
class
StaffAuthStrikeBackend
extends
AuthStrikeBackend
{
function
authstrike
(
$username
,
$password
=
null
)
{
global
$ost
;
$cfg
=
$ost
->
getConfig
();
if
(
$_SESSION
[
'_staff'
][
'laststrike'
])
{
if
((
time
()
-
$_SESSION
[
'_staff'
][
'laststrike'
])
<
$cfg
->
getStaffLoginTimeout
())
{
...
...
@@ -369,12 +399,49 @@ class AuthLockoutBackend extends AuthenticationBackend {
$ost
->
logWarning
(
'Failed staff login attempt ('
.
$username
.
')'
,
$alert
,
false
);
}
}
}
StaffAuthenticationBackend
::
register
(
StaffAuthStrikeBackend
);
/*
* Backend to monitor user's failed login attempts
*/
class
UserAuthStrikeBackend
extends
AuthStrikeBackend
{
function
authstrike
(
$username
,
$password
=
null
)
{
global
$ost
;
$cfg
=
$ost
->
getConfig
();
//Check time for last max failed login attempt strike.
if
(
$_SESSION
[
'_client'
][
'laststrike'
])
{
if
((
time
()
-
$_SESSION
[
'_client'
][
'laststrike'
])
<
$cfg
->
getClientLoginTimeout
())
{
$_SESSION
[
'_client'
][
'laststrike'
]
=
time
();
//renew the strike.
return
new
AccessDenied
(
'You\'ve reached maximum failed login attempts allowed.'
);
}
else
{
//Timeout is over.
//Reset the counter for next round of attempts after the timeout.
$_SESSION
[
'_client'
][
'laststrike'
]
=
null
;
$_SESSION
[
'_client'
][
'strikes'
]
=
0
;
}
}
$_SESSION
[
'_client'
][
'strikes'
]
+=
1
;
if
(
$_SESSION
[
'_client'
][
'strikes'
]
>
$cfg
->
getClientMaxLogins
())
{
$_SESSION
[
'_client'
][
'laststrike'
]
=
time
();
$alert
=
'Excessive login attempts by a user.'
.
"
\n
"
.
'Login: '
.
$username
.
': '
.
$password
.
"
\n
"
.
'IP: '
.
$_SERVER
[
'REMOTE_ADDR'
]
.
"
\n
"
.
'Time:'
.
date
(
'M j, Y, g:i a T'
)
.
"
\n\n
"
.
'Attempts #'
.
$_SESSION
[
'_client'
][
'strikes'
];
$ost
->
logError
(
'Excessive login attempts (user)'
,
$alert
,
(
$cfg
->
alertONLoginError
()));
return
new
AccessDenied
(
'Access Denied'
);
}
elseif
(
$_SESSION
[
'_client'
][
'strikes'
]
%
2
==
0
)
{
//Log every other failed login attempt as a warning.
$alert
=
'Login: '
.
$username
.
': '
.
$password
.
"
\n
"
.
'IP: '
.
$_SERVER
[
'REMOTE_ADDR'
]
.
"
\n
"
.
'TIME: '
.
date
(
'M j, Y, g:i a T'
)
.
"
\n\n
"
.
'Attempts #'
.
$_SESSION
[
'_client'
][
'strikes'
];
$ost
->
logWarning
(
'Failed login attempt (user)'
,
$alert
);
}
function
supportsAuthentication
()
{
return
false
;
}
}
AuthenticationBackend
::
register
(
AuthLockout
Backend
);
User
AuthenticationBackend
::
register
(
UserAuthStrike
Backend
);
class
osTicketAuthentication
extends
StaffAuthenticationBackend
{
...
...
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