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

cmd/tclipd: allow creating tokens to edit the contents of a note from a Internet node #43

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

Conversation

lucasew
Copy link

@lucasew lucasew commented Sep 30, 2023

This is a opt-in feature that, to be enabled, one must pass a flag (-use-set-tokens) or a environment variable (USE_SET_TOKENS) to enable.

Basically it allows the owner of a note to create edit tokens. The flow is the following:

  • User creates a note.
  • User creates a token for a note.
  • Server gives a full URL.
  • User can now set the content of that note by passing the content as body to the full URL of the previous step.
  • If funnel is enabled then the user can even use the tokens through the Internet using any machine that speaks HTTP and can connect to the Internet.

In practice:

  • go run -v ./cmd/tclipd -data-location /tmp/test-paste -hostname test-paste -tsnet-verbose -use-funnel -use-set-tokens
  • Create a note from the Web UI then a token on the note page
  • It will give you a full link like https://test-paste.stargazer-shark.ts.net/api/token/set/0d4f1364-548f-4fdd-ba08-d5e1c3503044
  • Change the content of the note using HTTP requests
    • Ex: curl https://test-paste.stargazer-shark.ts.net/api/token/set/0d4f1364-548f-4fdd-ba08-d5e1c3503044 -d blah

I also abstracted away some details like the function to assert that the request is in the form format to a function to reuse in other routes (before that this logic was only used once).

BTW I hope I got the CSS right lol.

… a Internet node

Signed-off-by: lucasew <lucas59356@gmail.com>
@Erisa Erisa added the enhancement New feature or request label Jul 15, 2024
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

Successfully merging this pull request may close these issues.

2 participants