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

Trim newlines of token #73

Open
rickdgeerling opened this issue Mar 1, 2023 · 1 comment
Open

Trim newlines of token #73

rickdgeerling opened this issue Mar 1, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@rickdgeerling
Copy link

Summary

A token with additional newlines is not considered valid and results in a rather unhelpful error message: Failed to retrieve item: Get "http://onepassword-connect:8080/v1/vaults?filter=title+eq+%22engineering%22": net/http: invalid header field value for "Authorization". Trimming newlines would resolve the problem.

This is not a bug, because headers shouldn't contain newlines, but trimming the token string would result in a better developer-experience. It's rather easy to create such an invalid token with kubectl create secret generic op-token --from-file=token=token.txt because a lot of text editors are configured to add a trailing newline.

Use cases

Can save a few hours of debugging for anyone that doesn't follow the getting started guide exactly. In my case I integrated it into an existing Kustomize setup. Kustomize emphasises a declarative approach and loading the secret from a file is therefore not a strange approach.

Proposed solution

Please trim the token. I'd open up a PR but I'm not familiar with Go and its toolchain

Is there a workaround to accomplish this today?

Yes, remove newlines with some bash-fu

cat token.txt | tr -d "\n" > trimmed_token.txt

References & Prior Work

n/a

@edif2008 edif2008 added the enhancement New feature or request label Dec 1, 2023
@edif2008
Copy link
Member

edif2008 commented Dec 1, 2023

Hey @tuxmachine! 👋

Thank you for raising this enhancement for the SDK.
I can see this come in handy to ensure any leading or following whitespaces and newlines don't break the flow of using the token.
We've tracked this internally and keep you updated when there's progress on it. 😄

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

No branches or pull requests

2 participants