yitsushi / totp-cli

Authy/Google Authenticator like TOTP CLI tool written in Go.

Home Page:http://yitsushi.github.io/totp-cli/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parameter Instant requires input

germeshausen opened this issue · comments

commented

I tried to use the parameter instant and have noticed that an additional input is required.
So calling the .\totp-cli.exe instant Z4L6NI0Q3M2PDUBCXZSYN3UBJK first shows a blank line, i can type or just hit enter and then the totp is shown.

That's intentional. From the help:

   instant          Generate an OTP from TOTP_TOKEN or stdin without the Storage backend.

So yes, it waits for an input from stdin and it does not work with additional arguments. The token should never be pasted as an argument, either saved in an env var (for example CD/CI), pipe it from other program (or even like echo), or paste it after you started. If you put it into the command line with the command, it may show up in your shell history and usually that's something we want to avoid.

or just hit enter and then the totp is shown.

that totp shouldn't be correlated with the provided token. That was generated from an "empty string token".

commented

OK. Got it running.
But when I write
Write-Host $env:token | .\totp-cli.exe instant the token is printed to the console and this will also appear in the logs. I have tried to redirect the different streams, but without success.
How can I savely suppress printing the token?

Usually stdin and stdout are not in the log, only commands as written for shell history. What is the environment (I can see it's windows, but that's the only thing I can see), what logs?

Another note: I'm not a PowerShell mage, it's rare I use it, but looking up what Write-Host does, it send a message to the host. I think you want to use Write-Output. The following example shows Write-Host output doesn't go to stdout, while Write-Output does.

PS C:\Users\efert\Downloads> Write-Host "should fail with 'illegal' input" | .\totp-cli.exe instant
should fail with 'illegal' input
974991

PS C:\Users\efert\Downloads> Write-Output "should fail with 'illegal' input" | .\totp-cli.exe instant
 !!! otp error: illegal base32 data at input byte 14

(and sorry I'm very slow recently, I have to much on my plate and hard to focus)

commented

Thank you for your feedback. It looks good now and gives me the only output i expect.

$totp = "3SLSWZPQQBB7WBRYDAQZ5J77W5D7I6GU"
Write-Output $totp | .\totp-cli.exe instant

It was indeed the small difference between Write-Output and Write-Host.
Thank you for your assistance ;-)