Skip to content

Commit 5f5f09a

Browse files
author
Dylan Stein
committed
update required deps; update readme to markdown
1 parent 2c27ea7 commit 5f5f09a

File tree

3 files changed

+96
-72
lines changed

3 files changed

+96
-72
lines changed

Pipfile

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
Django = "*"
8-
djangorestframework = "*"
97
twilio = "*"
108

119
[dev-packages]

README.md

+95-63
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
.. image:: https://travis-ci.org/aaronn/django-rest-framework-passwordless.svg?branch=master
2-
:target: https://travis-ci.org/aaronn/django-rest-framework-passwordless
3-
1+
![ci-image]
42

53
drfpasswordless is a quick way to integrate ‘passwordless’ auth into
64
your Django Rest Framework project using a user’s email address or
@@ -17,77 +15,79 @@ Callback tokens by default expire after 15 minutes.
1715
Example Usage:
1816
==============
1917

20-
::
21-
18+
```bash
2219
curl -X POST -d “email=aaron@email.com” localhost:8000/auth/email/
20+
```
2321

2422
Email to aaron@email.com:
2523

26-
::
27-
28-
24+
```
25+
...
2926
<h1>Your login token is 815381.</h1>
30-
27+
...
28+
```
3129

3230
Return Stage
3331

34-
::
35-
32+
```bash
3633
curl -X POST -d "token=815381" localhost:8000/callback/auth/
3734

3835
> HTTP/1.0 200 OK
3936
> {"token":"76be2d9ecfaf5fa4226d722bzdd8a4fff207ed0e”}
37+
```
4038
4139
Requirements
4240
============
4341
44-
::
45-
46-
- Python (2.7, 3.4, 3.5, 3.6+)
47-
- Django (1.8, 1.9, 1.10, 1.11+)
48-
- Django Rest Framework + AuthToken (3.4, 3.5, 3.6+)
49-
- Python-Twilio (Optional, for mobile.)
50-
42+
```
43+
- Python (3.6+)
44+
- Django (2.0+)
45+
- Django Rest Framework + AuthToken (3.6+)
46+
- Python-Twilio (Optional, for mobile.)
47+
```
5148
5249
Install
5350
=======
5451
5552
1. Install drfpasswordless
5653
57-
::
58-
59-
pip install drfpasswordless
60-
61-
54+
```
55+
pipenv install drfpasswordless
56+
```
57+
6258
2. Add Django Rest Framework’s Token Authentication to your Django Rest
6359
Framework project.
6460
65-
::
66-
61+
```python
6762
REST_FRAMEWORK = {
6863
'DEFAULT_AUTHENTICATION_CLASSES':
6964
('rest_framework.authentication.TokenAuthentication',
7065
)}
7166
7267
INSTALLED_APPS = [
73-
// …
68+
...
7469
'rest_framework',
7570
'rest_framework.authtoken',
7671
'drfpasswordless',
72+
...
7773
]
74+
```
7875
79-
And run ``manage.py migrate``.
76+
And run
77+
```bash
78+
python manage.py migrate
79+
```
8080
8181
3. Set which types of contact points are allowed for auth in your
8282
Settings.py. The available options are ``EMAIL`` and ``MOBILE``.
8383
84-
::
85-
86-
PASSWORDLESS_AUTH = {
87-
//…
88-
‘PASSWORDLESS_AUTH_TYPES’: [‘EMAIL’, ‘MOBILE’],
89-
//…
90-
}
84+
```python
85+
PASSWORDLESS_AUTH = {
86+
..
87+
'PASSWORDLESS_AUTH_TYPES': ['EMAIL', 'MOBILE'],
88+
..
89+
}
90+
```
9191
9292
By default drfpasswordless looks for fields named ``email`` or ``mobile``
9393
on the User model. If an alias provided doesn’t belong to any given user,
@@ -101,36 +101,37 @@ Install
101101
102102
4. Add ``drfpasswordless.urls`` to your urls.py
103103
104-
::
105-
104+
```python
106105
urlpatterns = [
107-
//..
108-
url(r'^', include('drfpasswordless.urls')),
109-
//..
106+
..
107+
path('', include('drfpasswordless.urls')),
108+
..
110109
]
111-
110+
```
112111
113112
5. You can now POST to either of the endpoints:
114113
115-
::
114+
```bash
116115
117-
curl -X POST -d "email=aaron@email.com" localhost:8000/auth/email/
116+
curl -X POST -d "email=aaron@email.com" localhost:8000/auth/email/
118117
119-
curl -X POST -d "mobile=+15552143912" localhost:8000/mobile/
118+
// OR
120119
120+
curl -X POST -d "mobile=+15552143912" localhost:8000/mobile/
121+
```
121122
A 6 digit callback token will be sent to the contact point.
122123
123124
6. The client has 15 minutes to use the 6 digit callback token
124125
correctly. If successful, they get an authorization token in exchange
125126
which the client can then use with Django Rest Framework’s
126127
TokenAuthentication scheme.
127128
128-
::
129+
```bash
130+
curl -X POST -d "token=815381" localhost:8000/callback/auth/
129131
130-
curl -X POST -d "token=815381" localhost:8000/callback/auth/
131-
132-
> HTTP/1.0 200 OK
133-
> {"token":"76be2d9ecfaf5fa4226d722bzdd8a4fff207ed0e”}
132+
> HTTP/1.0 200 OK
133+
> {"token":"76be2d9ecfaf5fa4226d722bzdd8a4fff207ed0e”}
134+
```
134135
135136
Configuring Emails
136137
------------------
@@ -144,27 +145,27 @@ development you can set up a dummy development smtp server to test
144145
emails. Sent emails will print to the console. `Read more
145146
here. <https://docs.djangoproject.com/en/1.10/topics/email/#configuring-email-for-development>`__
146147
147-
::
148-
148+
```python
149149
# Settings.py
150150
151151
EMAIL_HOST = 'localhost'
152152
EMAIL_PORT = 1025
153+
```
153154
154155
Then run the following:
155156
156-
::
157-
157+
```bash
158158
python -m smtpd -n -c DebuggingServer localhost:1025
159+
```
159160
160161
Configuring Mobile
161162
------------------
162163
163164
You’ll need to have the python twilio module installed
164165
165-
::
166-
167-
pip install twilio
166+
```bash
167+
pipenv install twilio
168+
```
168169
169170
and set the ``TWILIO_ACCOUNT_SID`` and ``TWILIO_AUTH_TOKEN`` environment
170171
variables.
@@ -178,12 +179,12 @@ Templates
178179
If you’d like to use a custom email template for your email callback
179180
token, specify your template name with this setting:
180181
181-
::
182-
182+
```bash
183183
PASSWORDLESS_AUTH = {
184-
//…
185-
'PASSWORDLESS_EMAIL_TOKEN_HTML_TEMPLATE_NAME': "mytemplate.html"
184+
...
185+
'PASSWORDLESS_EMAIL_TOKEN_HTML_TEMPLATE_NAME': "mytemplate.html"
186186
}
187+
```
187188
188189
The template renders a single variable ``{{ callback_token }}`` which is
189190
the 6 digit callback token being sent.
@@ -225,8 +226,7 @@ Other Settings
225226
226227
Here’s a full list of the configurable defaults.
227228
228-
::
229-
229+
```python
230230
DEFAULTS = {
231231
232232
# Allowed auth types, can be EMAIL, MOBILE, or both.
@@ -293,10 +293,42 @@ Here’s a full list of the configurable defaults.
293293
# Automatically send verification email or sms when a user changes their alias.
294294
'PASSWORDLESS_AUTO_SEND_VERIFICATION_TOKEN': False,
295295
}
296+
```
296297
297-
Todo
298+
To Do
298299
----
299300
301+
- github.io project page
302+
- Add MkDocs - http://www.mkdocs.org/
300303
- Support non-US mobile numbers
301304
- Custom URLs
302-
- Change bad settings to 500's
305+
- Change bad settings to 500's
306+
307+
Pull requests are encouraged!
308+
309+
License
310+
-------
311+
312+
The MIT License (MIT)
313+
314+
Copyright (c) 2017 Aaron Ng
315+
316+
Permission is hereby granted, free of charge, to any person obtaining a copy
317+
of this software and associated documentation files (the "Software"), to deal
318+
in the Software without restriction, including without limitation the rights
319+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
320+
copies of the Software, and to permit persons to whom the Software is
321+
furnished to do so, subject to the following conditions:
322+
323+
The above copyright notice and this permission notice shall be included in all
324+
copies or substantial portions of the Software.
325+
326+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
327+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
328+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
329+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
330+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
331+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
332+
SOFTWARE.
333+
334+
[ci-image]: https://travis-ci.org/aaronn/django-rest-framework-passwordless.svg?branch=master

setup.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# What packages are required for this module to be executed?
2828
REQUIRED = [
29-
# 'requests', 'maya', 'records',
29+
'Django', 'djangorestframework'
3030
]
3131

3232
# The rest you shouldn't have to touch too much :)
@@ -98,12 +98,6 @@ def run(self):
9898
python_requires=REQUIRES_PYTHON,
9999
url=URL,
100100
packages=find_packages(exclude=('tests',)),
101-
# If your package is a single module, use this instead of 'packages':
102-
# py_modules=['mypackage'],
103-
104-
# entry_points={
105-
# 'console_scripts': ['mycli=mymodule:cli'],
106-
# },
107101
install_requires=REQUIRED,
108102
include_package_data=True,
109103
license='MIT',

0 commit comments

Comments
 (0)