hedgedoc / cli

A tiny CLI for HedgeDoc
GNU Affero General Public License v3.0
150 stars 37 forks source link

403 when attempting to import a note #46

Closed LifelongNovember closed 2 years ago

LifelongNovember commented 2 years ago

Hi!

I am currently trying to import a local note to my own HedgeDoc instance. After a successful login, I get the following output from hedgedoc profile:

$ hedgedoc profile                                 
You are logged in to a HedgeDoc server.

HEDGEDOC_SERVER=https://my.hedgedoc.instance
HEDGEDOC_COOKIES_FILE=/home/me/.config/hedgedoc/key.conf

USER_NAME=me
USER_ID=some-uuid
USER_PHOTO=https://cdn.libravatar.org/avatar/myavatar

(I hid my info but it the same as what is set server-side) Immediately after running this, if I try to hedgedoc import a file with any existing or non-existing note_id, I get the following output:

$ hedgedoc import File.md note_id
https://my.hedgedoc.instance/new/note_id
Failed with a 403 status.
Hint: You may need to run 'hedgedoc login' to authenticate first.

But if I try without defining a note_id:

$ hedgedoc import File.md                       
https://my.hedgedoc.instance/new

(I should mention that if I try to hedgedoc profile right after these, it still shows that I'm correctly logged in)

Maybe I did something wrong when I configured my hedgedoc server, but everything seems to work well from my browser. Do you have any idea of why it's doing this?

Thank you very much!

hugopeixoto commented 2 years ago

I can reproduce the issue. Maybe something changed in the hedgedoc API. I'll investigate

hugopeixoto commented 2 years ago

To be able to specify a note_id, your server needs to allow custom urls. This is disabled by default, and can be enabled by setting CMD_ALLOW_FREEURL=true.

More information here: https://docs.hedgedoc.org/configuration/#users-and-privileges

I'll add this information to the README.