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

Wrong getURI method #81

Open
andilem opened this issue Jun 25, 2024 · 1 comment
Open

Wrong getURI method #81

andilem opened this issue Jun 25, 2024 · 1 comment

Comments

@andilem
Copy link

andilem commented Jun 25, 2024

Your HOTPGenerator#getURI method is mighty wrong.

  1. Special characters in the components (label, issuer) must be URI-encoded, i.e. replace " " by "%20" (and not by "+") and so on.
    Possible solution: Apply following encoding to the label parts (issuer and account) and to the issuer parameter. Note that it is valid to encode the : in the label as well, but this is not required.
URLEncoder.encode(s, StandardCharsets.UTF_8)
    .replace("+", "%20")
    .replace("%21", "!")
    .replace("%27", "'")
    .replace("%28", "(")
    .replace("%29", ")")
    .replace("%7E", "~")
  1. The secret must be Base32-encoded, e.g. new Base32().encodeToString(secret) using Apache Commons Codec Base32 implementation
@BastiaanJansen
Copy link
Owner

Thanks for you comment. I am open to Pull requests, as I currently don't have the time to implement your solution.

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

No branches or pull requests

2 participants