Skip to content

Extract secret from otpauth uri - #37

Closed
samueltardieu wants to merge 1 commit into
dashbitco:masterfrom
samueltardieu:extract-secret
Closed

Extract secret from otpauth uri#37
samueltardieu wants to merge 1 commit into
dashbitco:masterfrom
samueltardieu:extract-secret

Conversation

@samueltardieu

Copy link
Copy Markdown
Contributor

This extracts the secret from an otpauth:// URI.

@samueltardieu

Copy link
Copy Markdown
Contributor Author

Since this information comes from outside, a lot of checks are done to ensure that this is a valid URI. Should a less strict parsing be required in some contexts, a simple URI.parse(uri).query |> URI.decode_query() |> Map.get("secret") without any verification should do the job.

@samueltardieu
samueltardieu marked this pull request as draft October 28, 2025 09:34
@samueltardieu

Copy link
Copy Markdown
Contributor Author

Setting to draft, I want to double-check that labels are mandatory

@josevalim

Copy link
Copy Markdown
Member

Thank you @samueltardieu! I am starting to wonder if it should be part of this library, as we mostly concern ourselves with generating TOTPs...

@samueltardieu

Copy link
Copy Markdown
Contributor Author

Yes, it is mandatory.

@samueltardieu
samueltardieu marked this pull request as ready for review October 28, 2025 09:36
@samueltardieu

Copy link
Copy Markdown
Contributor Author

Thank you @samueltardieu! I am starting to wonder if it should be part of this library, as we mostly concern ourselves with generating TOTPs...

My use case was to programatically access a service for which I had to enter a TOTP. I could indeed use this version in my own service, or release an extra library, since all the functions from NimbleTOTP that are used inside are public. As you wish.

@josevalim

Copy link
Copy Markdown
Member

Hi @samueltardieu! Thank you for the contributions but yes, I think this is a bit outside of NimbleTOTP for now. I appreciate the time and you sharing the code with us though. ❤️

@josevalim josevalim closed this Oct 28, 2025
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

Successfully merging this pull request may close these issues.

2 participants