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

Add basic authentication support for tm-http-request #8109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jermolene
Copy link
Owner

This PR adds support for basic authentication to the tm-http-request.

It was already possible to create an "Authorisation" header of the correct format with code like this:

header-Authorization={{{ [<username>addsuffix[:]addsuffix<password>encodebase64[]addprefix[Basic ]] }}}

However, that will only work if the password is available to wikitext. It is preferred to store passwords via the <$password> widget so that they are not accessible to casual wikitext.

This PR adds four new parameters to the tm-http-requestmessage that allow the username and password to be passed as plain text, or taken from named entries in the password store:

  • basic-auth-username - Optional username for HTTP basic authentication
  • basic-auth-username-from-store - Optional username for HTTP basic authentication, specified as the name of the entry in the password store containing the username
  • basic-auth-password - Optional password for HTTP basic authentication
  • basic-auth-password-from-store - Optional password for HTTP basic authentication, specified as the name of the entry in the password store containing the password

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Mar 27, 2024 10:37am

@Jermolene
Copy link
Owner Author

@mklauber do you have any thoughts on this? It is intended to make it easier to store basic auth credentials in the TW password vault.

@mklauber
Copy link
Contributor

I don't have an strong feeling about it. tm-http-request is becoming a very complex widgetMessage, but I'm not sure if there's a better way to implement it.

If we wrote a Filter Operator password[...name of password...] that returned strings from the password store, you could probably rewrite the above as a macro instead of embedding it inside the tm-http-request. I'm not sure if that's desirable.

Something like:
header-Authorization=<<BasicAuth username:"username" password:"password" >> or header-Authorization=<<BasicAuth username-from-store:"username" password-from-store:"password" >>

@mklauber
Copy link
Contributor

Overall, I wouldn't been concerned about this PR until you asked for input. Since you asked, those are my thoughts, but I'm happy with this as it is.

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.

None yet

2 participants