hedgedoc / cli

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

CURL-generated cookies.txt file not working to authenticate wget downloads #26

Closed CptPie closed 4 years ago

CptPie commented 5 years ago

Description

I am not sure if it is just a usage error or if it is actually an issue. After logging in with valid credentials the script prints a success message. When i then try to download a pad the download results in a html file prompting to login to access the pad. While testing i noticed that the download only works when the pad is visible for guests which makes me belive that the login functionality is not working correctly or the login state is not tracked.

Executed commands:

env CODIMD_SERVER="{our codimd server}" codimd login --ldap {username} {password} $ Logged in {our codimd server} as {username} successfully. env CODIMD_SERVER="{our codimd server}" codimd export --md {pad id} file.md (file is downloaded but contains html)

Desired state:

The Login Information is carried over to the download function which then downloads the correct data.

Current state:

The Login Information doesn't seem to be carried over and a download (of a restricted pad) results in html.

Steps to Reproduce:

see Executed Commands

Fumesover commented 5 years ago

You are supposed to use --ldap to use ldap login cf https://github.com/codimd/cli/blob/023a017a7fa33640aea1a84d6614da49b0a084e8/bin/codimd#L125

CptPie commented 5 years ago

Sorry, my bad - I am using the --ldap option - I just forgot to add it to the problem description I'll edit the original post

wscheicher commented 4 years ago

Same here. Figured out curl based options did work (profile, history, ...) so i tried to replace

wget --load-cookies "$CODIMD_COOKIES_FILE" -O "$exportpath" "$CODIMD_SERVER/$noteid/download"

with

curl -s -b "$CODIMD_COOKIES_FILE" "$CODIMD_SERVER/$noteid/download" -o "$exportpath"

and then things worked.

pirate commented 4 years ago

This is definitely a bug, can you post your (redacted) $CODIMD_COOKIES_FILE here? (it defaults to ~/.codimd-key.conf). In theory cookies.txt should be cross-compatible between curl and wget, but maybe there's some formatting issue or bug making it incompatible with wget.

http://www.cookiecentral.com/faq/#3.5

pirate commented 4 years ago

Fixed in https://github.com/codimd/cli/commit/83d913ef468d738a2f1bd44c1d90b29ff8e6a4d5

(but not for the slides & html export, so if you find some working wget options still let us know)