{"id":15447961,"url":"https://github.com/geolffreym/jwtauth","last_synced_at":"2026-05-17T02:38:56.556Z","repository":{"id":85046748,"uuid":"91709151","full_name":"geolffreym/jwtAuth","owner":"geolffreym","description":"Django JWT auth middleware ","archived":false,"fork":false,"pushed_at":"2017-06-01T20:30:40.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T13:07:06.331Z","etag":null,"topics":["api","django","jwt","jwt-authentication","python","python-3","security"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geolffreym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T15:24:50.000Z","updated_at":"2023-10-20T09:20:48.000Z","dependencies_parsed_at":"2023-03-03T00:45:25.536Z","dependency_job_id":null,"html_url":"https://github.com/geolffreym/jwtAuth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/geolffreym/jwtAuth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geolffreym%2FjwtAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geolffreym%2FjwtAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geolffreym%2FjwtAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geolffreym%2FjwtAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geolffreym","download_url":"https://codeload.github.com/geolffreym/jwtAuth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geolffreym%2FjwtAuth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33125383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"online","status_checked_at":"2026-05-17T02:00:05.366Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","django","jwt","jwt-authentication","python","python-3","security"],"created_at":"2024-10-01T20:21:15.907Z","updated_at":"2026-05-17T02:38:56.538Z","avatar_url":"https://github.com/geolffreym.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Django JWT Middleware\n \n\n*Configuration*\n\nSet your settings in the JWTSettings file\n\nCopy the jwtAuth package to the directory of your project or into a folder for utilities and set the following configuration with the relative directories\n\nThe except_jwt property allows you to bypass jwt checks in some views\nex:\n```\nurl(r'^auth/$', Auth.as_view(), {'except_jwt': True}, name='api_auth'),\n```\n\n\nTo set the active middleware should be added to your setting in django\nex:\n```\nMIDDLEWARE = (\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n    'django.middleware.security.SecurityMiddleware',\n\n    '{my_dir}.jwtAuth.JWTMiddleware.JWTAuthMiddleware'\n\n)\n```\n\n\nAfter this you must use the jwt helper library to authenticate into the system and generate the token that will be used in each request\nex:\n```\nfrom django.contrib.auth.models import User\nfrom django.views.generic import View\nfrom jwtAuth.helpers.jwt import jwt_login\n\nclass Auth(View):\n    \"\"\"\n    The users api auth\n    @return 400: bad request\n    @return 403: forbidden\n    @return 200: Ok\n    \"\"\"\n\n    def post(self, request, *args, **kwargs):\n        \"\"\"\n        Login\n        :param request:\n        :param args:\n        :param kwargs:\n        :return:\n        \"\"\"\n        the_email = request.POST.get('email')\n        the_password = request.POST.get('password')\n\n        # Valid data?\n        if not the_email or not the_password:\n            # Bad request\n            raise Response400(\n                'Invalid password or email'\n            )\n\n        # Try login\n        try:\n            user = User.objects.get(email=the_email)\n            if user.check_password(the_password):\n                # Logged\n                # OK\n                return request.responseOk({\n                    'token': jwt_login(user)\n                })\n\n        except User.DoesNotExist:\n            pass\n\n        # Rejected\n        raise Response403(\n            'Wrong password or email'\n        )\n\n```\n\n\nThe token must be saved to be sent at each request to the system\nThen for each request to the system should be sent the __Bearer__ header\nex:\n```\n{\n    url: _uri,\n    method: 'get',\n    headers: {'Authorization': 'Bearer {token}'}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeolffreym%2Fjwtauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeolffreym%2Fjwtauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeolffreym%2Fjwtauth/lists"}