Skip to content

Commit

Permalink
feat: access with /raw/name?password
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed Jul 9, 2024
1 parent 0becd8e commit 16c3fa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ FLASK_ENV=production poetry run python wsgi.py

```shell
# Get clip named my_clip
curl http://example.com/raw/my_clip?pwd=my_password
curl http://example.com/raw/my_clip?my_password
```

### Debug
Expand All @@ -66,7 +66,7 @@ cd frontend
yarn dev
# backend
cd server
poetry run python wsgi.py --debug
poetry run python wsgi.py
```

### Backend database initailization
Expand Down
8 changes: 5 additions & 3 deletions server/app/resources/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ def decorated_function(*args, **kwargs):
except (binascii.Error, UnicodeDecodeError):
return return_json(status_code=400, message="Invalid password provided")
else:
# then, try get password from query string (first try "password", then try "pwd")
plain_password = request.args.get("pwd", "")
if plain_password != "":
plain_password = ""
# then, try get password from url query (like "/raw/name?password")
if len(request.args) == 1:
plain_password = list(request.args.keys())[0]
if plain_password:
password = sha512(plain_password)

note = g.note
Expand Down

0 comments on commit 16c3fa4

Please sign in to comment.