rotp 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 249d6f491f01af9144f3e7e6573e40f5f6b33039
4
- data.tar.gz: 21959028b9d02f4c112ef0f3a9e1573c935fcef3
3
+ metadata.gz: 17c7287512c5437d21d34d9d0eae73f42cce0501
4
+ data.tar.gz: a2b8c0c4133681b23af7a30c34f9e6d0386e1f65
5
5
  SHA512:
6
- metadata.gz: 2b3b5ce10fb037701d5c73b1a1a095a9bd0186baf6cc29ba7e6fe20d1aabcf9b59444588969e1175da044ca1159529d1915722620101d65780c95d0a3b4bdbcd
7
- data.tar.gz: 3f61abe5b65d0a8a180b7297c09f9654637a23a7e39446358dd7095e883ff5c65afce5f23420bfdaa29a0a6a04469013ab078b31ef4a003cf1140e697adca376
6
+ metadata.gz: dc396f7711a415619afd44e5b2d1eba90dada73990a4531fb5bede1dc0d7c8c620e745be388e85ad34d290878a14e92e194ed9379ff0226964cac97070eada7c
7
+ data.tar.gz: 9ed66cff8f1b90b54252842131d1f2c046d87a1082381470b8ea0c7b2e3cda890039967b1b458d771ca3e5f4f7f5a3892fdaff6f408b8618ff357405e9727b31
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ### Changelog
2
2
 
3
+ #### 3.0.0
4
+
5
+ - Provisioning URL includes issuer label per RFC 5234 See mdp/rotp/pull/51
6
+
3
7
  #### 2.1.2
4
8
 
5
9
  - Remove string literals to prepare immutable strings in Ruby 3.0
data/README.md CHANGED
@@ -39,6 +39,7 @@ Optionally, you can provide an issuer which will be used as a title in Google Au
39
39
 
40
40
  ```ruby
41
41
  totp = ROTP::TOTP.new("base32secret3232", issuer: "My Service")
42
+ totp.provisioning_uri("alice@google.com")
42
43
  ```
43
44
 
44
45
  ### Counter based OTP's
@@ -68,8 +69,8 @@ Provisioning URI's generated by ROTP are compatible with the Google Authenticato
68
69
  to be scanned with the in-built QR Code scanner.
69
70
 
70
71
  ```ruby
71
- totp.provisioning_uri("alice@google.com") # => 'otpauth://totp/alice@google.com?secret=JBSWY3DPEHPK3PXP'
72
- hotp.provisioning_uri("alice@google.com", 0) # => 'otpauth://hotp/alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=0'
72
+ totp.provisioning_uri("alice@google.com") # => 'otpauth://totp/issuer:alice@google.com?secret=JBSWY3DPEHPK3PXP'
73
+ hotp.provisioning_uri("alice@google.com", 0) # => 'otpauth://hotp/issuer:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=0'
73
74
  ```
74
75
 
75
76
  This can then be rendered as a QR Code which can then be scanned and added to the users
data/lib/rotp/totp.rb CHANGED
@@ -51,9 +51,14 @@ module ROTP
51
51
  # This can then be encoded in a QR Code and used
52
52
  # to provision the Google Authenticator app
53
53
  # @param [String] name of the account
54
- # @return [String] provisioning uri
54
+ # @return [String] provisioning URI
55
55
  def provisioning_uri(name)
56
- encode_params("otpauth://totp/#{URI.encode(name)}",
56
+ # The format of this URI is documented at:
57
+ # https://github.com/google/google-authenticator/wiki/Key-Uri-Format
58
+ # For compatibility the issuer appears both before that account name and also in the
59
+ # query string.
60
+ issuer_string = issuer.nil? ? "" : "#{URI.encode(issuer)}:"
61
+ encode_params("otpauth://totp/#{issuer_string}#{URI.encode(name)}",
57
62
  :secret => secret, :period => (interval==30 ? nil : interval), :issuer => issuer)
58
63
  end
59
64
 
data/lib/rotp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ROTP
2
- VERSION = "2.1.2"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -101,7 +101,7 @@ RSpec.describe ROTP::TOTP do
101
101
  let(:totp) { ROTP::TOTP.new 'JBSWY3DPEHPK3PXP', issuer: 'FooCo' }
102
102
 
103
103
  it 'has the correct format' do
104
- expect(uri).to match %r{\Aotpauth:\/\/totp.+}
104
+ expect(uri).to match %r{\Aotpauth:\/\/totp/FooCo:.+}
105
105
  end
106
106
 
107
107
  it 'includes the secret as parameter' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Percival
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-12 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-rspec