Git Product home page Git Product logo

drf-firebase-auth's People

Contributors

garyburgmann avatar jaylynch avatar justin-thurman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drf-firebase-auth's Issues

You should let to decide an unique username in def get_or_create_local_user()

Hi, I'm using you library

I was trying to sign in with anothe gmail account have my same displayname and the library don't let me beacuse in line 184 in the authentication.py :

username = '_'.join(
                firebase_user.display_name.split(' ') if firebase_user.display_name \
                else str(uuid.uuid4())
            )
            username = username if len(username) <= 30 else username[:30]
            new_user = User.objects.create_user(
                username=username,
                email=email
            )

you are using username with the split of displayname, an i think a lot of persons can have the same name.
Like Carlos Torres a lot of people will have this displayname but are diferent people or diferent email accounts.

I solve this changin de username with the email, let me know if work for you.

            new_user = User.objects.create_user(
                username=email,
                email=email
            )

Best Carlos

Viewset Testing not working unless forcing authentication

I'm not exactly sure if my issue is with the package itself or not, but here goes.

I've integrated drf-firebase-auth to my project and it seems to work as intended when I'm testing it from my client and with Postman.

However, when I test the views themselves I start getting 403 errors unless I force authenticate. I've submitted a question about this to Stack Overflow as well. Any help would be greatly appreciated.

There's a decent chance that I've just configured DRFs APITestCase settings incorrectly, so this might have nothing to do with the package itself.

Use with IsAuthenticatedOrReadOnly

No Authorization header returns Invalid Authorization header format, expecting: JWT <token>., and a blank one results in JWT was found to be invalid, or the App’s project ID cannot be determined. Is this the intended behavior? I have ALLOW_ANONYMOUS_REQUESTS set to True.

login by facebook

if the facebookuser is registread with mobile number in django local database user is not going to create why because facebok wont gives the info of users it only gives profile image and uid

drf-firebase-auth with angular

No Authorization header returns Invalid Authorization header format, expecting: JWT ., and a blank one results in JWT was found to be invalid, or the App’s project ID cannot be determined on my frontend (i am using angular). what am i missing out

Not Working for Firebase Mobile Authentication

I am using Firebase Mobile Auth, and getting error it is searching for email and obviously thats not available in phone authentication, please look at the issue.

Internal Server Error: /api/events/upcoming_events Traceback (most recent call last): File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\drf_firebase_auth\authentication.py", line 158, in get_or_create_local_user user = User.objects.get(email=email) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\db\models\manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\db\models\query.py", line 399, in get self.model._meta.object_name django.contrib.auth.models.User.DoesNotExist: User matching query does not exist.

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 77, in wrap_attributeerrors yield File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 223, in user self._authenticate() File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 376, in _authenticate user_auth_tuple = authenticator.authenticate(self) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\drf_firebase_auth\authentication.py", line 51, in authenticate local_user = self.get_or_create_local_user(firebase_user) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\drf_firebase_auth\authentication.py", line 182, in get_or_create_local_user display_name = firebase_user.display_name.split() AttributeError: 'NoneType' object has no attribute 'split'

Traceback (most recent call last): File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\views\generic\base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\views.py", line 495, in dispatch response = self.handle_exception(exc) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\views.py", line 455, in handle_exception self.raise_uncaught_exception(exc) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\views.py", line 483, in dispatch self.initial(request, *args, **kwargs) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\views.py", line 400, in initial self.perform_authentication(request) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\views.py", line 326, in perform_authentication request.user File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 223, in user self._authenticate() File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 81, in wrap_attributeerrors six.reraise(type(exc), exc, info[2]) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\django\utils\six.py", line 683, in reraise raise value.with_traceback(tb) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 77, in wrap_attributeerrors yield File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 223, in user self._authenticate() File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\rest_framework\request.py", line 376, in _authenticate user_auth_tuple = authenticator.authenticate(self) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\drf_firebase_auth\authentication.py", line 51, in authenticate local_user = self.get_or_create_local_user(firebase_user) File "F:\ProgramData\Anaconda3\envs\MyEnv\lib\site-packages\drf_firebase_auth\authentication.py", line 182, in get_or_create_local_user display_name = firebase_user.display_name.split() rest_framework.request.WrappedAttributeError: 'NoneType' object has no attribute 'split' [28/Mar/2019 19:21:19] "GET /api/events/upcoming_events HTTP/1.1" 500 21332

Should I use CSRF sessionauthentication with drf-firebase-auth?

I am currently using drf-firebase-auth with vue.js and I don't know if I should implement CSRF with Djangorestframework. Should I look on how to do it? And should I be concerned or not if I am not using it? I don't know too much about security, and I don't want to leave a vulnerability in my website. I checked the following explanation and it says:

TokenAuthentication. This requires clients to pass a token in the Authorization header of each request. This is the kind of authentication you should use for most client-server setups, like a mobile app or desktop app consuming your API.

This kind of auth doesn’t require CSRF protection. The token isn’t stored in a cookie, so it doesn’t get sent automatically by your browser, which means it can’t cause CSRF vulnerabilities.

What's your opinion on this?

Application crash if credentials are not provided

For some reasons (testing purpose and etc) it would be great to avoid this exception raising.

Traceback (most recent call last):
api | File "manage.py", line 16, in
api | execute_from_command_line(sys.argv)
api | File "/usr/local/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line
api | utility.execute()
api | File "/usr/local/lib/python3.8/site-packages/django/core/management/init.py", line 395, in execute
api | self.fetch_command(subcommand).run_from_argv(self.argv)
api | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
api | self.execute(*args, **cmd_options)
api | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 366, in execute
api | self.check()
api | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check
api | all_issues = self._run_checks(
api | File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 382, in _run_checks
api | return checks.run_checks(**kwargs)
api | File "/usr/local/lib/python3.8/site-packages/django/core/checks/registry.py", line 72, in run_checks
api | new_errors = check(app_configs=app_configs)
api | File "/usr/local/lib/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
api | return check_resolver(resolver)
api | File "/usr/local/lib/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
api | return check_method()
api | File "/usr/local/lib/python3.8/site-packages/django/urls/resolvers.py", line 407, in check
api | for pattern in self.url_patterns:
api | File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in get
api | res = instance.dict[self.name] = self.func(instance)
api | File "/usr/local/lib/python3.8/site-packages/django/urls/resolvers.py", line 588, in url_patterns
api | patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
api | File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in get
api | res = instance.dict[self.name] = self.func(instance)
api | File "/usr/local/lib/python3.8/site-packages/django/urls/resolvers.py", line 581, in urlconf_module
api | return import_module(self.urlconf_name)
api | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
api | return _bootstrap._gcd_import(name[level:], package, level)
api | File "", line 1014, in _gcd_import
api | File "", line 991, in _find_and_load
api | File "", line 975, in _find_and_load_unlocked
api | File "", line 671, in _load_unlocked
api | File "", line 783, in exec_module
api | File "", line 219, in _call_with_frames_removed
api | File "/src/urls.py", line 7, in
api | from drf_yasg import openapi
api | File "/usr/local/lib/python3.8/site-packages/drf_yasg/openapi.py", line 13, in
api | from .utils import dict_has_ordered_keys, filter_none, force_real_str
api | File "/usr/local/lib/python3.8/site-packages/drf_yasg/utils.py", line 16, in
api | from rest_framework.views import APIView
api | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 17, in
api | from rest_framework.schemas import DefaultSchema
api | File "/usr/local/lib/python3.8/site-packages/rest_framework/schemas/init.py", line 33, in
api | authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
api | File "/usr/local/lib/python3.8/site-packages/rest_framework/settings.py", line 220, in getattr
api | val = perform_import(val, attr)
api | File "/usr/local/lib/python3.8/site-packages/rest_framework/settings.py", line 168, in perform_import
api | return [import_from_string(item, setting_name) for item in val]
api | File "/usr/local/lib/python3.8/site-packages/rest_framework/settings.py", line 168, in
api | return [import_from_string(item, setting_name) for item in val]
api | File "/usr/local/lib/python3.8/site-packages/rest_framework/settings.py", line 177, in import_from_string
api | return import_string(val)
api | File "/usr/local/lib/python3.8/site-packages/django/utils/module_loading.py", line 17, in import_string
api | module = import_module(module_path)
api | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
api | return _bootstrap._gcd_import(name[level:], package, level)
api | File "/usr/local/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 32, in
api | firebase_credentials = firebase_admin.credentials.Certificate(
api | File "/usr/local/lib/python3.8/site-packages/firebase_admin/credentials.py", line 98, in init
api | raise ValueError('Failed to initialize a certificate credential. '
api | ValueError: Failed to initialize a certificate credential. Caused by: "No key could be detected."

Update readme

Include more info re: Python versions, setup, and testing

remove redundant code by subclassing authentication.TokenAuthentication

Can simply return from an authenticate_credentials() method, and define 'keyword' property for prefix (i.e. JWT or Bearer).

Have done this for another auth backend using KeyCloak and it worked well. This will not impact the current functionality, but merely remove a lot of the verbosity of the existing code.

Calls to firebase_auth.get_user() can add 100-200ms to request time

Hi,

Just reviewing my web API performance and found high latency whenever firebase_auth.get_user() is called, since it sends a blocking HTTP request to the Firebase Auth API.

I've read a few different Python Firebase Auth tutorials and they all just use the decoded JWT to supply user data, they do not make a call out to the Firebase web API. This makes sense since a synchronous HTTP call is bad for performance.

If FIREBASE_CHECK_JWT_REVOKED is enabled, the get_user() call is made twice per request cycle. One of these calls is surely redundant.

Apart from revocation is there a reason to fetch the user rather than using the properties that are already embedded in the JWT?

Thanks!

Facebook id Token can't be verified on Firebase

Hi,

The call to verify_id_token is failing here:

return firebase_auth.verify_id_token( firebase_token, check_revoked=api_settings.FIREBASE_CHECK_JWT_REVOKED )

The root cause seems to be in the following line in the pkcs1.py:

def verify(message, signature, pub_key): ... method_name = _find_method_hash(clearsig)

where it tries to find the hash method for the payload based on the following headers:

HASH_ASN1 = { 'MD5': b'\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10', 'SHA-1': b'\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14', 'SHA-224': b'\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04\x05\x00\x04\x1c', 'SHA-256': b'\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20', 'SHA-384': b'\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30', 'SHA-512': b'\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40', }

and it is not able to find the corresponding hash method (which I think it is SHA-256).

Let me know if I can help further.

Thanks!

_get_or_create_local_user - User.DoesNotExist: or detail": "duplicate key value violates unique constraint \"users_customuser_username_key\"\nDETAIL: Key (username)=(...) already exists

Hi

I don't know if this is related to drf-firebase-auth but I believe there is something I'm missing here. I'm developing a flutter app with a Django backend. After users sign in I send a request to REST APi and pull the necessary data.

This error happens on initial signup, after restarting the app, no error shows up. After the initial signup Server returns 403. If I check the logs I found these 2 errors.

I believe something happens when the local user is being created but I couldn't really find a solution. I caught these using Sentry and Apilogs
- _get_or_create_local_user - User.DoesNotExist: %useremail%
- detail": "duplicate key value violates unique constraint "users_customuser_username_key"\nDETAIL: Key (username)=(...) already exists

I'm also using default drf-firebase-auth settings.

Thank you for your time.

How to register FirebaseUser, FirebaseUserProvider in admin?

Can someone help how to register the models of the package to be visible in the admin panel?

I thought It would work if i add an admins.py with the code below to the package

from django.contrib import admin
from .models import FirebaseUser, FirebaseUserProvider

admin.site.register(FirebaseUser)
admin.site.register(FirebaseUserProvider)

Module 'firebase_admin.auth' has no attribute 'AuthError'

Versions

drf-firebase-auth~=0.0.6
Django~=2.2

During processing a request with expired token or invalid token AuthError exception failed to be thrown

To reproduce - just send an invalid token

Invalid token trace

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 118, in decode_token
    return firebase_auth.verify_id_token(
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/auth.py", line 179, in verify_id_token
    verified_claims = token_verifier.verify_id_token(id_token)
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 234, in verify_id_token
    return self.id_token_verifier.verify(id_token, self.request)
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 272, in verify
    header, payload = self._decode_unverified(token)
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 348, in _decode_unverified
    raise self._invalid_token_error(str(error), cause=error)
firebase_admin._auth_utils.InvalidIdTokenError: Wrong number of segments in token: b'undefined'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 74, in wrap_attributeerrors
    yield
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 57, in authenticate
    decoded_token = self.decode_token(firebase_token)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 127, in decode_token
    except firebase_auth.AuthError as exc:
AttributeError: module 'firebase_admin.auth' has no attribute 'AuthError'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/opt/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/python/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 493, in dispatch
    self.initial(request, *args, **kwargs)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 410, in initial
    self.perform_authentication(request)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 324, in perform_authentication
    request.user
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 78, in wrap_attributeerrors
    raise exc.with_traceback(info[2])
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 74, in wrap_attributeerrors
    yield
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 57, in authenticate
    decoded_token = self.decode_token(firebase_token)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 127, in decode_token
    except firebase_auth.AuthError as exc:
rest_framework.request.WrappedAttributeError: module 'firebase_admin.auth' has no attribute 'AuthError'

Expired token

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 118, in decode_token
    return firebase_auth.verify_id_token(
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/auth.py", line 179, in verify_id_token
    verified_claims = token_verifier.verify_id_token(id_token)
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 234, in verify_id_token
    return self.id_token_verifier.verify(id_token, self.request)
  File "/opt/python/lib/python3.8/site-packages/firebase_admin/_token_gen.py", line 339, in verify
    raise self._expired_token_error(str(error), cause=error)
firebase_admin._token_gen.ExpiredIdTokenError: Token expired, 1580047340 < 1580053167

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 74, in wrap_attributeerrors
    yield
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 57, in authenticate
    decoded_token = self.decode_token(firebase_token)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 127, in decode_token
    except firebase_auth.AuthError as exc:
AttributeError: module 'firebase_admin.auth' has no attribute 'AuthError'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/opt/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/python/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/python/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 493, in dispatch
    self.initial(request, *args, **kwargs)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 410, in initial
    self.perform_authentication(request)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/views.py", line 324, in perform_authentication
    request.user
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/usr/local/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 78, in wrap_attributeerrors
    raise exc.with_traceback(info[2])
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 74, in wrap_attributeerrors
    yield
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/opt/python/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 57, in authenticate
    decoded_token = self.decode_token(firebase_token)
  File "/opt/python/lib/python3.8/site-packages/drf_firebase_auth/authentication.py", line 127, in decode_token
    except firebase_auth.AuthError as exc:
rest_framework.request.WrappedAttributeError: module 'firebase_admin.auth' has no attribute 'AuthError'

Incompatible with Django 4.x

Using this package with django 4.x gives the following error:

Traceback (most recent call last):
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/rest_framework/settings.py", line 177, in import_from_string
    return import_string(val)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/pysetup/.venv/lib/python3.10/site-packages/drf_firebase_auth/authentication.py", line 11, in <module>
    from django.utils.encoding import smart_text
ImportError: cannot import name 'smart_text' from 'django.utils.encoding' (/opt/pysetup/.venv/lib/python3.10/site-packages/django/utils/encoding.py)

Smart text has been deprecated since django 3.0 and removed in 4.0. I'm willing to submit a PR that fixes this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.