Skip to content

Commit

Permalink
Check the other thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Douwe M Osinga committed Nov 8, 2024
1 parent 3ddf8d9 commit 5b41853
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ The easiest way to get started is to use the docker image. This will give you a

```shell

<<<<<<< Updated upstream
docker-compose up -d
=======
docker compose up -d
docker logs neptyne-spreadsheet-neptyne-1
>>>>>>> Stashed changes

```

Only need to build it once. After that, you can just run `docker-compose up`.
The second statement will print out the shared secret you need to connect to the Neptyne server.
Open that url and you are in business.

```shell

### Method 2: pip install

Expand Down
11 changes: 8 additions & 3 deletions server/users.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Any, Literal

from jwt import PyJWTError
from sqlalchemy import func
from sqlalchemy.orm import Session
from tornado import web
from tornado_sqlalchemy import SessionMixin

from server.gsheet_auth import decode_gsheet_extension_token
from server.models import (
EmailShare,
FirebaseUser,
Expand All @@ -19,7 +21,7 @@
def token_from_headers(request_handler: web.RequestHandler) -> str | None:
header = request_handler.request.headers.get("Authorization")
if not header:
return None
return request_handler.request.headers.get("X-Neptyne-GSheet-Auth-Token")

parts = header.split(" ")
if len(parts) != 2 or parts[0].lower() != "bearer":
Expand Down Expand Up @@ -55,8 +57,11 @@ async def _authenticate_request(
)
if not token:
raise web.HTTPError(401, "Missing token")
if not token == shared_secret: # TODO: also check for a signed token
raise web.HTTPError(401, "Invalid token")
if not token == shared_secret:
try:
decode_gsheet_extension_token(token)
except PyJWTError:
raise web.HTTPError(401, "Invalid token")
return await load_user(
session,
"<single-user-firebase-uid>",
Expand Down

0 comments on commit 5b41853

Please sign in to comment.