rotp 6.2.2 → 6.3.1
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 +11 -26
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/release.yaml +36 -0
- data/.github/workflows/test.yaml +6 -7
- data/.release-please-manifest.json +3 -0
- data/CHANGELOG.md +45 -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/arguments.rb +11 -2
- data/lib/rotp/cli.rb +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 +34 -1
- data/spec/lib/rotp/totp_spec.rb +46 -4
- metadata +11 -8
- data/.devcontainer/Dockerfile +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c2b1404b98062478370f77b91348c5480783bbf6353fcc4d1beea0603bea63f
|
|
4
|
+
data.tar.gz: 2134d1e2ce2af29a4b72f75a8c7b8bea073b215f2ace05be9e3cefd2f10e7587
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b787d125aa066e36a2f905bd9e707253c77f75a8abe189ca6eb6f160fa4203960064089ec6ba15ea3e16d83826d6f2346528b95942681226fca32b47a09763a
|
|
7
|
+
data.tar.gz: 1396bb30353567e42df1ecd602b6c93c88034d9755be47a1848b70200ceb1111cf35fcad0abd8c5d44881563821ae3d555be222153141da6723b1648072895c3
|
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
-
// https://github.com/
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
|
|
3
3
|
{
|
|
4
4
|
"name": "Ruby",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Use -bullseye variants on local on arm64/Apple Silicon.
|
|
11
|
-
"VARIANT": "3-bullseye",
|
|
12
|
-
// Options
|
|
13
|
-
"NODE_VERSION": "16"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
5
|
+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
|
6
|
+
"image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye"
|
|
7
|
+
|
|
8
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
9
|
+
// "features": {},
|
|
16
10
|
|
|
17
|
-
// Configure tool-specific properties.
|
|
18
|
-
"customizations": {
|
|
19
|
-
// Configure properties specific to VS Code.
|
|
20
|
-
"vscode": {
|
|
21
|
-
// Add the IDs of extensions you want installed when the container is created.
|
|
22
|
-
"extensions": [
|
|
23
|
-
"rebornix.Ruby"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
|
|
28
11
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
29
12
|
// "forwardPorts": [],
|
|
30
13
|
|
|
31
14
|
// Use 'postCreateCommand' to run commands after the container is created.
|
|
32
15
|
// "postCreateCommand": "ruby --version",
|
|
33
16
|
|
|
34
|
-
//
|
|
35
|
-
"
|
|
17
|
+
// Configure tool-specific properties.
|
|
18
|
+
// "customizations": {},
|
|
36
19
|
|
|
20
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
21
|
+
// "remoteUser": "root"
|
|
37
22
|
}
|
|
@@ -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@v4
|
|
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@v4
|
|
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
|
@@ -12,16 +12,15 @@ jobs:
|
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
|
|
14
14
|
strategy:
|
|
15
|
+
# Include '3.5.0-preview1' to test compatibility with the upcoming Ruby 3.5 release.
|
|
15
16
|
matrix:
|
|
16
|
-
ruby-version: ['3.
|
|
17
|
-
|
|
17
|
+
ruby-version: ['3.5.0-preview1', '3.4', '3.3', '3.2', '3.0', '2.7', '2.3', 'truffleruby-head']
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@v4
|
|
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,38 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## [6.3.1] (2025-06-03)
|
|
4
|
+
|
|
5
|
+
* Fix: Drop usage of OpenStruct to support Ruby 3.5
|
|
6
|
+
|
|
7
|
+
## [6.3.0](https://github.com/mdp/rotp/compare/v6.2.2...v6.3.0) (2023-08-30)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* 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))
|
|
13
|
+
|
|
14
|
+
## 6.2.2
|
|
4
15
|
|
|
5
16
|
- Removed `rjust` from `generate_otp` in favor of more time constant version
|
|
6
17
|
|
|
7
|
-
|
|
18
|
+
## 6.2.1
|
|
8
19
|
|
|
9
20
|
- Removed old rdoc folder that was triggering a security warning due to an
|
|
10
21
|
old version of JQuery being included in the HTML docs. This has no impact
|
|
11
22
|
on the Ruby library.
|
|
12
23
|
|
|
13
|
-
|
|
24
|
+
## 6.2.0
|
|
14
25
|
|
|
15
26
|
- Update to expand compatibility with Ruby 3. This was only a change to the
|
|
16
27
|
gemspec, no code changes were necessary.
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
## 6.1.0
|
|
19
30
|
|
|
20
31
|
- Fixing URI encoding issues again, breaking out into it's own module
|
|
21
32
|
due to the complexity - closes #100 (@atcruice)
|
|
22
33
|
- Add docker-compose.yml to help with easier testing
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
## 6.0.0
|
|
25
36
|
|
|
26
37
|
- Dropping support for Ruby <2.3 (Major version bump)
|
|
27
38
|
- Fix issue when using --enable-frozen-string-literal Ruby option #95 (jeremyevans)
|
|
@@ -29,33 +40,33 @@
|
|
|
29
40
|
- Update gems (rake, addressable)
|
|
30
41
|
- Update Travis tests to include Ruby 2.7
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
## 5.1.0
|
|
33
44
|
|
|
34
45
|
- Create `random_base32` to perform `random` to avoid breaking changes
|
|
35
46
|
- Still needed to bump to 5.x due to Base32 cleanup
|
|
36
47
|
|
|
37
|
-
|
|
48
|
+
## 5.0.0
|
|
38
49
|
|
|
39
50
|
- Clean up base32 implementation to match Google Autheticator
|
|
40
51
|
- BREAKING `Base32.random_base32` renamed to random
|
|
41
52
|
- The argument is now byte length vs output string length for more precise bit strengths
|
|
42
53
|
|
|
43
|
-
|
|
54
|
+
## 4.1.0
|
|
44
55
|
|
|
45
56
|
- Add a digest option to the CLI #83
|
|
46
57
|
- Fix provisioning URI is README #82
|
|
47
58
|
- Improvements to docs
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
## 4.0.2
|
|
50
61
|
|
|
51
62
|
- Fix gemspec requirment for Addressable
|
|
52
63
|
|
|
53
|
-
|
|
64
|
+
## 4.0.1
|
|
54
65
|
|
|
55
66
|
- Rubocop for style fixes
|
|
56
67
|
- Replace deprecated URI.encode with Addressable's version
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
## 4.0.0
|
|
59
70
|
|
|
60
71
|
- Simplify API
|
|
61
72
|
- Remove support for Ruby < 2.0
|
|
@@ -65,96 +76,96 @@
|
|
|
65
76
|
- `TOTP#at`
|
|
66
77
|
- `TOTP#now` (first argument)
|
|
67
78
|
|
|
68
|
-
|
|
79
|
+
## 3.3.1
|
|
69
80
|
|
|
70
81
|
- Add OpenSSL as a requirement for Ruby 2.5. Fixes #70 & #64
|
|
71
82
|
- Allow Base32 with padding. #71
|
|
72
83
|
- Prevent verify with drift being negative #69
|
|
73
84
|
|
|
74
|
-
|
|
85
|
+
## 3.3.0
|
|
75
86
|
|
|
76
87
|
- Add digest algorithm parameter for non SHA1 digests - #62 from @btalbot
|
|
77
88
|
|
|
78
|
-
|
|
89
|
+
## 3.2.0
|
|
79
90
|
|
|
80
91
|
- Add 'verify_with_drift_and_prior' to prevent prior token use - #58 from @jlfaber
|
|
81
92
|
|
|
82
|
-
|
|
93
|
+
## 3.1.0
|
|
83
94
|
|
|
84
95
|
- Add Add digits paramater to provisioning URI. #54 from @sbc100
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
## 3.0.1
|
|
87
98
|
|
|
88
99
|
- Use SecureRandom. See mdp/rotp/pull/52
|
|
89
100
|
|
|
90
|
-
|
|
101
|
+
## 3.0.0
|
|
91
102
|
|
|
92
103
|
- Provisioning URL includes issuer label per RFC 5234 See mdp/rotp/pull/51
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
## 2.1.2
|
|
95
106
|
|
|
96
107
|
- Remove string literals to prepare immutable strings in Ruby 3.0
|
|
97
108
|
|
|
98
|
-
|
|
109
|
+
## 2.1.1
|
|
99
110
|
|
|
100
111
|
- Reorder the params for Windows Phone Authenticator - #43
|
|
101
112
|
|
|
102
|
-
|
|
113
|
+
## 2.1.0
|
|
103
114
|
|
|
104
115
|
- Add a CLI for generating OTP's mdp/rotp/pull/35
|
|
105
116
|
|
|
106
|
-
|
|
117
|
+
## 2.0.0
|
|
107
118
|
|
|
108
119
|
- Move to only comparing string OTP's.
|
|
109
120
|
|
|
110
|
-
|
|
121
|
+
## 1.7.0
|
|
111
122
|
|
|
112
123
|
- Move to only comparing string OTP's. See mdp/rotp/issues/32 - Moved to 2.0.0 - yanked from RubyGems
|
|
113
124
|
|
|
114
|
-
|
|
125
|
+
## 1.6.1
|
|
115
126
|
|
|
116
127
|
- Remove deprecation warning in Ruby 2.1.0 (@ylansegal)
|
|
117
128
|
- Add Ruby 2.0 and 2.1 to Travis
|
|
118
129
|
|
|
119
|
-
|
|
130
|
+
## 1.6.0
|
|
120
131
|
|
|
121
132
|
- Add verify_with_retries to HOTP
|
|
122
133
|
- Fix 'cgi' require and global DEFAULT_INTERVAL
|
|
123
134
|
|
|
124
|
-
|
|
135
|
+
## 1.5.0
|
|
125
136
|
|
|
126
137
|
- Add support for "issuer" parameter on provisioning url
|
|
127
138
|
- Add support for "period/interval" parameter on provisioning url
|
|
128
139
|
|
|
129
|
-
|
|
140
|
+
## 1.4.6
|
|
130
141
|
|
|
131
142
|
- Revert to previous Base32
|
|
132
143
|
|
|
133
|
-
|
|
144
|
+
## 1.4.5
|
|
134
145
|
|
|
135
146
|
- Fix and test correct implementation of Base32
|
|
136
147
|
|
|
137
|
-
|
|
148
|
+
## 1.4.4
|
|
138
149
|
|
|
139
150
|
- Fix issue with base32 decoding of strings in a length that's not a multiple of 8
|
|
140
151
|
|
|
141
|
-
|
|
152
|
+
## 1.4.3
|
|
142
153
|
|
|
143
154
|
- Bugfix on padding
|
|
144
155
|
|
|
145
|
-
|
|
156
|
+
## 1.4.2
|
|
146
157
|
|
|
147
158
|
- Better padding options (Pad the output with leading 0's)
|
|
148
159
|
|
|
149
|
-
|
|
160
|
+
## 1.4.1
|
|
150
161
|
|
|
151
162
|
- Clean up drift logic
|
|
152
163
|
|
|
153
|
-
|
|
164
|
+
## 1.4.0
|
|
154
165
|
|
|
155
166
|
- Added clock drift support via 'verify_with_drift' for TOTP
|
|
156
167
|
|
|
157
|
-
|
|
168
|
+
## 1.3.0
|
|
158
169
|
|
|
159
170
|
- Added support for Ruby 1.9.x
|
|
160
171
|
- 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/arguments.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require 'optparse'
|
|
2
|
-
require 'ostruct'
|
|
3
2
|
|
|
4
3
|
module ROTP
|
|
5
4
|
class Arguments
|
|
5
|
+
Options = Struct.new(:time, :counter, :mode, :digest, :secret, :warnings)
|
|
6
|
+
|
|
6
7
|
def initialize(filename, arguments)
|
|
7
8
|
@filename = filename
|
|
8
9
|
@arguments = Array(arguments)
|
|
@@ -26,7 +27,15 @@ module ROTP
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def default_options
|
|
29
|
-
|
|
30
|
+
o = Options.new
|
|
31
|
+
o.time = true
|
|
32
|
+
o.counter = 0
|
|
33
|
+
o.mode = :time
|
|
34
|
+
o
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_h
|
|
38
|
+
options!.to_h
|
|
30
39
|
end
|
|
31
40
|
|
|
32
41
|
def parse
|
data/lib/rotp/cli.rb
CHANGED
|
@@ -31,9 +31,9 @@ module ROTP
|
|
|
31
31
|
return arguments.to_s if options.mode == :help
|
|
32
32
|
|
|
33
33
|
if options.mode == :time
|
|
34
|
-
ROTP::TOTP.new(options.secret, options).now
|
|
34
|
+
ROTP::TOTP.new(options.secret, options.to_h).now
|
|
35
35
|
elsif options.mode == :hmac
|
|
36
|
-
ROTP::HOTP.new(options.secret, options).at options.counter
|
|
36
|
+
ROTP::HOTP.new(options.secret, options.to_h).at options.counter
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
+
require 'uri'
|
|
2
3
|
|
|
3
4
|
RSpec.describe ROTP::HOTP do
|
|
4
5
|
let(:counter) { 1234 }
|
|
@@ -108,7 +109,15 @@ RSpec.describe ROTP::HOTP do
|
|
|
108
109
|
end
|
|
109
110
|
|
|
110
111
|
describe '#provisioning_uri' do
|
|
111
|
-
|
|
112
|
+
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "m@mdp.im") }
|
|
113
|
+
let(:params) { CGI.parse URI.parse(uri).query }
|
|
114
|
+
|
|
115
|
+
it 'created from the otp instance data' do
|
|
116
|
+
expect(hotp.provisioning_uri())
|
|
117
|
+
.to eq 'otpauth://hotp/m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0'
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'allow passing a name to override the OTP name' do
|
|
112
121
|
expect(hotp.provisioning_uri('mark@percival'))
|
|
113
122
|
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0'
|
|
114
123
|
end
|
|
@@ -117,5 +126,29 @@ RSpec.describe ROTP::HOTP do
|
|
|
117
126
|
expect(hotp.provisioning_uri('mark@percival', 17))
|
|
118
127
|
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=17'
|
|
119
128
|
end
|
|
129
|
+
|
|
130
|
+
context 'with non-standard provisioning_params' do
|
|
131
|
+
let(:hotp) { ROTP::HOTP.new('a' * 32, digits: 8, provisioning_params: {image: 'https://example.com/icon.png'}) }
|
|
132
|
+
let(:uri) { hotp.provisioning_uri("mark@percival") }
|
|
133
|
+
|
|
134
|
+
it 'includes the issuer as parameter' do
|
|
135
|
+
expect(params['image'].first).to eq 'https://example.com/icon.png'
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context "with an issuer" do
|
|
140
|
+
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "m@mdp.im", issuer: "Example.com") }
|
|
141
|
+
|
|
142
|
+
it 'created from the otp instance data' do
|
|
143
|
+
expect(hotp.provisioning_uri())
|
|
144
|
+
.to eq 'otpauth://hotp/Example.com:m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0'
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'allow passing a name to override the OTP name' do
|
|
148
|
+
expect(hotp.provisioning_uri('mark@percival'))
|
|
149
|
+
.to eq 'otpauth://hotp/Example.com:mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0'
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
120
153
|
end
|
|
121
154
|
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.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Percival
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -74,15 +74,17 @@ executables:
|
|
|
74
74
|
extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
|
76
76
|
files:
|
|
77
|
-
- ".devcontainer/Dockerfile"
|
|
78
77
|
- ".devcontainer/devcontainer.json"
|
|
79
78
|
- ".dockerignore"
|
|
79
|
+
- ".github/dependabot.yml"
|
|
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
|
|
@@ -110,7 +113,7 @@ homepage: https://github.com/mdp/rotp
|
|
|
110
113
|
licenses:
|
|
111
114
|
- MIT
|
|
112
115
|
metadata: {}
|
|
113
|
-
post_install_message:
|
|
116
|
+
post_install_message:
|
|
114
117
|
rdoc_options: []
|
|
115
118
|
require_paths:
|
|
116
119
|
- lib
|
|
@@ -125,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
128
|
- !ruby/object:Gem::Version
|
|
126
129
|
version: '0'
|
|
127
130
|
requirements: []
|
|
128
|
-
rubygems_version: 3.
|
|
129
|
-
signing_key:
|
|
131
|
+
rubygems_version: 3.5.22
|
|
132
|
+
signing_key:
|
|
130
133
|
specification_version: 4
|
|
131
134
|
summary: A Ruby library for generating and verifying one time passwords
|
|
132
135
|
test_files: []
|
data/.devcontainer/Dockerfile
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/ruby/.devcontainer/base.Dockerfile
|
|
2
|
-
|
|
3
|
-
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster
|
|
4
|
-
ARG VARIANT="3.1-bullseye"
|
|
5
|
-
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
|
|
6
|
-
|
|
7
|
-
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
|
|
8
|
-
ARG NODE_VERSION="none"
|
|
9
|
-
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
|
10
|
-
|
|
11
|
-
# [Optional] Uncomment this section to install additional OS packages.
|
|
12
|
-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|
13
|
-
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
|
14
|
-
|
|
15
|
-
# [Optional] Uncomment this line to install additional gems.
|
|
16
|
-
# RUN gem install <your-gem-names-here>
|
|
17
|
-
|
|
18
|
-
# [Optional] Uncomment this line to install global node packages.
|
|
19
|
-
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|