tfa 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tfa/cli.rb +10 -1
- data/lib/tfa/version.rb +1 -1
- data/spec/lib/cli_spec.rb +38 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fb7180ac2ccb7c877e05e1927763d9bdb0d4e6c
|
4
|
+
data.tar.gz: f7d18a024879662a22404c42b1a3ef01975b027e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e854463b20f67ec678ac3c0e0e08e3c00df4ce9fc27df0a0b7b320647d65de78d938fa38f9a3074f3050dd6789fa4f2166c6e24b173c7e540eb33d40fd6efd
|
7
|
+
data.tar.gz: 0741cd7c80b47730893ad23fc962d0448a2e8ae3be72a4c98c5ddefab31fe423d8bd6ec4fbefeaa3a2c2b9b2d17c902a37642f73e360a2dfc3cbb725cc79ca23
|
data/lib/tfa/cli.rb
CHANGED
@@ -7,6 +7,7 @@ module TFA
|
|
7
7
|
|
8
8
|
desc "add NAME SECRET", "add a new secret to the database"
|
9
9
|
def add(name, secret)
|
10
|
+
secret = clean(secret)
|
10
11
|
storage.save(name, secret)
|
11
12
|
"Added #{name}"
|
12
13
|
end
|
@@ -18,7 +19,7 @@ module TFA
|
|
18
19
|
|
19
20
|
desc "totp NAME", "generate a Time based One Time Password"
|
20
21
|
def totp(name = nil)
|
21
|
-
TotpCommand.new(storage).run(
|
22
|
+
TotpCommand.new(storage).run(name)
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -26,5 +27,13 @@ module TFA
|
|
26
27
|
def storage
|
27
28
|
@storage ||= Storage.new(filename: options[:filename] || 'tfa')
|
28
29
|
end
|
30
|
+
|
31
|
+
def clean(secret)
|
32
|
+
if secret.include?("=")
|
33
|
+
/secret=([^&]*)/.match(secret).captures.first
|
34
|
+
else
|
35
|
+
secret
|
36
|
+
end
|
37
|
+
end
|
29
38
|
end
|
30
39
|
end
|
data/lib/tfa/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
module TFA
|
2
|
+
describe CLI do
|
3
|
+
subject { CLI.new }
|
4
|
+
|
5
|
+
def code_for(secret)
|
6
|
+
::ROTP::TOTP.new(secret).now
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:secret) { ::ROTP::Base32.random_base32 }
|
10
|
+
|
11
|
+
describe "#add" do
|
12
|
+
context "when a secret is added" do
|
13
|
+
it "adds the secret" do
|
14
|
+
subject.add("development", secret)
|
15
|
+
expect(subject.show("development")).to eql(secret)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when a full otpauth string is added" do
|
20
|
+
it "strips out the url for just the secret" do
|
21
|
+
url = "otpauth://totp/email@email.com?secret=#{secret}&issuer="
|
22
|
+
|
23
|
+
subject.add("development", url)
|
24
|
+
expect(subject.show("development")).to eql(secret)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#totp" do
|
30
|
+
context "when a single key is given" do
|
31
|
+
it "returns a time based one time password" do
|
32
|
+
subject.add("development", secret)
|
33
|
+
expect(subject.totp("development")).to eql(code_for(secret))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tfa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rotp
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/tfa/storage.rb
|
102
102
|
- lib/tfa/totp_command.rb
|
103
103
|
- lib/tfa/version.rb
|
104
|
+
- spec/lib/cli_spec.rb
|
104
105
|
- spec/lib/console_spec.rb
|
105
106
|
- spec/lib/totp_command_spec.rb
|
106
107
|
- spec/spec_helper.rb
|
@@ -130,6 +131,7 @@ signing_key:
|
|
130
131
|
specification_version: 4
|
131
132
|
summary: A CLI to manage your one time passwords.
|
132
133
|
test_files:
|
134
|
+
- spec/lib/cli_spec.rb
|
133
135
|
- spec/lib/console_spec.rb
|
134
136
|
- spec/lib/totp_command_spec.rb
|
135
137
|
- spec/spec_helper.rb
|