New version of otpauth_uri/4 with mandatory issuer - #36
Conversation
306e4cd to
42f7c62
Compare
|
The new version still has two function, one which raises if the issuer/label is incorrect or if they are mismatched, and one which returns a more precise error. I can:
Tell me what you prefer. |
|
I was thinking about this implementation: The rationale to raise is that previous implementations that have any of those two properties are, at the moment, broken. We should not need a new function. What do you think? |
|
I am not sure I understand your proposal here: in the third Another simple solution would be to have another function to let the user give the label and issuer separately in |
|
Good points. ❤️ What about adding a new version like this: And then we just deprecate the old one asking folks to call the new one? The thing is that I am not sure I am convinced about ok/error. Because it seems they are all errors by construction, not something inherent to the function. If you are passing an invalid argument, it indicates something you could have pruned before hand. |
|
Agreed, I just came to the same conclusion that it is the user's fault to call the function with wrong parameters and raising is fine as it should be considered a programming error. I like the new version, it ensures the URI is correct and respects the advices. The only change I would make would be to use the |
|
That works for me! Would you like to update/send a PR with tests? We can also add this special clause to the existing function: So we make the fourth argument of the new one optional. |
42f7c62 to
cb57dac
Compare
This helps build a correct URI following the recommendations to have the issuer both as a prefix to the account and as an "issuer" query parameter. Also, this checks that no colons are used either in the account or the issuer. Co-authored-by: José Valim <jose.valim@dashbit.co>
cb57dac to
894f845
Compare
|
One of the failure is related to Erlang installation, the other one complains about formatting but the PR is formatted ( |
Oh, I didn't notice your new commit, it has two extra spaces on an empty comment line, hence the formatting failure. |
|
Thanks, I will update CI in a later commit! :) |
|
💚 💙 💜 💛 ❤️ |
The
NimbleTOTP.otpauth_uri/2function doesn't check that the label is well-formed or that the issuer present in the keyword matches the one which might be present in the label.I noticed that when testing an URI generated by NimbleTOTP while trying to decode it with Rust's
totp-rscrate.