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

Rate Limiting #595

Open
wants to merge 156 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
596cbee
add DRF throttle scopes to relevant rest auth views
steverecio Jan 10, 2020
10eb4be
dont delete auth token on logout
steverecio Feb 10, 2020
92cc9c1
Renames project to dj-rest-auth
iMerica Feb 29, 2020
f7da276
Updates names
iMerica Mar 1, 2020
0824974
Adds circle CI
iMerica Mar 1, 2020
2e5df3b
Fixes Circle location
iMerica Mar 1, 2020
5c50d0c
Fixes YAML schema
iMerica Mar 1, 2020
0797ce2
Remove cache
iMerica Mar 1, 2020
03925f4
Removes echo flag
iMerica Mar 1, 2020
5faeda0
Updates yaml
iMerica Mar 1, 2020
a7025c1
Runs tests
iMerica Mar 1, 2020
b2300a4
Fixes test command
iMerica Mar 1, 2020
41dce88
Fixes tests
iMerica Mar 1, 2020
331094b
Fixes Imports
iMerica Mar 1, 2020
6ece00f
Adds Docker runtime
iMerica Mar 1, 2020
c43965b
Removes Orb
iMerica Mar 1, 2020
8e7982e
Uses Docker Orb
iMerica Mar 1, 2020
12883f8
Uses Docker Executor
iMerica Mar 1, 2020
3402d1f
Uses pip install with user
iMerica Mar 1, 2020
a87a458
Removes six
iMerica Mar 1, 2020
7331e63
Fixes min reqs
iMerica Mar 1, 2020
4c3a121
WIP
iMerica Mar 1, 2020
cd2328c
WIP
iMerica Mar 1, 2020
3e89a8d
Adds dev reqs
iMerica Mar 1, 2020
60c1a4a
Adds more tests coverage
iMerica Mar 1, 2020
60cdae1
Runs 1.11 tests
iMerica Mar 1, 2020
c99caac
Adds tests
iMerica Mar 1, 2020
a757eea
Install tests reqs
iMerica Mar 1, 2020
cb1e2b6
Bumps Django
iMerica Mar 1, 2020
93ed2a1
DRY's up config
iMerica Mar 1, 2020
6b27267
Updates Django version
iMerica Mar 1, 2020
455b88e
Removes Django 11
iMerica Mar 1, 2020
a639fc6
Fixes broken tests
iMerica Mar 1, 2020
39fbc15
Adds README badge
iMerica Mar 1, 2020
7f17e18
Updates badge URL
iMerica Mar 1, 2020
aafd10f
Updates README
iMerica Mar 1, 2020
8b3915e
Fixes README
iMerica Mar 1, 2020
7d63b53
Updats README
iMerica Mar 1, 2020
9298014
Fixes docs
iMerica Mar 1, 2020
25d0ebb
Specifies Python version
iMerica Mar 1, 2020
34d5706
Updates README
iMerica Mar 1, 2020
60e0ca4
Updates Docs
iMerica Mar 1, 2020
9b78f0e
Updates change log
iMerica Mar 1, 2020
8bc9ba8
Fixes references to serializers + isort
iMerica Mar 1, 2020
38945e8
Updates README
iMerica Mar 1, 2020
3c30c39
Corrects grammar
iMerica Mar 1, 2020
d90e3db
Uses new org
iMerica Mar 1, 2020
238b92b
Updates Circle CI badge
iMerica Mar 1, 2020
c35773d
Adds Jazzband badge
iMerica Mar 6, 2020
b5914db
Adds contributing file
iMerica Mar 6, 2020
fe01ba0
Adds coverage badge
iMerica Mar 6, 2020
3b83079
Adds coveralls dep and tests
iMerica Mar 7, 2020
a4915a1
Adds coverage repo token
iMerica Mar 7, 2020
229b755
Updates version in demo project
iMerica Mar 11, 2020
9bbc4a3
change standard auth stuff to work with simplejwt
alichass Mar 11, 2020
4fb746e
updated tests
alichass Mar 11, 2020
23e88f9
update registration views to work with simplejwt
alichass Mar 11, 2020
231ccc0
updated docs
alichass Mar 11, 2020
6dd2aea
Update setup.py
alichass Mar 11, 2020
e198f8d
Fix if condition in LoginSerializer
MathiasLantean Mar 11, 2020
6460348
Merge pull request #5 from MathiasLantean/Fix_LoginSerializer
iMerica Mar 11, 2020
597d17e
Uncomment 'django.contrib.messages'
mohmyo Mar 12, 2020
654eb22
Fix AttributeError at /docs/
mohmyo Mar 12, 2020
344a529
Merge pull request #8 from mohmyo/patch-2
iMerica Mar 13, 2020
3017853
Merge pull request #7 from mohmyo/patch-1
iMerica Mar 13, 2020
12e79aa
changed for use w/ cookies
alichass Mar 19, 2020
f73f3af
hopefully this should work?
alichass Mar 19, 2020
dbb3ff2
Fix typos in the registration serializer documentation
dedsm Mar 21, 2020
50b7a4a
Merge pull request #11 from dedsm/patch-1
iMerica Mar 22, 2020
475e0b9
Support for Http-Only JWT Cookies
iMerica Mar 22, 2020
ce3b90d
Re-adds previous tests
iMerica Mar 22, 2020
4070bce
Attempts to fix tests
iMerica Mar 22, 2020
2781593
Bumps minor version
iMerica Mar 22, 2020
bfd6750
Removes coveralls patch edit
iMerica Mar 22, 2020
2722622
Merge pull request #3 from alichass/master
iMerica Mar 22, 2020
fe06053
Adds JWT example to Readme
iMerica Mar 22, 2020
1eaa8ed
README tweak
iMerica Mar 22, 2020
c933513
Bumps version, fixes import ordering
iMerica Mar 28, 2020
9d24b4f
Updates docs and demo
iMerica Mar 28, 2020
ff7d972
Use master in demo
iMerica Mar 28, 2020
ac3cbcb
Adds React SPA
iMerica Mar 28, 2020
a7f5499
Adds POC Login Form in React
iMerica Mar 28, 2020
c4130d1
Adds more help to docs
iMerica Mar 28, 2020
66beda5
Updates changelog
iMerica Mar 28, 2020
c05903b
Adds note about React SPA
iMerica Mar 28, 2020
53ca547
Updates RST Docs
iMerica Mar 28, 2020
68dbdf7
Fixes docs code sample
iMerica Mar 28, 2020
de25807
Note in docs to add allauth urls if account email verification is man…
anuj9196 Mar 30, 2020
3c89660
Update module name
anuj9196 Mar 31, 2020
d9996a7
Merge pull request #20 from anuj9196/master
iMerica Mar 31, 2020
1c485bc
Update documentation
anuj9196 Mar 31, 2020
26b6e22
blacklist refresh token on logout if REST_USE_JWT and added .idea to …
mjlabe Apr 1, 2020
241011a
attempt to blacklist token if no JWT_AUTH_COOKIE is found
mjlabe Apr 1, 2020
9180f39
Revert "Update documentation"
iMerica Apr 1, 2020
f2a5078
Merge pull request #29 from jazzband/revert-24-patch-1
iMerica Apr 1, 2020
aaab91f
updated exceptions to raise error if not not handled
mjlabe Apr 2, 2020
8f97cbc
added rest_framework_simplejwt.token_blacklist to settings for tests,…
mjlabe Apr 2, 2020
8b284f8
fixed typo in 500 response
mjlabe Apr 2, 2020
3304a6b
Fix JWTSerializer USER_DETAILS_SERIALIZER import
altjohndev Apr 3, 2020
497d88c
Merge pull request #32 from altjohndev/master
iMerica Apr 4, 2020
058df2b
Bumps version
iMerica Apr 7, 2020
b55fcc2
deleted make file and adding testing section to README
mjlabe Apr 8, 2020
d5d9c69
check if blacklist is installed and warn user to delete client side i…
mjlabe Apr 10, 2020
91c052f
changed invalid or expired and blacklisted errors to 401
mjlabe Apr 10, 2020
1c64c0d
changed spacing for better readability
mjlabe Apr 10, 2020
275d1c4
Merge pull request #28 from mjlabe/logout-blacklist-jwt-token
iMerica Apr 10, 2020
40125b1
Bumps version for release
iMerica Apr 14, 2020
40208ea
Don't _require_ rest_framework_simplejwt
necaris Apr 14, 2020
506912f
Move import inside response method
necaris Apr 14, 2020
8583c55
Add token endpoints from rest_framework_simplejwt to url config
VolkerSchiewe Apr 15, 2020
5e8cca1
Use import_string for getting TokenModel instead of passing class
SerhiyRomanov Apr 15, 2020
d882edc
Update dj_rest_auth/urls.py
iMerica Apr 16, 2020
17e9230
Update dj_rest_auth/urls.py
iMerica Apr 16, 2020
d53c447
Merge pull request #41 from SerhiyRomanov/fix_REST_AUTH_TOKEN_MODEL
iMerica Apr 16, 2020
3f61d48
Merge pull request #38 from necaris/fix/import-of-simplejwt
iMerica Apr 16, 2020
a190e03
Bug fixes related to Simple JWT integrations
iMerica Apr 16, 2020
4dcca58
changed url to path
Apr 16, 2020
3b7b607
Merge pull request #43 from Pinzauti/url-to-path
iMerica Apr 17, 2020
5d2e83c
Merge pull request #39 from VolkerSchiewe/master
iMerica Apr 17, 2020
64e07ec
Fix missed import_callable
SerhiyRomanov Apr 17, 2020
9e04918
Merge pull request #46 from SerhiyRomanov/fix_missed_import_callable
iMerica Apr 18, 2020
4a46807
Bumps version
iMerica Apr 18, 2020
2602d66
Pass context to JWTSerializer and TokenSerializer
githubuser88442 Apr 21, 2020
a2b8c9c
Merge pull request #52 from ranetpgit/master
iMerica Apr 22, 2020
23bef47
Compile pt_BR language messages
rafaelzl Apr 26, 2020
e73dad7
Merge pull request #55 from rafaelzl/master
iMerica Apr 27, 2020
7b1bfec
added italian language
May 7, 2020
3b0e95c
Compile italian language
May 7, 2020
a3955bc
Merge pull request #59 from Pinzauti/italian_language
iMerica May 8, 2020
bffec48
Adds centralized version store
iMerica May 9, 2020
b3758c9
Added swedish (sv) translations
lideen May 10, 2020
5f137da
make token validation in PasswordResetConfirmSerializer is the first …
mohmyo May 10, 2020
1dd2019
Merge pull request #64 from mohmyo/master
iMerica May 11, 2020
0be5b2d
Fixes no-user issue
iMerica May 12, 2020
a63a13e
Merge pull request #66 from jazzband/fixes-no-user
iMerica May 12, 2020
0bc943f
Adds a tox.ini file and instructions in the readme for how to use it.
robdox May 16, 2020
2a43288
Merge pull request #69 from robdox/master
iMerica May 16, 2020
860c350
Fixes the Circle CI Link
iMerica May 16, 2020
2a6fb3a
serializers: import gettext_lazy; fixes #70
seanfarley May 20, 2020
02c9242
Merge pull request #72 from seanfarley/smf/django3-warnings
iMerica May 23, 2020
1fe4ba7
Updated PasswordResetConfirmSerializer docstring
mohmyo May 27, 2020
9a75a15
docs: Update registration install command for zsh
erdaltsksn May 30, 2020
6e77382
Merge pull request #74 from erdaltsksn/docs/updateinstallcmd
iMerica May 30, 2020
dfec75e
Merge pull request #73 from mohmyo/patch-1
iMerica May 30, 2020
202b5e8
Adds vulnerability disclosure
iMerica May 30, 2020
c18ccf5
Improves link in docs
iMerica May 30, 2020
24413e4
Removes changelog. Refer to Github instead
iMerica May 30, 2020
3ac4251
Added ukrainian locale
null-none May 30, 2020
13a241f
Updates index
iMerica May 30, 2020
099e61e
Removes reference tot changelog
iMerica May 30, 2020
62e291b
Fixes docs
iMerica May 30, 2020
c1e15d8
Merge pull request #78 from null-none/master
iMerica May 30, 2020
073ea55
Bumps to 1.0.6
iMerica May 30, 2020
c5d553d
Merge pull request #79 from lideen/master
iMerica May 30, 2020
c03558b
fix merge issue
steverecio Jun 3, 2020
2daa44e
change throttle scope naming (rest_auth -> dj_rest_auth)
steverecio Jun 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 2.1
orbs:
docker: circleci/[email protected]

jobs:
test-django-3: &template
docker:
- image: circleci/python:3.8.0
environment:
DJANGO_VERSION: 3.0.3
DRF: 3.11
executor: docker/docker
steps:
- checkout
- run: pip install --user -r dev-requirements.txt
- run: pip install --user -r dj_rest_auth/tests/requirements.pip
- run: pip install -q --user coveralls djangorestframework==$DRF Django==$DJANGO_VERSION
- run:
command: coverage run --source=dj_rest_auth setup.py test
name: Test
- run:
command: COVERALLS_REPO_TOKEN=Q58WdUuZOi89XHyDeDsGE2lxUGQ2IfqP3 coveralls
name: Coverage
test-django-2:
<<: *template
environment:
DJANGO_VERSION: 2.2.10
DRF: 3.9

workflows:
main:
jobs:
- test-django-3
- test-django-2
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: Q58WdUuZOi89XHyDeDsGE2lxUGQ2IfqP3
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# IDE
.idea

# pyenv
.python-version

Expand Down Expand Up @@ -102,3 +105,5 @@ venv.bak/

# mypy
.mypy_cache/
demo/react-spa/node_modules/
demo/react-spa/yarn.lock
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
http://github.com/Tivix/django-rest-auth/contributors
http://github.com/jazzband/dj-rest-auth/contributors
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[![Jazzband](https://jazzband.co/static/img/jazzband.svg)](https://jazzband.co/)

This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct) and follow the [guidelines](https://jazzband.co/about/guidelines).
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Tivix
Copyright (c) 2014 iMerica https://github.com/iMerica/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include AUTHORS
include LICENSE
include MANIFEST.in
include README.md
graft rest_auth
graft dj_rest_auth
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Dj-Rest-Auth
[![<iMerica>](https://circleci.com/gh/jazzband/dj-rest-auth.svg?style=svg)](https://app.circleci.com/pipelines/github/jazzband/dj-rest-auth)
[![Jazzband](https://jazzband.co/static/img/badge.svg)](https://jazzband.co/)
[![Coverage Status](https://coveralls.io/repos/github/jazzband/dj-rest-auth/badge.svg?branch=master)](https://coveralls.io/github/jazzband/dj-rest-auth?branch=master)

Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well
with SPAs (e.g React, Vue, Angular), and Mobile applications.

## Requirements
- Django 2 or 3.
- Python 3

## Quick Setup

Install package

pip install dj-rest-auth

Add `dj_rest_auth` app to INSTALLED_APPS in your django settings.py:

```python
INSTALLED_APPS = (
...,
'rest_framework',
'rest_framework.authtoken',
...,
'dj_rest_auth'
)
```

Add URL patterns

```python
urlpatterns = [
url(r'^dj-rest-auth/', include('dj_rest_auth.urls'))
]
```


(Optional) Use Http-Only cookies

```python
REST_USE_JWT = True
JWT_AUTH_COOKIE = 'jwt-auth'
```

### Testing

To run the tests within a virtualenv, run `python runtests.py` from the repository directory.
The easiest way to run test coverage is with [`coverage`](https://pypi.org/project/coverage/),
which runs the tests against all supported Django installs. To run the test coverage
within a virtualenv, run `coverage run ./runtests.py` from the repository directory then run `coverage report`.

#### Tox

Testing may also be done using [`tox`](https://pypi.org/project/tox/), which
will run the tests against all supported combinations of python and django.

Install tox, either globally or within a virtualenv, and then simply run `tox`
from the repository directory. As there are many combinations, you may run them
in [`parallel`](https://tox.readthedocs.io/en/latest/config.html#cmdoption-tox-p)
using `tox --parallel`.

The `tox.ini` includes an environment for testing code [`coverage`](https://pypi.org/project/coverage/)
and you can run it and view this report with `tox -e coverage`.

Linting may also be performed via [`flake8`](https://pypi.org/project/flake8/)
by running `tox -e flake8`.

### Documentation

View the full documentation here: https://dj-rest-auth.readthedocs.io/en/latest/index.html


### Acknowledgements

This project began as a fork of `django-rest-auth`. Big thanks to everyone who contributed to that repo!
31 changes: 0 additions & 31 deletions README.rst

This file was deleted.

21 changes: 15 additions & 6 deletions demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
# 'django.contrib.messages',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

'rest_framework',
'rest_framework.authtoken',
'rest_auth',

'dj_rest_auth',
'allauth',
'allauth.account',
'rest_auth.registration',
'dj_rest_auth.registration',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'rest_framework_swagger',
'corsheaders'
)

MIDDLEWARE = (
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -116,14 +116,23 @@
ACCOUNT_AUTHENTICATION_METHOD = 'username'
ACCOUNT_EMAIL_VERIFICATION = 'optional'

REST_USE_JWT = True
JWT_AUTH_COOKIE = 'auth'

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
)
'dj_rest_auth.utils.JWTCookieAuthentication'
),
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}

SWAGGER_SETTINGS = {
'LOGIN_URL': 'login',
'LOGOUT_URL': 'logout',
}


# For demo purposes only. Use a white list in the real world.
CORS_ORIGIN_ALLOW_ALL = True
7 changes: 3 additions & 4 deletions demo/demo/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView, RedirectView

from django.views.generic import RedirectView, TemplateView
from rest_framework_swagger.views import get_swagger_view

urlpatterns = [
Expand Down Expand Up @@ -35,8 +34,8 @@
TemplateView.as_view(template_name="password_reset_confirm.html"),
name='password_reset_confirm'),

url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(r'^dj-rest-auth/', include('dj_rest_auth.urls')),
url(r'^dj-rest-auth/registration/', include('dj_rest_auth.registration.urls')),
url(r'^account/', include('allauth.urls')),
url(r'^admin/', admin.site.urls),
url(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=True), name='profile-redirect'),
Expand Down
4 changes: 3 additions & 1 deletion demo/demo/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")

application = get_wsgi_application()
23 changes: 23 additions & 0 deletions demo/react-spa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*