rotp 6.2.2 → 6.3.0
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/.devcontainer/devcontainer.json +5 -1
- data/.github/workflows/release.yaml +36 -0
- data/.github/workflows/test.yaml +5 -6
- data/.release-please-manifest.json +3 -0
- data/CHANGELOG.md +41 -34
- data/{Dockerfile-3.0-rc → Dockerfile-3.0} +1 -1
- data/README.md +1 -1
- data/docker-compose.yml +2 -2
- data/lib/rotp/hotp.rb +2 -2
- data/lib/rotp/otp/uri.rb +3 -4
- data/lib/rotp/otp.rb +13 -1
- data/lib/rotp/totp.rb +2 -2
- data/lib/rotp/version.rb +1 -1
- data/release-please-config.json +12 -0
- data/spec/lib/rotp/hotp_spec.rb +33 -1
- data/spec/lib/rotp/totp_spec.rb +46 -4
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d6cedb1952a6df3b069bb85d94e169d4aeb7878e6e4dde0dcb3fe4a2915a747
|
4
|
+
data.tar.gz: 2ad3bb2a4ef2575af9b976da0c59eb22b7e4d8b9e0a44e477329222feb567e09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90ea9ec5403ad5e0953582e4a8c17369a0722c3f79d6b5a9d25e1f756a2cc024d01824a7e469a10dd98a7289aef6b34496dc6987565885fa01b3e8d0d6fb8e8c
|
7
|
+
data.tar.gz: aa7a667ef8de152cca8cd67df56d0f55a03ac7429f114d619bec1ac05178c015ba6c932f6fd651f27031c860927b81a3dc98bcd53ff7ef4080120a58404cd8f8
|
@@ -32,6 +32,10 @@
|
|
32
32
|
// "postCreateCommand": "ruby --version",
|
33
33
|
|
34
34
|
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
35
|
-
"remoteUser": "vscode"
|
35
|
+
"remoteUser": "vscode",
|
36
|
+
"features": {
|
37
|
+
"ghcr.io/devcontainers-contrib/features/act:1": {},
|
38
|
+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
39
|
+
}
|
36
40
|
|
37
41
|
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'main'
|
7
|
+
jobs:
|
8
|
+
release:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: google-github-actions/release-please-action@v3
|
12
|
+
id: release
|
13
|
+
with:
|
14
|
+
release-type: ruby
|
15
|
+
package-name: rotp
|
16
|
+
version-file: "lib/rotp/version.rb"
|
17
|
+
# Checkout code if release was created
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
if: ${{ steps.release.outputs.release_created }}
|
20
|
+
# Setup ruby if a release was created
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: 3.2
|
24
|
+
bundler-cache: true
|
25
|
+
if: ${{ steps.release.outputs.release_created }}
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rspec
|
28
|
+
if: ${{ steps.release.outputs.release_created }}
|
29
|
+
# build gem and add to release
|
30
|
+
- name: Upload Release Artifact
|
31
|
+
if: ${{ steps.release.outputs.release_created }}
|
32
|
+
env:
|
33
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
34
|
+
run:
|
35
|
+
gem build *.gemspec
|
36
|
+
gh release upload ${{ steps.release.outputs.tag_name }} *.gem
|
data/.github/workflows/test.yaml
CHANGED
@@ -4,7 +4,7 @@ on:
|
|
4
4
|
push:
|
5
5
|
branches: [ main ]
|
6
6
|
pull_request:
|
7
|
-
|
7
|
+
types: [opened, reopened, synchronize]
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
test:
|
@@ -13,15 +13,14 @@ jobs:
|
|
13
13
|
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby-version: ['3.
|
16
|
+
ruby-version: ['3.2', '3.0', '2.7', '2.3', truffleruby-head]
|
17
17
|
|
18
18
|
steps:
|
19
19
|
- uses: actions/checkout@v3
|
20
20
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
|
-
uses: ruby/setup-ruby@
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
22
|
with:
|
23
23
|
ruby-version: ${{ matrix.ruby-version }}
|
24
|
-
|
25
|
-
run: bundle install
|
24
|
+
bundler-cache: true
|
26
25
|
- name: Run tests
|
27
|
-
run: bundle exec rspec
|
26
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,27 +1,34 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## [6.3.0](https://github.com/mdp/rotp/compare/v6.2.2...v6.3.0) (2023-08-30)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Allow for non-standard provisioning URI params, eg. image/icon ([#91](https://github.com/mdp/rotp/issues/91)) ([45d8aac](https://github.com/mdp/rotp/commit/45d8aac8356424897faf3a0dbda59f88b22df775))
|
9
|
+
|
10
|
+
## 6.2.2
|
4
11
|
|
5
12
|
- Removed `rjust` from `generate_otp` in favor of more time constant version
|
6
13
|
|
7
|
-
|
14
|
+
## 6.2.1
|
8
15
|
|
9
16
|
- Removed old rdoc folder that was triggering a security warning due to an
|
10
17
|
old version of JQuery being included in the HTML docs. This has no impact
|
11
18
|
on the Ruby library.
|
12
19
|
|
13
|
-
|
20
|
+
## 6.2.0
|
14
21
|
|
15
22
|
- Update to expand compatibility with Ruby 3. This was only a change to the
|
16
23
|
gemspec, no code changes were necessary.
|
17
24
|
|
18
|
-
|
25
|
+
## 6.1.0
|
19
26
|
|
20
27
|
- Fixing URI encoding issues again, breaking out into it's own module
|
21
28
|
due to the complexity - closes #100 (@atcruice)
|
22
29
|
- Add docker-compose.yml to help with easier testing
|
23
30
|
|
24
|
-
|
31
|
+
## 6.0.0
|
25
32
|
|
26
33
|
- Dropping support for Ruby <2.3 (Major version bump)
|
27
34
|
- Fix issue when using --enable-frozen-string-literal Ruby option #95 (jeremyevans)
|
@@ -29,33 +36,33 @@
|
|
29
36
|
- Update gems (rake, addressable)
|
30
37
|
- Update Travis tests to include Ruby 2.7
|
31
38
|
|
32
|
-
|
39
|
+
## 5.1.0
|
33
40
|
|
34
41
|
- Create `random_base32` to perform `random` to avoid breaking changes
|
35
42
|
- Still needed to bump to 5.x due to Base32 cleanup
|
36
43
|
|
37
|
-
|
44
|
+
## 5.0.0
|
38
45
|
|
39
46
|
- Clean up base32 implementation to match Google Autheticator
|
40
47
|
- BREAKING `Base32.random_base32` renamed to random
|
41
48
|
- The argument is now byte length vs output string length for more precise bit strengths
|
42
49
|
|
43
|
-
|
50
|
+
## 4.1.0
|
44
51
|
|
45
52
|
- Add a digest option to the CLI #83
|
46
53
|
- Fix provisioning URI is README #82
|
47
54
|
- Improvements to docs
|
48
55
|
|
49
|
-
|
56
|
+
## 4.0.2
|
50
57
|
|
51
58
|
- Fix gemspec requirment for Addressable
|
52
59
|
|
53
|
-
|
60
|
+
## 4.0.1
|
54
61
|
|
55
62
|
- Rubocop for style fixes
|
56
63
|
- Replace deprecated URI.encode with Addressable's version
|
57
64
|
|
58
|
-
|
65
|
+
## 4.0.0
|
59
66
|
|
60
67
|
- Simplify API
|
61
68
|
- Remove support for Ruby < 2.0
|
@@ -65,96 +72,96 @@
|
|
65
72
|
- `TOTP#at`
|
66
73
|
- `TOTP#now` (first argument)
|
67
74
|
|
68
|
-
|
75
|
+
## 3.3.1
|
69
76
|
|
70
77
|
- Add OpenSSL as a requirement for Ruby 2.5. Fixes #70 & #64
|
71
78
|
- Allow Base32 with padding. #71
|
72
79
|
- Prevent verify with drift being negative #69
|
73
80
|
|
74
|
-
|
81
|
+
## 3.3.0
|
75
82
|
|
76
83
|
- Add digest algorithm parameter for non SHA1 digests - #62 from @btalbot
|
77
84
|
|
78
|
-
|
85
|
+
## 3.2.0
|
79
86
|
|
80
87
|
- Add 'verify_with_drift_and_prior' to prevent prior token use - #58 from @jlfaber
|
81
88
|
|
82
|
-
|
89
|
+
## 3.1.0
|
83
90
|
|
84
91
|
- Add Add digits paramater to provisioning URI. #54 from @sbc100
|
85
92
|
|
86
|
-
|
93
|
+
## 3.0.1
|
87
94
|
|
88
95
|
- Use SecureRandom. See mdp/rotp/pull/52
|
89
96
|
|
90
|
-
|
97
|
+
## 3.0.0
|
91
98
|
|
92
99
|
- Provisioning URL includes issuer label per RFC 5234 See mdp/rotp/pull/51
|
93
100
|
|
94
|
-
|
101
|
+
## 2.1.2
|
95
102
|
|
96
103
|
- Remove string literals to prepare immutable strings in Ruby 3.0
|
97
104
|
|
98
|
-
|
105
|
+
## 2.1.1
|
99
106
|
|
100
107
|
- Reorder the params for Windows Phone Authenticator - #43
|
101
108
|
|
102
|
-
|
109
|
+
## 2.1.0
|
103
110
|
|
104
111
|
- Add a CLI for generating OTP's mdp/rotp/pull/35
|
105
112
|
|
106
|
-
|
113
|
+
## 2.0.0
|
107
114
|
|
108
115
|
- Move to only comparing string OTP's.
|
109
116
|
|
110
|
-
|
117
|
+
## 1.7.0
|
111
118
|
|
112
119
|
- Move to only comparing string OTP's. See mdp/rotp/issues/32 - Moved to 2.0.0 - yanked from RubyGems
|
113
120
|
|
114
|
-
|
121
|
+
## 1.6.1
|
115
122
|
|
116
123
|
- Remove deprecation warning in Ruby 2.1.0 (@ylansegal)
|
117
124
|
- Add Ruby 2.0 and 2.1 to Travis
|
118
125
|
|
119
|
-
|
126
|
+
## 1.6.0
|
120
127
|
|
121
128
|
- Add verify_with_retries to HOTP
|
122
129
|
- Fix 'cgi' require and global DEFAULT_INTERVAL
|
123
130
|
|
124
|
-
|
131
|
+
## 1.5.0
|
125
132
|
|
126
133
|
- Add support for "issuer" parameter on provisioning url
|
127
134
|
- Add support for "period/interval" parameter on provisioning url
|
128
135
|
|
129
|
-
|
136
|
+
## 1.4.6
|
130
137
|
|
131
138
|
- Revert to previous Base32
|
132
139
|
|
133
|
-
|
140
|
+
## 1.4.5
|
134
141
|
|
135
142
|
- Fix and test correct implementation of Base32
|
136
143
|
|
137
|
-
|
144
|
+
## 1.4.4
|
138
145
|
|
139
146
|
- Fix issue with base32 decoding of strings in a length that's not a multiple of 8
|
140
147
|
|
141
|
-
|
148
|
+
## 1.4.3
|
142
149
|
|
143
150
|
- Bugfix on padding
|
144
151
|
|
145
|
-
|
152
|
+
## 1.4.2
|
146
153
|
|
147
154
|
- Better padding options (Pad the output with leading 0's)
|
148
155
|
|
149
|
-
|
156
|
+
## 1.4.1
|
150
157
|
|
151
158
|
- Clean up drift logic
|
152
159
|
|
153
|
-
|
160
|
+
## 1.4.0
|
154
161
|
|
155
162
|
- Added clock drift support via 'verify_with_drift' for TOTP
|
156
163
|
|
157
|
-
|
164
|
+
## 1.3.0
|
158
165
|
|
159
166
|
- Added support for Ruby 1.9.x
|
160
167
|
- Removed dependency on Base32
|
data/README.md
CHANGED
@@ -149,7 +149,7 @@ totp = ROTP::TOTP.new("base32secret3232", issuer: "My Service")
|
|
149
149
|
totp.provisioning_uri("alice@google.com") # => 'otpauth://totp/My%20Service:alice%40google.com?secret=base32secret3232&issuer=My%20Service'
|
150
150
|
|
151
151
|
hotp = ROTP::HOTP.new("base32secret3232", issuer: "My Service")
|
152
|
-
hotp.provisioning_uri("alice@google.com", 0) # => 'otpauth://hotp/alice%40google.com?secret=base32secret3232&counter=0'
|
152
|
+
hotp.provisioning_uri("alice@google.com", 0) # => 'otpauth://hotp/My%20Service:alice%40google.com?secret=base32secret3232&issuer=My%20Service&counter=0'
|
153
153
|
```
|
154
154
|
|
155
155
|
This can then be rendered as a QR Code which the user can scan using their mobile phone and the appropriate application.
|
data/docker-compose.yml
CHANGED
@@ -28,10 +28,10 @@ services:
|
|
28
28
|
volumes:
|
29
29
|
- "./lib:/usr/src/app/lib"
|
30
30
|
- "./spec:/usr/src/app/spec"
|
31
|
-
|
31
|
+
ruby_3_0:
|
32
32
|
build:
|
33
33
|
context: .
|
34
|
-
dockerfile: Dockerfile-3.0
|
34
|
+
dockerfile: Dockerfile-3.0
|
35
35
|
volumes:
|
36
36
|
- "./lib:/usr/src/app/lib"
|
37
37
|
- "./spec:/usr/src/app/spec"
|
data/lib/rotp/hotp.rb
CHANGED
@@ -24,8 +24,8 @@ module ROTP
|
|
24
24
|
# @param [String] name of the account
|
25
25
|
# @param [Integer] initial_count starting counter value, defaults to 0
|
26
26
|
# @return [String] provisioning uri
|
27
|
-
def provisioning_uri(name, initial_count = 0)
|
28
|
-
OTP::URI.new(self, account_name: name, counter: initial_count).to_s
|
27
|
+
def provisioning_uri(name = nil, initial_count = 0)
|
28
|
+
OTP::URI.new(self, account_name: name || @name, counter: initial_count).to_s
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/rotp/otp/uri.rb
CHANGED
@@ -2,9 +2,9 @@ module ROTP
|
|
2
2
|
class OTP
|
3
3
|
# https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
4
4
|
class URI
|
5
|
-
def initialize(otp, account_name
|
5
|
+
def initialize(otp, account_name: nil, counter: nil)
|
6
6
|
@otp = otp
|
7
|
-
@account_name = account_name
|
7
|
+
@account_name = account_name || ''
|
8
8
|
@counter = counter
|
9
9
|
end
|
10
10
|
|
@@ -34,8 +34,6 @@ module ROTP
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def issuer
|
37
|
-
return if @otp.is_a?(HOTP)
|
38
|
-
|
39
37
|
@otp.issuer&.strip&.tr(':', '_')
|
40
38
|
end
|
41
39
|
|
@@ -56,6 +54,7 @@ module ROTP
|
|
56
54
|
period: period,
|
57
55
|
counter: counter,
|
58
56
|
}
|
57
|
+
.merge(@otp.provisioning_params)
|
59
58
|
.reject { |_, v| v.nil? }
|
60
59
|
.map { |k, v| "#{k}=#{ERB::Util.url_encode(v)}" }
|
61
60
|
.join('&')
|
data/lib/rotp/otp.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ROTP
|
2
2
|
class OTP
|
3
|
-
attr_reader :secret, :digits, :digest
|
3
|
+
attr_reader :secret, :digits, :digest, :name, :issuer, :provisioning_params
|
4
4
|
DEFAULT_DIGITS = 6
|
5
5
|
|
6
6
|
# @param [String] secret in the form of base32
|
@@ -10,10 +10,22 @@ module ROTP
|
|
10
10
|
# @option options digest [String] (sha1)
|
11
11
|
# Digest used in the HMAC.
|
12
12
|
# Google Authenticate only supports 'sha1' currently
|
13
|
+
# @option options name [String]
|
14
|
+
# The name of the account for the OTP.
|
15
|
+
# Used in the provisioning URL
|
16
|
+
# @option options issuer [String]
|
17
|
+
# The issuer of the OTP.
|
18
|
+
# Used in the provisioning URL
|
19
|
+
# @option options provisioning_params [Hash] ({})
|
20
|
+
# Additional non-standard params you may want appended to the
|
21
|
+
# provisioning URI. Ex. `image: 'https://example.com/icon.png'`
|
13
22
|
# @returns [OTP] OTP instantiation
|
14
23
|
def initialize(s, options = {})
|
15
24
|
@digits = options[:digits] || DEFAULT_DIGITS
|
16
25
|
@digest = options[:digest] || 'sha1'
|
26
|
+
@name = options[:name]
|
27
|
+
@issuer = options[:issuer]
|
28
|
+
@provisioning_params = options[:provisioning_params] || {}
|
17
29
|
@secret = s
|
18
30
|
end
|
19
31
|
|
data/lib/rotp/totp.rb
CHANGED
@@ -53,8 +53,8 @@ module ROTP
|
|
53
53
|
# to provision the Google Authenticator app
|
54
54
|
# @param [String] name of the account
|
55
55
|
# @return [String] provisioning URI
|
56
|
-
def provisioning_uri(name)
|
57
|
-
OTP::URI.new(self, account_name: name).to_s
|
56
|
+
def provisioning_uri(name = nil)
|
57
|
+
OTP::URI.new(self, account_name: name || @name).to_s
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
data/lib/rotp/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"packages": {
|
3
|
+
".": {
|
4
|
+
"changelog-path": "CHANGELOG.md",
|
5
|
+
"bump-minor-pre-major": false,
|
6
|
+
"bump-patch-for-minor-pre-major": false,
|
7
|
+
"draft": false,
|
8
|
+
"prerelease": false
|
9
|
+
}
|
10
|
+
},
|
11
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
12
|
+
}
|
data/spec/lib/rotp/hotp_spec.rb
CHANGED
@@ -108,7 +108,15 @@ RSpec.describe ROTP::HOTP do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
describe '#provisioning_uri' do
|
111
|
-
|
111
|
+
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "m@mdp.im") }
|
112
|
+
let(:params) { CGI.parse URI.parse(uri).query }
|
113
|
+
|
114
|
+
it 'created from the otp instance data' do
|
115
|
+
expect(hotp.provisioning_uri())
|
116
|
+
.to eq 'otpauth://hotp/m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0'
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'allow passing a name to override the OTP name' do
|
112
120
|
expect(hotp.provisioning_uri('mark@percival'))
|
113
121
|
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0'
|
114
122
|
end
|
@@ -117,5 +125,29 @@ RSpec.describe ROTP::HOTP do
|
|
117
125
|
expect(hotp.provisioning_uri('mark@percival', 17))
|
118
126
|
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=17'
|
119
127
|
end
|
128
|
+
|
129
|
+
context 'with non-standard provisioning_params' do
|
130
|
+
let(:hotp) { ROTP::HOTP.new('a' * 32, digits: 8, provisioning_params: {image: 'https://example.com/icon.png'}) }
|
131
|
+
let(:uri) { hotp.provisioning_uri("mark@percival") }
|
132
|
+
|
133
|
+
it 'includes the issuer as parameter' do
|
134
|
+
expect(params['image'].first).to eq 'https://example.com/icon.png'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "with an issuer" do
|
139
|
+
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "m@mdp.im", issuer: "Example.com") }
|
140
|
+
|
141
|
+
it 'created from the otp instance data' do
|
142
|
+
expect(hotp.provisioning_uri())
|
143
|
+
.to eq 'otpauth://hotp/Example.com:m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0'
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'allow passing a name to override the OTP name' do
|
147
|
+
expect(hotp.provisioning_uri('mark@percival'))
|
148
|
+
.to eq 'otpauth://hotp/Example.com:mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
120
152
|
end
|
121
153
|
end
|
data/spec/lib/rotp/totp_spec.rb
CHANGED
@@ -2,11 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
TEST_TIME = Time.utc 2016, 9, 23, 9 # 2016-09-23 09:00:00 UTC
|
4
4
|
TEST_TOKEN = '082630'.freeze
|
5
|
+
TEST_SECRET = 'JBSWY3DPEHPK3PXP'
|
5
6
|
|
6
7
|
RSpec.describe ROTP::TOTP do
|
7
8
|
let(:now) { TEST_TIME }
|
8
9
|
let(:token) { TEST_TOKEN }
|
9
|
-
let(:totp) { ROTP::TOTP.new
|
10
|
+
let(:totp) { ROTP::TOTP.new TEST_SECRET }
|
10
11
|
|
11
12
|
describe '#at' do
|
12
13
|
let(:token) { totp.at now }
|
@@ -220,11 +221,52 @@ RSpec.describe ROTP::TOTP do
|
|
220
221
|
end
|
221
222
|
end
|
222
223
|
|
224
|
+
|
223
225
|
describe '#provisioning_uri' do
|
224
|
-
|
225
|
-
|
226
|
-
|
226
|
+
let(:params) { CGI.parse URI.parse(uri).query }
|
227
|
+
|
228
|
+
context "with a provided name on the TOTP instance" do
|
229
|
+
let(:totp) { ROTP::TOTP.new(TEST_SECRET, name: "m@mdp.im") }
|
230
|
+
it 'creates a provisioning uri from the OTP instance' do
|
231
|
+
expect(totp.provisioning_uri())
|
232
|
+
.to eq 'otpauth://totp/m%40mdp.im?secret=JBSWY3DPEHPK3PXP'
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'allow passing a name to override the OTP name' do
|
236
|
+
expect(totp.provisioning_uri('mark@percival'))
|
237
|
+
.to eq 'otpauth://totp/mark%40percival?secret=JBSWY3DPEHPK3PXP'
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
context 'with non-standard provisioning_params' do
|
242
|
+
let(:totp) {
|
243
|
+
ROTP::TOTP.new(TEST_SECRET,
|
244
|
+
provisioning_params: { image: 'https://example.com/icon.png' }
|
245
|
+
)
|
246
|
+
}
|
247
|
+
let(:uri) { totp.provisioning_uri("mark@percival") }
|
248
|
+
|
249
|
+
it 'includes the issuer as parameter' do
|
250
|
+
expect(params['image'].first).to eq 'https://example.com/icon.png'
|
251
|
+
end
|
252
|
+
|
227
253
|
end
|
254
|
+
|
255
|
+
context "with an issuer" do
|
256
|
+
let(:totp) { ROTP::TOTP.new(TEST_SECRET, name: "m@mdp.im", issuer: "Example.com") }
|
257
|
+
|
258
|
+
it 'creates a provisioning uri from the OTP instance' do
|
259
|
+
expect(totp.provisioning_uri())
|
260
|
+
.to eq 'otpauth://totp/Example.com:m%40mdp.im?secret=JBSWY3DPEHPK3PXP&issuer=Example.com'
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'allow passing a name to override the OTP name' do
|
264
|
+
expect(totp.provisioning_uri('mark@percival'))
|
265
|
+
.to eq 'otpauth://totp/Example.com:mark%40percival?secret=JBSWY3DPEHPK3PXP&issuer=Example.com'
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
|
228
270
|
end
|
229
271
|
|
230
272
|
describe '#now' 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: 6.
|
4
|
+
version: 6.3.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:
|
11
|
+
date: 2023-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -77,12 +77,14 @@ files:
|
|
77
77
|
- ".devcontainer/Dockerfile"
|
78
78
|
- ".devcontainer/devcontainer.json"
|
79
79
|
- ".dockerignore"
|
80
|
+
- ".github/workflows/release.yaml"
|
80
81
|
- ".github/workflows/test.yaml"
|
81
82
|
- ".gitignore"
|
83
|
+
- ".release-please-manifest.json"
|
82
84
|
- CHANGELOG.md
|
83
85
|
- Dockerfile-2.3
|
84
86
|
- Dockerfile-2.7
|
85
|
-
- Dockerfile-3.0
|
87
|
+
- Dockerfile-3.0
|
86
88
|
- Gemfile
|
87
89
|
- Guardfile
|
88
90
|
- LICENSE
|
@@ -98,6 +100,7 @@ files:
|
|
98
100
|
- lib/rotp/otp/uri.rb
|
99
101
|
- lib/rotp/totp.rb
|
100
102
|
- lib/rotp/version.rb
|
103
|
+
- release-please-config.json
|
101
104
|
- rotp.gemspec
|
102
105
|
- spec/lib/rotp/arguments_spec.rb
|
103
106
|
- spec/lib/rotp/base32_spec.rb
|
@@ -125,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
128
|
- !ruby/object:Gem::Version
|
126
129
|
version: '0'
|
127
130
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.4.10
|
129
132
|
signing_key:
|
130
133
|
specification_version: 4
|
131
134
|
summary: A Ruby library for generating and verifying one time passwords
|