Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
46ea2a0c
Commit
46ea2a0c
authored
9 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
better var name
parent
17bc7830
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
src/metabase/api/session.clj
+6
-7
6 additions, 7 deletions
src/metabase/api/session.clj
with
6 additions
and
7 deletions
src/metabase/api/session.clj
+
6
−
7
View file @
46ea2a0c
...
...
@@ -92,8 +92,8 @@
(
when
(
>
num-attempts-over-threshold
0
)
(
let
[
delay-seconds
(
*
(
math/expt
num-attempts-over-threshold
failed-login-delay-exponent
)
failed-login-attempts-initial-delay-seconds
)
nex
t-login
-allowed
-ms
(
+
(
.getTime
most-recent-attempt
)
(
*
delay-seconds
1000
))
seconds-till-next-login
(
int
(
math/round
(
/
(
-
nex
t-login
-allowed
-ms
(
System/currentTimeMillis
))
1000
)))]
las
t-login
+delay
-ms
(
+
(
.getTime
most-recent-attempt
)
(
*
delay-seconds
1000
))
seconds-till-next-login
(
int
(
math/round
(
/
(
-
las
t-login
+delay
-ms
(
System/currentTimeMillis
))
1000
)))]
(
when
(
>
seconds-till-next-login
0
)
seconds-till-next-login
))))))
...
...
@@ -104,11 +104,10 @@
;; Remove any out-of-date failed login attempts
(
remove-old-failed-login-attempts
)
;; Now count the number of recent attempts with this email
(
let
[
recent-attempts
(
filter
(
fn
[[
attempt-email
_
]]
(
=
email
attempt-email
))
@
failed-login-attempts
)
[
_
most-recent-attempt
]
(
first
recent-attempts
)]
(
println
"RECENT ATTEMPTS:\n"
(
metabase.util/pprint-to-str
'cyan
recent-attempts
))
(
let
[[[
_
most-recent-attempt
]
:as
recent-attempts
]
(
filter
(
fn
[[
attempt-email
_
]]
(
=
email
attempt-email
))
@
failed-login-attempts
)]
(
println
"RECENT ATTEMPTS:\n"
(
metabase.util/pprint-to-str
'cyan
recent-attempts
))
;; TODO - remove debug loggin
(
when-let
[
login-delay
(
calculate-login-delay
most-recent-attempt
(
count
recent-attempts
))]
(
let
[
message
(
format
"Too many recent failed logins! You must wait %d seconds before trying again."
login-delay
)]
(
throw
(
ex-info
message
{
:status-code
400
...
...
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