Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otp_provisioning_uri formatting error #190

Open
Isaius opened this issue Apr 6, 2021 · 4 comments
Open

otp_provisioning_uri formatting error #190

Isaius opened this issue Apr 6, 2021 · 4 comments
Labels

Comments

@Isaius
Copy link

Isaius commented Apr 6, 2021

I've setup this gem before and write some tests. Now, when I updated to Rails 6.1.3 tests have been failing.

Expected behavior

I expect the otp_provisioning_uri returns the correct format in the README.
"otpauth://totp/Your%20App:user@example.com?secret=[otp_secret]&issuer=Your+App"

Actual behavior

When pass a label to the otp_provisioning_uri it returns an string with the @ characters transformed in %40 and the Issuer name twice.

Steps to reproduce

  • Have a user with 2FA enable
  • Call user.otp_provisioning_uri("Emitter:email@example.com, issuer: "Emitter")
  • receives "otpauth://totp/Emitter:Emitter_email%40example.com?secret=[secret]&issuer=Emitter"

Info

  • Ruby 2.7.2
  • Rails 6.1.3
  • The gem is using the github repository, since there's no release yet.
@Isaius
Copy link
Author

Isaius commented Apr 6, 2021

For some reason, with the actual version now the label is no more in the format ISSUER:email. Now otp_provisioning_uri only need the email and the issuer as a second parameter. As follows:

user.otp_provisioning_uri("email@example.com, issuer: "Emitter")

//=> otpauth://totp/Emitter:email%40example.com?secret=[secret]&issuer=Emitter

But the error with @ still happening.

@Isaius
Copy link
Author

Isaius commented Apr 6, 2021

An update:

I've solved this by decoding the URI, but haven't figured out what's the cause of this.
Since the ROTP gem is actually in 6.2.0 and this gem seems to be using 6.0 I'll dig a bit more and try to track what it is, because in the previous release that wasn't a problem.

@bsedat bsedat added the bug label Jul 8, 2022
@Jaco-Pretorius
Copy link

I'm running into the same issue

@Jaco-Pretorius
Copy link

Actually, I did some more digging and this is not my issue. I think you're correct that you only need to pass the email and the issuer. However, the URI should be encoded - if you look at the examples in the ROTP gem you can see they are expecting to output an encoded URI https://github.com/mdp/rotp#generating-qr-codes-for-provisioning-mobile-apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants