login-control 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/login_control_module.rb +1 -0
- data/lib/login_control_view_helper.rb +6 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7140d5b9a8e9ee22b79f9e2522a09704cdac500ae79ff3f0bd143986d787045c
|
4
|
+
data.tar.gz: e31cca96bd63a22b6b9c6fe9978ab28b09580b676df3575a9d17c5f73f31caa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a949f430c3b55cb22cc85f249a738ef89c1ab66c926a89e7f59cbbd5c68e262682364d9f975e46e833b44060aa8d56f67f68135407c8c99fad9778935d702ea
|
7
|
+
data.tar.gz: 129ccb62c18fbef17a434990b7d14330cee531b339adffe98febe4ffb7c59822f4462d798d98887919f364af9de32d4cb13956ac84671282f77922914f50eea2
|
data/lib/login_control_module.rb
CHANGED
@@ -3,6 +3,7 @@ module LoginControlModule
|
|
3
3
|
# check if captcha is to validate (does not store a cookie)
|
4
4
|
def captcha_validation?(scope: :global, login_name: nil)
|
5
5
|
rec = rc_record(scope, login_name)
|
6
|
+
logger.info "LOGIN-CONTROL => get captcha #{captcha_requested ? '' : 'NOT '}requested from record LoginControl.#{rec.id}" if debug_request_control
|
6
7
|
rec ? rec.validate_captcha : true
|
7
8
|
end
|
8
9
|
|
@@ -6,12 +6,13 @@ module LoginControlViewHelper
|
|
6
6
|
def captcha_tag?(scope: :global, login_name: nil)
|
7
7
|
debug = (Rails.configuration.x.login_control.debug || !Rails.env.production?)
|
8
8
|
rc_id = cookies.encrypted.permanent[:login_control]
|
9
|
+
captcha_requested = true
|
9
10
|
if request.host == 'localhost'
|
10
11
|
logger.info 'LOGIN-CONTROL => no captcha because of localhost' if debug
|
11
|
-
false
|
12
|
+
captcha_requested = false
|
12
13
|
elsif !rc_id.present?
|
13
14
|
logger.info 'LOGIN-CONTROL => captcha because no cookie stored yet' if debug
|
14
|
-
true
|
15
|
+
captcha_requested = true
|
15
16
|
else
|
16
17
|
logger.info 'LOGIN-CONTROL => cookie found ...' if debug
|
17
18
|
rec = LoginControl.find_by(session_id: rc_id, scope: scope, login_name: login_name)
|
@@ -20,7 +21,6 @@ module LoginControlViewHelper
|
|
20
21
|
true
|
21
22
|
else
|
22
23
|
logger.info 'LOGIN-CONTROL => record found ...' if debug
|
23
|
-
captcha_requested = true
|
24
24
|
|
25
25
|
attempts_allowed = (Rails.configuration.x.login_control.attempts_allowed || 10)
|
26
26
|
retry_after_seconds = (Rails.configuration.x.login_control.retry_after_seconds || 30)
|
@@ -32,9 +32,10 @@ module LoginControlViewHelper
|
|
32
32
|
logger.info "LOGIN-CONTROL => captcha #{captcha_requested ? '' : 'NOT '}requested: config.x.retry_after_seconds(#{retry_after_seconds}) >= secs(#{secs})" if debug
|
33
33
|
end
|
34
34
|
|
35
|
-
rec.update!(validate_captcha: captcha_requested)
|
36
|
-
captcha_requested
|
37
35
|
end
|
36
|
+
rec.update!(validate_captcha: captcha_requested)
|
37
|
+
logger.info "LOGIN-CONTROL => set captcha #{captcha_requested ? '' : 'NOT '}requested to record LoginControl.#{rec.id}" if debug
|
38
|
+
captcha_requested
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: login-control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Sedlmair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Based on Login Attempts check if captcha is necessary. It stores a permanent
|
14
14
|
cookie and uses a table for tracking login requests.
|