authentic 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/authentic +1 -0
- data/lib/authentic.rb +25 -13
- data/lib/authentic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a5638eac32ad5d3c4da52d99a8c25ca5c2bdca5
|
4
|
+
data.tar.gz: ca509f3b357a2d5a8cdffa593c6721f45adb72cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17d8c8a27bb04f8c36cfdd4adbbffcfe4d797ceb3ac4581fcbcca60a7157629024f6b72ecdd890aff20e25f7458a2b291da2ab818c5ae7d44d3d10c21aa365d0
|
7
|
+
data.tar.gz: 29649b4fdb4fe73a9193bd8a14d0b17956a886a81db9275854c480212402c7550d1c608455da30134191e16b32c879ec6de2ef4db9807608d6b7490bbe49aa51
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ only be displayed the first time you setup TFA for the service.
|
|
47
47
|
Once you have your TFA key in hand, adding it to `authentic` is as simple as:
|
48
48
|
|
49
49
|
```shell
|
50
|
-
$ authentic add MyService
|
50
|
+
$ authentic add MyService qwdrft6789jkh
|
51
51
|
✓ Service MyService added to keychain
|
52
52
|
```
|
53
53
|
|
data/bin/authentic
CHANGED
data/lib/authentic.rb
CHANGED
@@ -11,14 +11,14 @@ module Authentic
|
|
11
11
|
package_name "Authentic"
|
12
12
|
default_task :generate
|
13
13
|
|
14
|
-
desc "add NAME SECRET_KEY [
|
15
|
-
def add(name, secret_key,
|
14
|
+
desc "add NAME SECRET_KEY [SERVICE]", "Add a new TOTP key"
|
15
|
+
def add(name, secret_key, service = nil)
|
16
16
|
params = {
|
17
|
-
|
18
|
-
password: secret_key,
|
17
|
+
label: "authentic gem",
|
19
18
|
account: name,
|
19
|
+
service: service || name,
|
20
|
+
password: secret_key,
|
20
21
|
}
|
21
|
-
params[:comment] = label if label
|
22
22
|
|
23
23
|
begin
|
24
24
|
item = Keychain.generic_passwords.create(params)
|
@@ -59,27 +59,39 @@ module Authentic
|
|
59
59
|
|
60
60
|
desc "generate", "Generate TOTP codes"
|
61
61
|
option 'skip-copy', default: false, type: :boolean, aliases: '-s'
|
62
|
+
option 'qr-codes', default: false, type: :boolean, aliases: '-qr'
|
62
63
|
def generate
|
63
64
|
now = Time.now
|
64
65
|
keys = Keychain
|
65
66
|
.generic_passwords
|
66
|
-
.where(
|
67
|
+
.where(label: "authentic gem")
|
67
68
|
.all.map do |key|
|
68
|
-
|
69
|
+
secret = key.password.gsub(/=*$/, '')
|
70
|
+
totp = ROTP::TOTP.new(secret)
|
69
71
|
OpenStruct.new(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
secret: secret,
|
73
|
+
code: totp.at(now),
|
74
|
+
name: key.attributes[:account],
|
75
|
+
service: key.attributes[:service],
|
76
|
+
remain: now.utc.to_i % totp.interval
|
74
77
|
)
|
75
|
-
end
|
78
|
+
end.sort_by { |k| [k.service, k.name] }
|
79
|
+
|
80
|
+
if options['qr-codes']
|
81
|
+
keys.each do |key|
|
82
|
+
puts "#{key.service} - #{key.name}\n"
|
83
|
+
puts `qrencode 'otpauth://totp/#{key.name}?issuer=#{key.service}&secret=#{key.secret}' -s 5 -o - | ~/.iterm2/imgcat`
|
84
|
+
end
|
85
|
+
return
|
86
|
+
end
|
76
87
|
|
77
88
|
table = keys.each_with_index.map do |key, idx|
|
78
89
|
number = (idx + 1).to_s.rjust(keys.size.to_s.size, ' ')
|
90
|
+
service_prefix = "#{key.service} - " if key.service && key.service != key.name
|
79
91
|
[
|
80
92
|
number.colorize(:red),
|
81
93
|
key.code.colorize(:green),
|
82
|
-
"#{
|
94
|
+
"#{service_prefix}#{key.name}",
|
83
95
|
CLOCKS[7 * (key.remain / 7)].colorize(:blue)
|
84
96
|
]
|
85
97
|
end
|
data/lib/authentic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|