-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Pupmp versio to 1.2.0. Adapt with
clock_skew_seconds
- Loading branch information
1 parent
a186412
commit 255b94f
Showing
8 changed files
with
23 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
Using google authentication (with application) | ||
Using firebase authentication (with web) | ||
""" | ||
|
||
import abc | ||
import datetime | ||
|
||
|
@@ -79,10 +80,13 @@ def djb2(seed): | |
|
||
|
||
class AbstractAuthentication(authentication.BaseAuthentication): | ||
token_post_index_name= "id_token" | ||
token_post_index_name = "id_token" | ||
|
||
def authenticate(self, request): | ||
auth_header = request.META.get("HTTP_AUTHORIZATION") or "" | ||
id_token = request.data.get(self.token_post_index_name) or auth_header.split(" ").pop() | ||
id_token = ( | ||
request.data.get(self.token_post_index_name) or auth_header.split(" ").pop() | ||
) | ||
if not auth_header and not id_token: | ||
# return AnonymousUser, None | ||
return None | ||
|
@@ -112,7 +116,7 @@ def authenticate(self, request): | |
if not id_token or not decoded_token: | ||
return None | ||
|
||
striped_user_name = authenticated_user['email'].split("@")[0] | ||
striped_user_name = authenticated_user["email"].split("@")[0] | ||
# Let's add random chars after the stiped username | ||
# There may be the case where [email protected] and [email protected] users register | ||
# We will generate random string using the email as seed | ||
|
@@ -130,15 +134,13 @@ def authenticate(self, request): | |
defaults=defaults, | ||
)[0] | ||
avatar_url = authenticated_user.get("picture") | ||
uid =authenticated_user.get("uid") | ||
uid = authenticated_user.get("uid") | ||
full_name = authenticated_user.get("name") | ||
first_name = full_name.split(" ")[0] | ||
last_name = ( | ||
" ".join(full_name.split(" ")[1:]) if len(full_name.split(" ")) > 1 else "" | ||
) | ||
profile = self._get_or_create_profile( | ||
user=user, uid=uid, avatar=avatar_url | ||
) | ||
profile = self._get_or_create_profile(user=user, uid=uid, avatar=avatar_url) | ||
|
||
if user.first_name != first_name or user.last_name != last_name: | ||
user.first_name = first_name | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .settings import * | ||
from .settings import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from django.urls import path | ||
from django_firebase_auth.viewsets.firebase_auth_viewset import FirebaseAuthViewSet | ||
|
||
app_name = 'firebase_auth' | ||
app_name = "firebase_auth" | ||
urlpatterns = [ | ||
path('login/', FirebaseAuthViewSet.as_view(), name='login'), | ||
path("login/", FirebaseAuthViewSet.as_view(), name="login"), | ||
# path('logout/', FirebaseAuthLogoutViewSet.as_view(), name='logout'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ def create(self, request): | |
""" | ||
This method is used to logout the user from the firebase. | ||
""" | ||
pass | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
setuptools | ||
django | ||
djangorestframework | ||
firebase-admin | ||
firebase-admin>=6.5.0 | ||
supabase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters