Skip to content

Conversation

@paper-dragonfly
Copy link
Collaborator

firebase authentication + jwt access tokens. Working (yay!) but still needs clean up and testing.

@@ -0,0 +1,32 @@
"""added firebase_id column to User table
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next time, use a shorter name because this becomes the file name.

alembic
email-validator
fastapi
firebase_admin
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to execute ./update-deps.sh when you make changes to the dependencies. that will change the lock files, which need to be a part of this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you do that or do I still need to do that?



def verify_firebase_token(authorization: str):
# TODO: adding delay is a hack fix for clock skew issue with firebase - find better solution?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought you were not gonna do this approach?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved away from using firebase to authenticate each API request. However, I still need to authenticate with firebase when they log in which requires this hack.

if ENV == "test":
log.debug("Bypass token verification")
return 'fakeid'
try:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the point of this exception handling? i think you can take it out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catches errors like if the token is invalid or expired

class UserFirebase(User):
firebase_id: str

class UserAuth(User):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having so many variants of the User class. I wonder if we should separate the access-token from the User. Instead, make it an Auth object. If needed, we can have endpoints that return both a User and an Auth.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this one to you.

email: EmailStr
username: str = Field(..., min_length=3, max_length=15)
# TODO: need to inform user of min/max user name constraint
# or create allert in the event that credentials don't meet specifications
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or create allert in the event that credentials don't meet specifications
# or create alert in the event that credentials don't meet specifications

@@ -1 +1,3 @@
export ENV=dev
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this. The default is already dev. If you put this here, you can't run the prod-debug env, or the test env, with this script.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so...just delete the line?

paper-dragonfly and others added 3 commits July 20, 2024 12:43
Co-authored-by: Nico <[email protected]>
add nico's comment

Co-authored-by: Nico <[email protected]>
explicitly make firebase_id column nullable

Co-authored-by: Nico <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants