-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow for non-standard provisioning URI params, eg. image/icon (#…
…91) - Added the ability to add custom provisioning params to the provisionsing URI. - Matched up TOTP provisioning URI's with HOTP provisioning URI's - https://github.com/google/google-authenticator/wiki/Key-Uri-Format - Small chore fixes to CHANGELOG formatting
- Loading branch information
Showing
8 changed files
with
134 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,7 @@ totp = ROTP::TOTP.new("base32secret3232", issuer: "My Service") | |
totp.provisioning_uri("[email protected]") # => 'otpauth://totp/My%20Service:alice%40google.com?secret=base32secret3232&issuer=My%20Service' | ||
|
||
hotp = ROTP::HOTP.new("base32secret3232", issuer: "My Service") | ||
hotp.provisioning_uri("[email protected]", 0) # => 'otpauth://hotp/alice%40google.com?secret=base32secret3232&counter=0' | ||
hotp.provisioning_uri("[email protected]", 0) # => 'otpauth://hotp/My%20Service:alice%40google.com?secret=base32secret3232&issuer=My%20Service&counter=0' | ||
``` | ||
|
||
This can then be rendered as a QR Code which the user can scan using their mobile phone and the appropriate application. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,15 @@ | |
end | ||
|
||
describe '#provisioning_uri' do | ||
it 'accepts the account name' do | ||
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "[email protected]") } | ||
let(:params) { CGI.parse URI.parse(uri).query } | ||
|
||
it 'created from the otp instance data' do | ||
expect(hotp.provisioning_uri()) | ||
.to eq 'otpauth://hotp/m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0' | ||
end | ||
|
||
it 'allow passing a name to override the OTP name' do | ||
expect(hotp.provisioning_uri('mark@percival')) | ||
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=0' | ||
end | ||
|
@@ -117,5 +125,29 @@ | |
expect(hotp.provisioning_uri('mark@percival', 17)) | ||
.to eq 'otpauth://hotp/mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&counter=17' | ||
end | ||
|
||
context 'with non-standard provisioning_params' do | ||
let(:hotp) { ROTP::HOTP.new('a' * 32, digits: 8, provisioning_params: {image: 'https://example.com/icon.png'}) } | ||
let(:uri) { hotp.provisioning_uri("mark@percival") } | ||
|
||
it 'includes the issuer as parameter' do | ||
expect(params['image'].first).to eq 'https://example.com/icon.png' | ||
end | ||
end | ||
|
||
context "with an issuer" do | ||
let(:hotp) { ROTP::HOTP.new('a' * 32, name: "[email protected]", issuer: "Example.com") } | ||
|
||
it 'created from the otp instance data' do | ||
expect(hotp.provisioning_uri()) | ||
.to eq 'otpauth://hotp/Example.com:m%40mdp.im?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0' | ||
end | ||
|
||
it 'allow passing a name to override the OTP name' do | ||
expect(hotp.provisioning_uri('mark@percival')) | ||
.to eq 'otpauth://hotp/Example.com:mark%40percival?secret=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&issuer=Example.com&counter=0' | ||
end | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.