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

Library errors out when auth token has whitespace / newlines #107

Open
nijikokun opened this issue Jul 11, 2023 · 1 comment
Open

Library errors out when auth token has whitespace / newlines #107

nijikokun opened this issue Jul 11, 2023 · 1 comment

Comments

@nijikokun
Copy link

What's happening:

Library rejects authentication tokens with additional newlines or whitespace before / after the token (e.g. <authtoken>\n):

ERRO[0000] failed to reconnect session                   
err="authentication failed: The authtoken you specified does not look like a proper ngrok tunnel authtoken.\n
Your authtoken: <authtoken>\n\n
Instructions to install your authtoken are on your ngrok dashboard:\nhttps://dashboard.ngrok.com/get-started/your-authtoken\r\n\r\nERR_NGROK_105\r\n" id=974c591a9879 obj=csess

Expectation:

  • User sets authentication token with whitespace / newlines (e.g. <authtoken>\n)
  • Library trims authentication token for whitespace / newlines (becomes <authtoken>)
  • Library works as expected
@euank
Copy link
Contributor

euank commented Jul 12, 2023

This feels like it should be the caller's responsibility, not the library's.

If we had something like WithAuthTokenFromFile("/some/path"), chomping newlines off that would make sense, but the methods we provide are WithAuthtoken(string) and WithAuthtokenFromEnv().

For WithAuthtokenFromEnv(), trimming makes some sense to me. For WithAuthtoken(string), it really feels like it should be the caller's responsibility to do WithAuthtoken(strings.TrimSpace(authToken)) if they've gotten it from a source where it might have whitespace (such as from reading a file).

Are you expecting to just trim the environment variable one (which makes sense to me!), or are you suggesting trimming for both methods?

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