Skip to content

Commit 4c13c8b

Browse files
authored
Merge pull request #35 from caravancoop/develop
Release v0.9
2 parents 0c1f762 + 2965a13 commit 4c13c8b

18 files changed

+222
-112
lines changed

Diff for: .circleci/config.yml

+35-9
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,43 @@ workflows:
44
version: 2
55
rest-auth-toolkit:
66
jobs:
7+
- test-py37
78
- test-py36
89
- test-py27
910
- check
1011

1112
jobs:
1213

14+
test-py37:
15+
docker:
16+
- image: circleci/python:3.7
17+
working_directory: ~/rest-auth-toolkit
18+
steps:
19+
- checkout
20+
- restore_cache:
21+
key: rest-auth-toolkit-py37-v2
22+
- run:
23+
name: Install CI tools
24+
command: |
25+
python3.7 -m venv venv
26+
venv/bin/pip install tox
27+
- run:
28+
name: Test with Python 3.7
29+
command: venv/bin/tox -e py37
30+
- save_cache:
31+
key: rest-auth-toolkit-py37-v2
32+
paths:
33+
- venv
34+
- .tox
35+
1336
test-py36:
1437
docker:
1538
- image: circleci/python:3.6
1639
working_directory: ~/rest-auth-toolkit
1740
steps:
1841
- checkout
1942
- restore_cache:
20-
key: rest-auth-toolkit-py36-v1
43+
key: rest-auth-toolkit-py36-v2
2144
- run:
2245
name: Install CI tools
2346
command: |
@@ -27,29 +50,32 @@ jobs:
2750
name: Test with Python 3.6
2851
command: venv/bin/tox -e py36
2952
- save_cache:
30-
key: rest-auth-toolkit-py36-v1
53+
key: rest-auth-toolkit-py36-v2
3154
paths:
3255
- venv
3356
- .tox
3457

3558
test-py27:
3659
docker:
37-
- image: circleci/python:2.7
60+
# This image contains Python 3.6 (to install flit) and 2.7 (to run tests)
61+
- image: circleci/python:3.6
3862
working_directory: ~/rest-auth-toolkit
3963
steps:
4064
- checkout
4165
- restore_cache:
42-
key: rest-auth-toolkit-py27-v1
66+
key: rest-auth-toolkit-py27-v2
4367
- run:
4468
name: Install CI tools
4569
command: |
46-
virtualenv -p python2.7 venv
70+
python3.6 -m venv venv
4771
venv/bin/pip install tox
4872
- run:
4973
name: Test with Python 2.7
50-
command: venv/bin/tox -e py27
74+
command: |
75+
venv/bin/tox --sdistonly
76+
venv/bin/tox -e py27
5177
- save_cache:
52-
key: rest-auth-toolkit-py35-v1
78+
key: rest-auth-toolkit-py27-v2
5379
paths:
5480
- venv
5581
- .tox
@@ -61,7 +87,7 @@ jobs:
6187
steps:
6288
- checkout
6389
- restore_cache:
64-
key: rest-auth-toolkit-check-v2
90+
key: rest-auth-toolkit-check-v3
6591
- run:
6692
name: Install CI tools
6793
command: |
@@ -71,7 +97,7 @@ jobs:
7197
name: Check packaging and dependencies
7298
command: venv/bin/tox -e pkg
7399
- save_cache:
74-
key: rest-auth-toolkit-check-v2
100+
key: rest-auth-toolkit-check-v3
75101
paths:
76102
- venv
77103
- .tox

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ __pycache__
66
# Test artifacts
77
/.cache/
88
/.tox/
9+
/venv/
910

1011
# Packaging litter
1112
/*.egg-info

Diff for: MANIFEST.in

-7
This file was deleted.

Diff for: README.md

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
```
2-
__ __ __ __ ____ _ __
3-
________ _____/ /_ ____ ___ __/ /_/ /_ / /_____ ____ / / /__(_) /_
4-
/ ___/ _ \/ ___/ __/ ___/ __ `/ / / / __/ __ \ ___/ __/ __ \/ __ \/ / //_/ / __/
5-
/ / / __(__ ) /_ /__/ /_/ / /_/ / /_/ / / / /__/ /_/ /_/ / /_/ / / ,< / / /_
6-
/_/ \___/____/\__/ \__,_/\__,_/\__/_/ /_/ \__/\____/\____/_/_/|_/_/\__/
2+
__ __ __ __ ____ _ __
3+
________ _____/ /_ ____ ___ __/ /_/ /_ / /_____ ____ / / /__(_) /_
4+
/ ___/ _ \/ ___/ __/ ___/ __ `/ / / / __/ __ \ ___/ __/ __ \/ __ \/ / //_/ / __/
5+
/ / / __(__ ) /_ /__/ /_/ / /_/ / /_/ / / / /__/ /_/ /_/ / /_/ / / ,< / / /_
6+
/_/ \___/____/\__/ \__,_/\__,_/\__/_/ /_/ \__/\____/\____/_/_/|_/_/\__/
77
88
```
99

10-
Mixins and views to handle signup and login in an API built with
11-
django-rest-framework.
10+
This libary provides mixins and views to handle signup, login and
11+
logout in an API built with django-rest-framework. After login,
12+
client applications get a token for the API requests.
13+
14+
Email-based signups are supported out of the box.
15+
Other methods require you to specify an extra in your requirements;
16+
for example, to use Facebook login you need to depend on
17+
`rest-framework-auth-toolkit[facebook]`.
18+
19+
Contrary to other similar modules, rest-auth-toolkit doess not provide
20+
a set of Django apps to include and configure in your settings, but a
21+
collection of mixins, base classes, base views and simple templates
22+
that you can integrate and customize in your own apps.
23+
24+
See the [demo](demo/) app for example usage.
25+
26+
⚠️ This library is not stable yet, make sure to pin your dependencies.
27+
Recommended form: `rest-framework-auth-toolkit == 0.9.*`

Diff for: demo/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Demo application for Rest-Framework-Auth-Toolkit
2+
3+
This is a minimal Django project that shows how to use
4+
the package and helps checking if changes break usage.
5+
6+
## How to install
7+
8+
Run this command once from the repository root:
9+
10+
```
11+
python setup-develop.py develop
12+
```
13+
14+
This makes the package `rest_auth_toolkit` importable by the demo app,
15+
with local changes immediately seen.
16+
17+
Go in the `demo` directory and install the other dependencies:
18+
19+
```
20+
pip install -r requirements.txt
21+
```
22+
23+
# How to run
24+
25+
Define the environment variables needed by the app:
26+
27+
```
28+
export DEMO_FACEBOOK_APP_ID="..."
29+
export DEMO_FACEBOOK_SECRET_KEY="..."
30+
```
31+
32+
(using a [virtualenvwrapper hook](https://virtualenvwrapper.readthedocs.io/en/latest/scripts.html#postactivate)
33+
or a `.env` file with [direnv](https://direnv.net/) is a good ideae to make this automatic)
34+
35+
You can then run Django commands:
36+
37+
```
38+
python manage.py migrate
39+
python manage.py runserver
40+
```
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.0.8 on 2018-09-21 23:51
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('accounts', '0002_auto_20180222_0012'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='user',
15+
name='last_name',
16+
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
17+
),
18+
]

Diff for: demo/demo/urls.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
"""demo URL Configuration."""
22

3-
from django.conf.urls import url, include
3+
from django.urls import include, path
44
from django.contrib import admin
55

66
from rest_auth_toolkit.views import FacebookLoginView, LoginView, LogoutView, SignupView
77

88

99
auth_urlpatterns = [
10-
url(r'^signup/', SignupView.as_view(), name='signup'),
11-
url(r'^login/', LoginView.as_view(), name='login'),
12-
url(r'^logout/', LogoutView.as_view(), name='logout'),
13-
url(r'^fb-login/', FacebookLoginView.as_view(), name='fb-login'),
10+
path('signup/', SignupView.as_view(), name='signup'),
11+
path('login/', LoginView.as_view(), name='login'),
12+
path('logout/', LogoutView.as_view(), name='logout'),
13+
path('fb-login/', FacebookLoginView.as_view(), name='fb-login'),
1414
]
1515

1616
api_urlpatterns = [
17-
url(r'^account/', include('demo.accounts.urls')),
18-
url(r'', include((auth_urlpatterns, 'auth'))),
17+
path('account/', include('demo.accounts.urls')),
18+
path('', include((auth_urlpatterns, 'auth'))),
1919
]
2020

2121
urlpatterns = [
22-
url(r'^admin/', admin.site.urls),
23-
url(r'^api/', include(api_urlpatterns)),
24-
url(r'', include('demo.pages.urls')),
25-
url(r'', include('demo.pages.auth_urls')),
22+
path('admin/', admin.site.urls),
23+
path('api/', include(api_urlpatterns)),
24+
path('', include('demo.pages.urls')),
25+
path('', include('demo.pages.auth_urls')),
2626
]

Diff for: demo/requirements.in

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
pip-tools
22

3-
django ~= 1.11
3+
django == 2.0.*
44
djangorestframework
55
django-debug-toolbar
66

7-
# Note: rest-framework-auth-toolkit is not here, it should already
8-
# be importable if you do pip install -e from your dev virtualenv.
9-
107
django-model-utils
118
django-shortuuidfield
129

10+
# TODO add develop install for rest-framework-auth-toolkit
11+
# (when pip supports PEP 517); see README for how to install rest-auth-toolkit
12+
#-e ..[facebook]
13+
# In the meantime we include facepy here to make sure requirements.txt
14+
# contains all transitive dependencies
15+
facepy
16+
1317
# for the browsable API
1418
markdown
1519
pygments

Diff for: demo/requirements.txt

+13-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
44
#
55
# pip-compile --output-file requirements.txt requirements.in
66
#
7+
certifi==2018.8.24 # via requests
8+
chardet==3.0.4 # via requests
79
click==6.7 # via pip-tools
8-
django-debug-toolbar==1.9.1
9-
django-model-utils==3.1.1
10+
django-debug-toolbar==1.10.1
11+
django-model-utils==3.1.2
1012
django-shortuuidfield==0.1.3
11-
django==1.11.10
12-
djangorestframework==3.7.7
13+
django==2.0.8
14+
djangorestframework==3.8.2
15+
facepy==1.0.9
1316
first==2.0.1 # via pip-tools
17+
idna==2.7 # via requests
1418
markdown==2.6.11
15-
pip-tools==1.11.0
19+
pip-tools==2.0.2
1620
pygments==2.2.0
17-
pytz==2018.3 # via django
21+
pytz==2018.5 # via django
22+
requests==2.19.1 # via facepy
1823
shortuuid==0.5.0 # via django-shortuuidfield
19-
six==1.11.0 # via django-shortuuidfield, pip-tools
24+
six==1.11.0 # via django-shortuuidfield, facepy, pip-tools
2025
sqlparse==0.2.4 # via django-debug-toolbar
26+
urllib3==1.23 # via requests

Diff for: pyproject.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[build-system]
2+
requires = ["flit"]
3+
build-backend = "flit.buildapi"
4+
5+
[tool.flit.metadata]
6+
module = "rest_auth_toolkit"
7+
dist-name = "Rest_Framework_Auth_Toolkit"
8+
author = "Caravan Coop"
9+
author-email = "[email protected]"
10+
home-page = "https://github.com/caravancoop/rest-framework-auth-toolkit"
11+
description-file = "README.md"
12+
classifiers = [
13+
"Development Status :: 3 - Alpha",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: MIT License",
16+
"Programming Language :: Python :: 2.7",
17+
"Programming Language :: Python :: 3.5",
18+
"Programming Language :: Python :: 3.6",
19+
"Programming Language :: Python :: 3.7",
20+
"Framework :: Django :: 1.11",
21+
"Framework :: Django :: 2.0",
22+
"Framework :: Django :: 2.1",
23+
]
24+
requires = [
25+
"django >= 1.11",
26+
]
27+
28+
[tool.flit.metadata.requires-extra]
29+
facebook = ["facepy"]

Diff for: requirements.txt

-16
This file was deleted.

Diff for: rest_auth_toolkit/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
"""Simple + flexible signup and login for Django APIs"""
2+
3+
__version__ = '0.9'
4+
15
default_app_config = 'rest_auth_toolkit.app.RestAuthToolkitConfig'

Diff for: rest_auth_toolkit/serializers.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from rest_framework import serializers
66
from rest_framework.exceptions import ValidationError
77

8-
import facepy
8+
try:
9+
import facepy
10+
except ImportError:
11+
facepy = None
912

1013

1114
User = get_user_model()

Diff for: rest_auth_toolkit/views.py

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from .serializers import FacebookLoginDeserializer, LoginDeserializer, SignupDeserializer
1212
from .utils import get_object_from_setting, get_setting, MissingSetting
1313

14+
try:
15+
import facepy
16+
except ImportError:
17+
facepy = None
18+
1419

1520
User = get_user_model()
1621
Token = get_object_from_setting('api_token_class')
@@ -93,6 +98,16 @@ class FacebookLoginView(generics.GenericAPIView):
9398
serializer_class = get_object_from_setting('facebook_login_serializer_class',
9499
FacebookLoginDeserializer)
95100

101+
@classmethod
102+
def as_view(cls, *args, **kwargs):
103+
if facepy is None:
104+
raise TypeError('install rest-framework-auth-toolkit[facebook] '
105+
'to enable Facebook logins')
106+
107+
# TODO error if settings are missing
108+
109+
return super(FacebookLoginView, cls).as_view(*args, **kwargs)
110+
96111
def post(self, request):
97112
deserializer = self.get_serializer(data=request.data)
98113
deserializer.is_valid(raise_exception=True)

0 commit comments

Comments
 (0)