2fa 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/2fa-0.0.1.gem +0 -0
- data/app/helpers/tfa/tfa_helper.rb +8 -6
- data/lib/TFA/version.rb +1 -1
- data/readme.md +4 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c6ee1d02fd641ab961cd51780f30d11b4596c344a1a076fce5d0c1687a679b
|
4
|
+
data.tar.gz: 39087b415fb04ea9049cb5721e8e1117975f005de5411dddfd366d6e557aa789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5795911bb57902b834af94f9181b27e60401082a54d2b53b59db0ba4acaa4fab5b22e2030dc44c9952bd7a955f782797ce92e54c423c8178d9c6ce1a65f92dae
|
7
|
+
data.tar.gz: 03b4ca5e1a4128f5353083258af7a8b20e459f06270e4974488a004ef6721cf9bd0611573669faf477f68aece0d2ccd2635ab0040ef64c7cbe8e4e6fd49fec95
|
data/2fa-0.0.1.gem
ADDED
Binary file
|
@@ -29,8 +29,12 @@ module TFA
|
|
29
29
|
controller.redirect_to Engine.routes.url_helpers.tfa_verify_path(@tfa)
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
32
|
+
def tfa_valid(expected_phone:nil)
|
33
|
+
params[:tfa_id] && Tfa.find_by(id: params[:tfa_id]).code.to_s == params[:code].to_s && !Tfa.find_by(id: params[:tfa_id]).used && (Tfa.find_by(id: params[:tfa_id]).phone == expected_phone || expected_phone == nil)
|
34
|
+
end
|
35
|
+
|
36
|
+
def if_tfa(expected_phone:nil, &block)
|
37
|
+
if tfa_valid(expected_phone: expected_phone)
|
34
38
|
@tfa = Tfa.find_by(id: params[:tfa_id])
|
35
39
|
@tfa.used = true
|
36
40
|
@tfa.save
|
@@ -39,10 +43,8 @@ module TFA
|
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
|
-
def no_tfa(&block)
|
43
|
-
if !
|
44
|
-
block.call
|
45
|
-
elsif Tfa.find_by(id: params[:tfa_id]).code.to_s != params[:code].to_s
|
46
|
+
def no_tfa(expected_phone:nil, &block)
|
47
|
+
if !tfa_valid(expected_phone: expected_phone)
|
46
48
|
block.call
|
47
49
|
end
|
48
50
|
end
|
data/lib/TFA/version.rb
CHANGED
data/readme.md
CHANGED
@@ -33,7 +33,7 @@ def create
|
|
33
33
|
end
|
34
34
|
|
35
35
|
helpers.if_tfa do
|
36
|
-
@example =
|
36
|
+
@example = Example.new(example_params)
|
37
37
|
|
38
38
|
respond_to do |format|
|
39
39
|
if @example.save
|
@@ -49,14 +49,10 @@ end
|
|
49
49
|
```
|
50
50
|
This is just a default scaffolded controller but with tfa auth.
|
51
51
|
|
52
|
-
This isn't perfect as in theory someone could pass a different unused tfa by inspecting the form, so to prevent this, you can
|
52
|
+
This isn't perfect as in theory someone could pass a different unused tfa by inspecting the form, so to prevent this, you can pass a `expected_phone: ` argument to `no_tfa` or `if_tfa` to add that requirement.
|
53
53
|
```rb
|
54
|
-
helpers.if_tfa do
|
55
|
-
|
56
|
-
#...your code here
|
57
|
-
else
|
58
|
-
head 401
|
59
|
-
end
|
54
|
+
helpers.if_tfa(expected_phone: @user.phone) do
|
55
|
+
#...
|
60
56
|
end
|
61
57
|
```
|
62
58
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 2fa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: twilio-ruby
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- 2fa-0.0.1.gem
|
48
49
|
- 2fa.gemspec
|
49
50
|
- app/controllers/tfa/tfas_controller.rb
|
50
51
|
- app/helpers/tfa/tfa_helper.rb
|