Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
023d2a49
Commit
023d2a49
authored
2 years ago
by
pabois
Browse files
Options
Downloads
Patches
Plain Diff
devise semi-paranoid mode
parent
af71c9ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
config/initializers/devise.rb
+18
-1
18 additions, 1 deletion
config/initializers/devise.rb
with
18 additions
and
1 deletion
config/initializers/devise.rb
+
18
−
1
View file @
023d2a49
...
...
@@ -90,7 +90,7 @@ Devise.setup do |config|
# It will change confirmation, password recovery and other workflows
# to behave the same regardless if the e-mail provided was right or wrong.
# Does not affect registerable.
#
config.paranoid = true
config
.
paranoid
=
true
# By default Devise will store the user in session. You can skip storage for
# particular strategies by setting this option.
...
...
@@ -322,3 +322,20 @@ Devise.setup do |config|
config
.
second_factor_resource_id
=
'id'
# Field or method name used to set value for 2fA remember cookie
config
.
delete_cookie_on_logout
=
false
# Delete cookie when user signs out, to force 2fA again on login
end
require
'devise/models/lockable'
Devise
::
Models
::
Lockable
.
class_eval
do
def
unauthenticated_message
# paranoid mode normally hide the locked message because it leaks the existence of an account.
# but I think this is totally not user friendly: a user can lock is account and still has the message "uncorrect"
# so I reverted to something less secure but more user friendly
if
access_locked?
||
(
lock_strategy_enabled?
(
:failed_attempts
)
&&
attempts_exceeded?
)
:locked
elsif
lock_strategy_enabled?
(
:failed_attempts
)
&&
last_attempt?
&&
self
.
class
.
last_attempt_warning
:last_attempt
else
super
end
end
end
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