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

Authentication for static files (and mjpeg) #4

Open
beasteers opened this issue Jul 20, 2022 · 0 comments
Open

Authentication for static files (and mjpeg) #4

beasteers opened this issue Jul 20, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request security Something that weakens security

Comments

@beasteers
Copy link
Contributor

There isn't really a way to enforce authentication for images and videos. I was thinking ideally we could get authentication working through cookies?

I was trying it out, but was struggling with it and eventually just disabled authentication for static files and for the mjpeg endpoint.

I also enabled token through query parameters but obvs that's a slight security issue.

Added cookie checking here:

def get_authorization(self, request: Request) -> str:
# get authorization from token query param, auth header, or cookie
token = request.query_params.get('token')
auth = f'Bearer {token}' if token else None
auth = auth or request.headers.get("Authorization")
auth = auth or request.cookies.get("authorization")
#print(auth, flush=True)
return auth

This is where static file authentication is disabled:

class AuthStaticFiles(RangedStaticFiles):
async def __call__(self, scope, receive, send) -> None:
assert scope["type"] == "http"
#request = Request(scope, receive)
#await UserAuth.require_authorization(await oauth2(request))
await super().__call__(scope, receive, send)

The mjpeg just exists in a separate router without auth but I had originally planned on putting it with the data endpoint
https://github.com/VIDA-NYU/ptg-api-server/blob/main/app/routers/mjpeg.py

@beasteers beasteers added enhancement New feature or request security Something that weakens security labels Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security Something that weakens security
Projects
None yet
Development

No branches or pull requests

2 participants