-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add Steam algorithm behind 'steam' feature #47
Conversation
One of the main reason I was thinking of using an API similar to |
A This would still require a |
The work on algorithm is fine as is, yes! It's just that instanciating it from New would be awkward, hence a Steam struct, or more simply having a This would mean merging #46 and then rebasing Edit: Because having a struct for each custom provider would actually be way too much copy/pasted code, and would probably hurt readability |
Alright! I'll work on these I agree, that adding struct for this would add a lot of boilerplate. |
Thanks a lot! :) |
Now that I think about it, the get_url function should be mindful of the algo, as in the steam case, we need to use /steam/ instead of /totp/ |
Right. This is already handled in and |
ba8ad4e
to
b4bb7e9
Compare
d1ddfcd
to
c5fd820
Compare
This is now rebased on the latest master. A Currently, it detects @constantoine Are you fine with me implementing |
As long as it's gated behind the Steam feature, I think it's acceptable, yes |
Implemented. This is ready for review. |
#[cfg(feature = "steam")] | ||
Some(Host::Domain("steam")) => { | ||
algorithm = Algorithm::Steam; | ||
digits = 5; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like you only need to set the algo, not the digits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like some otpauth URLs don't set the number of digits at all for Steam. That means we must set it explicitly somewhere.
Not setting this would cause problems, such as incorrect otpauth URL generation.
Better ways to implement this would require breaking API changes, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Should we then ignore the digit parameter, should it be present? Just like we ignore algorithm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an option. But that will still generate invalid otpauth URLs, as it will have ?digit=6
. We can implement an exception there but I don't think that is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add some tests and benchmark some stuff on my end, but this PR is ready :)
I'll ping you when the release is published on cargo
Fantastic! Thanks for your help. |
This implements
Algorithm::Steam
behind thesteam
feature flag.Fixes #45
Note that this is somewhat dirty, but keeps the API stability intact. Notably:
steam
feature (disabled by default)Algorithm::Steam
variantTOTP::new()
if algorithm is SteamTOTP::generate()
uses Steam alphabet for token if Steam algorithm is usedTOTP::from_url()
parses Steam URLs if thesteam
path is detected.I've tested this successfully with my personal Steam token.
I'm not sure if this is good enough to be merged, but I figured this to be a good start.