tfa 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tfa +1 -1
- data/lib/tfa/cli.rb +29 -0
- data/lib/tfa/storage.rb +1 -1
- data/lib/tfa/version.rb +1 -1
- data/lib/tfa.rb +1 -1
- data/spec/lib/console_spec.rb +6 -12
- data/spec/lib/show_command_spec.rb +1 -1
- data/spec/lib/totp_command_spec.rb +1 -2
- data/tfa.gemspec +1 -0
- metadata +17 -3
- data/lib/tfa/console.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3231a5fbb89add5da947d85c14c6281c62f77ca
|
4
|
+
data.tar.gz: 4e289687adc78c62657595f42b6d0d7178466ca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 225f5599d4f2eb90c9c049392bfdea258cbfa66b7075941121caf8eb3e424e56b08f9000df3280a10474c4d49b42acd957bff92e0dccc1252274f9e38e80b9b5
|
7
|
+
data.tar.gz: fae0bfe272ad2c6eb01fadefacbc5fc59f5354884d0dc05b362b45e76d998eea26a272db32f77df9f0fb352d375c5a8de4769b51b0689f108f07728f92372e30
|
data/bin/tfa
CHANGED
data/lib/tfa/cli.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module TFA
|
4
|
+
class CLI < Thor
|
5
|
+
package_name "TFA"
|
6
|
+
class_option :filename
|
7
|
+
|
8
|
+
desc "add NAME SECRET", "add a new secret to the database"
|
9
|
+
def add(name, secret)
|
10
|
+
AddCommand.new(storage).run([name, secret])
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "show NAME", "shows the secret for the given key"
|
14
|
+
def show(name)
|
15
|
+
ShowCommand.new(storage).run([name])
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "totp NAME", "generate a Time based One Time Password"
|
19
|
+
def totp(name)
|
20
|
+
TotpCommand.new(storage).run([name])
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def storage
|
26
|
+
@storage ||= Storage.new(filename: options[:filename] || 'tfa')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/tfa/storage.rb
CHANGED
data/lib/tfa/version.rb
CHANGED
data/lib/tfa.rb
CHANGED
data/spec/lib/console_spec.rb
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
module TFA
|
2
|
-
describe
|
3
|
-
subject {
|
2
|
+
describe CLI do
|
3
|
+
subject { CLI.new }
|
4
4
|
let(:secret) { ::ROTP::Base32.random_base32 }
|
5
5
|
|
6
6
|
describe "#run" do
|
7
7
|
context "when adding a key" do
|
8
8
|
it "saves a new secret" do
|
9
|
-
subject.
|
10
|
-
expect(subject.
|
9
|
+
subject.add("development", secret)
|
10
|
+
expect(subject.show("development")).to eql(secret)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when getting a one time password" do
|
15
15
|
it "creates a totp for a certain key" do
|
16
|
-
subject.
|
17
|
-
expect(subject.
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when running an unknown command" do
|
22
|
-
it "returns the usage" do
|
23
|
-
expect(subject.run([])).to_not be_nil
|
16
|
+
subject.add("development", secret)
|
17
|
+
expect(subject.totp("development")).to_not be_nil
|
24
18
|
end
|
25
19
|
end
|
26
20
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module TFA
|
2
2
|
describe ShowCommand do
|
3
3
|
subject { ShowCommand.new(storage) }
|
4
|
-
let(:storage) { Storage.new(SecureRandom.uuid) }
|
4
|
+
let(:storage) { Storage.new(filename: SecureRandom.uuid) }
|
5
5
|
|
6
6
|
describe "#run" do
|
7
7
|
context "when looking up the secret for a specific key" do
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module TFA
|
2
2
|
describe TotpCommand do
|
3
3
|
subject { TotpCommand.new(storage) }
|
4
|
-
let(:storage) { Storage.new(
|
5
|
-
let(:storage) { Storage.new(SecureRandom.uuid) }
|
4
|
+
let(:storage) { Storage.new(filename: SecureRandom.uuid) }
|
6
5
|
|
7
6
|
def code_for(secret)
|
8
7
|
::ROTP::TOTP.new(secret).now
|
data/tfa.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "rotp"
|
22
|
+
spec.add_dependency "thor"
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
24
|
spec.add_development_dependency "rake"
|
24
25
|
spec.add_development_dependency "rspec"
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rotp
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,7 +98,7 @@ files:
|
|
84
98
|
- bin/tfa
|
85
99
|
- lib/tfa.rb
|
86
100
|
- lib/tfa/add_command.rb
|
87
|
-
- lib/tfa/
|
101
|
+
- lib/tfa/cli.rb
|
88
102
|
- lib/tfa/show_command.rb
|
89
103
|
- lib/tfa/storage.rb
|
90
104
|
- lib/tfa/totp_command.rb
|
data/lib/tfa/console.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module TFA
|
2
|
-
class Console
|
3
|
-
def initialize(filename = "tfa")
|
4
|
-
@storage = Storage.new(filename)
|
5
|
-
end
|
6
|
-
|
7
|
-
def run(arguments)
|
8
|
-
command_name = arguments.first
|
9
|
-
command_for(command_name).run(arguments - [command_name])
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def command_for(command_name)
|
15
|
-
registry[command_name].call
|
16
|
-
end
|
17
|
-
|
18
|
-
def registry
|
19
|
-
Hash.new { |x, y| lambda { UsageCommand.new(@storage) } }.tap do |commands|
|
20
|
-
commands['add'] = lambda { AddCommand.new(@storage) }
|
21
|
-
commands['show'] = lambda { ShowCommand.new(@storage) }
|
22
|
-
commands['totp'] = lambda { TotpCommand.new(@storage) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|