/usr/lib/python2.7/dist-packages/djoser-0.4.0.egg-info/PKG-INFO is in python-djoser 0.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | Metadata-Version: 1.1
Name: djoser
Version: 0.4.0
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
Author-email: info@sunscrapers.com
License: MIT
Description: # djoser
[![Build Status](https://travis-ci.org/sunscrapers/djoser.svg?branch=master)](https://travis-ci.org/sunscrapers/djoser)
[![Coverage Status](https://coveralls.io/repos/sunscrapers/djoser/badge.png?branch=master)](https://coveralls.io/r/sunscrapers/djoser?branch=master)
REST implementation of [Django](https://www.djangoproject.com/) authentication
system. **Djoser** library provides a set of [Django Rest Framework](http://www.django-rest-framework.org/)
views to handle basic actions such as registration, login, logout, password
reset and account activation. It works with [custom user model](https://docs.djangoproject.com/en/dev/topics/auth/customizing/).
Instead of reusing Django code (e.g. `PasswordResetForm`), we reimplemented
few things to fit better into [Single Page App](http://en.wikipedia.org/wiki/Single-page_application)
architecture.
Developed by [SUNSCRAPERS](http://sunscrapers.com/) with passion & patience.
## Features
Here is a list of supported authentication backends:
* [HTTP Basic Auth](http://www.django-rest-framework.org/api-guide/authentication/#basicauthentication) (Default)
* [Token based authentication from Django Rest Framework](http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication)
Available endpoints:
* `/me/`
* `/register/`
* `/login/`
* `/logout/`
* `/activate/`
* `/{{ User.USERNAME_FIELD }}/`
* `/password/`
* `/password/reset/`
* `/password/reset/confirm/`
Supported Python versions:
* Python 2.6
* Python 2.7
* Python 3.4
Supported Django versions:
* Django 1.5
* Django 1.6
* Django 1.7
* Django 1.8
Supported Django Rest Framework versions:
* Django Rest Framework 3.x
For Django Rest Framework 2.4 support check [djoser 0.3.2](https://github.com/sunscrapers/djoser/tree/0.3.2).
## Installation
Use `pip`:
$ pip install djoser
## Quick Start
Configure `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
'django.contrib.auth',
(...),
'rest_framework',
'djoser',
(...),
)
```
Configure `urls.py`:
```python
urlpatterns = patterns('',
(...),
url(r'^auth/', include('djoser.urls')),
)
```
HTTP Basic Auth strategy is assumed by default as Django Rest Framework does it. However you may want to set it
explicitly:
```python
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
),
}
```
Run migrations (if you are using Django 1.7+ or South) - this step will create tables for `auth` app:
$ ./manage.py migrate
## Customizing authentication backend
### Token Based Authentication
Add `'rest_framework.authtoken'` to `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
'django.contrib.auth',
(...),
'rest_framework',
'rest_framework.authtoken',
'djoser',
(...),
)
```
Configure `urls.py`. Pay attention to `djoser.url.authtoken` module path.
```python
urlpatterns = patterns('',
(...),
url(r'^auth/', include('djoser.urls.authtoken')),
)
```
Set `TokenAuthentication` as default Django Rest Framework authentication strategy:
```python
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
}
```
Run migrations (if you are using Django 1.7+ or South) - this step will create tables for `auth` and `authtoken` apps:
$ ./manage.py migrate
## Settings
Optionally add `DJOSER` settings:
```python
DJOSER = {
'DOMAIN': 'frontend.com',
'SITE_NAME': 'Frontend',
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': True,
}
```
Check "Settings" section for more info.
## Endpoints
### User
Use this endpoint to retrieve/update user.
#### `GET`
URL: `/me/`
Retrieve user.
* **response**
* status: `HTTP_200_OK` (success)
* data:
`{{ User.USERNAME_FIELD }}`
`{{ User._meta.pk.name }}`
`{{ User.REQUIRED_FIELDS }}`
#### `PUT`
URL: `/me/`
Update user.
* **request**
* data:
`{{ User.REQUIRED_FIELDS }}`
* **response**
* status: `HTTP_200_OK` (success)
* data:
`{{ User.USERNAME_FIELD }}`
`{{ User._meta.pk.name }}`
`{{ User.REQUIRED_FIELDS }}`
### Register
Use this endpoint to register new user. Your user model manager should
implement [create_user](https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.UserManager.create_user)
method and have [USERNAME_FIELD](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD)
and [REQUIRED_FIELDS](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS)
fields.
#### `POST`
URL: `/register/`
* **request**
* data:
`{{ User.USERNAME_FIELD }}`
`{{ User.REQUIRED_FIELDS }}`
`password`
* **response**
* status: `HTTP_201_CREATED` (success)
* data:
`{{ User.USERNAME_FIELD }}`
`{{ User._meta.pk.name }}`
`{{ User.REQUIRED_FIELDS }}`
### Login
Use this endpoint to obtain user [authentication token](http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication).
#### `POST`
URL: `/login/`
* **request**
* data:
`{{ User.USERNAME_FIELD }}`
`password`
* **response**
* status: `HTTP_200_OK` (success)
* data:
`auth_token`
### Logout
Use this endpoint to logout user (remove user authentication token).
#### `POST`
URL: `/logout/`
* **response**
* status: `HTTP_200_OK` (success)
### Activate
Use this endpoint to activate user account. This endpoint is not a URL which
will be directly exposed to your users - you should provide site in your
frontend application (configured by `ACTIVATION_URL`) which will send `POST`
request to activate endpoint.
#### `POST`
URL: `/activate/`
* **request**
* data:
`uid`
`token`
* **response**
* status: `HTTP_200_OK` (success)
### Set username
Use this endpoint to change user username (`USERNAME_FIELD`).
#### `POST`
URL: `/{{ User.USERNAME_FIELD }}/`
* **request**
* data:
`new_{{ User.USERNAME_FIELD }}`
`re_new_{{ User.USERNAME_FIELD }}` (if `SET_USERNAME_RETYPE` is `True`)
`current_password`
* **response**
* status: `HTTP_200_OK` (success)
### Set password
Use this endpoint to change user password.
#### `POST`
URL: `/password/`
* **request**
* data:
`new_password`
`re_new_password` (if `SET_PASSWORD_RETYPE` is `True`)
`current_password`
* **response**
* status: `HTTP_200_OK` (success)
### Reset password
Use this endpoint to send email to user with password reset link. You have to
setup `PASSWORD_RESET_CONFIRM_URL`.
#### `POST`
URL: `/password/reset/`
* **request**
* data:
`email`
* **response**
* status: `HTTP_200_OK` (success)
### Reset password confirmation
Use this endpoint to finish reset password process. This endpoint is not a URL
which will be directly exposed to your users - you should provide site in your
frontend application (configured by `PASSWORD_RESET_CONFIRM_URL`) which
will send `POST` request to reset password confirmation endpoint.
#### `POST`
URL: `/password/reset/confirm/`
* **request**
* data:
`uid`
`token`
`new_password`
`re_new_password` (if `PASSWORD_RESET_CONFIRM_RETYPE` is `True`)
* **response**
* status: `HTTP_200_OK` (success)
## Settings
### DOMAIN
Domain of your frontend app. If not provided, domain of current site will be
used.
**Required**: `False`
### SITE_NAME
Name of your frontend app. If not provided, name of current site will be
used.
**Required**: `False`
### PASSWORD_RESET_CONFIRM_URL
URL to your frontend password reset page. It should contain `{uid}` and
`{token}` placeholders, e.g. `#/password-reset/{uid}/{token}`. You should pass
`uid` and `token` to reset password confirmation endpoint.
**Required**: `True`
### SEND_ACTIVATION_EMAIL
If `True`, register endpoint will send activation email to user.
**Default**: `False`
### ACTIVATION_URL
URL to your frontend activation page. It should contain `{uid}` and `{token}`
placeholders, e.g. `#/activate/{uid}/{token}`. You should pass `uid` and
`token` to activation endpoint.
**Required**: `True`
### SET_USERNAME_RETYPE
If `True`, you need to pass `re_new_{{ User.USERNAME_FIELD }}` to
`/{{ User.USERNAME_FIELD }}/` endpoint, to validate username equality.
**Default**: `False`
### SET_PASSWORD_RETYPE
If `True`, you need to pass `re_new_password` to `/password/` endpoint, to
validate password equality.
**Default**: `False`
### PASSWORD_RESET_CONFIRM_RETYPE
If `True`, you need to pass `re_new_password` to `/password/reset/confirm/`
endpoint in order to validate password equality.
**Default**: `False`
## Emails
There are few email templates which you may want to override:
* `activation_email_body.txt`
* `activation_email_subject.txt`
* `password_reset_email_body.txt`
* `password_reset_email_subject.txt`
All of them have following context:
* `user`
* `domain`
* `site_name`
* `url`
* `uid`
* `token`
* `protocol`
## Sample usage
We provide a standalone test app for you to start easily, see how everything works with basic settings. It might be useful before integrating **djoser** into your backend application.
In this extremely short tutorial we are going to mimic the simplest flow: register user, log in and log out. We will also check resource access on each consecutive step. Let's go!
* Clone repository and install **djoser** to your virtualenv:
`$ git clone git@github.com:sunscrapers/djoser.git`
`$ cd djoser`
`$ pip install -e .`
* Go to the `testproject` directory, migrate the database and start the development server:
`$ cd testproject`
`$ ./manage.py migrate`
`$ ./manage.py runserver 8088`
* Register a new user:
`$ curl -X POST http://127.0.0.1:8088/auth/register/ --data 'username=djoser&password=djoser'`
`{"email": "", "username": "djoser"}`
So far, so good. We have just created a new user using REST API.
* Let's access user's details:
`$ curl -X GET http://127.0.0.1:8088/auth/me/`
`{"detail": "Authentication credentials were not provided."}`
As we can see, we cannot access user profile without logging in. Pretty obvious.
* Let's log in:
`curl -X POST http://127.0.0.1:8088/auth/login/ --data 'username=djoser&password=djoser'`
`{"auth_token": "b704c9fc3655635646356ac2950269f352ea1139"}`
We have just obtained an authorization token that we may use later in order to retrieve specific resources.
* Let's access user's details again:
`$ curl -X GET http://127.0.0.1:8088/auth/me/`
`{"detail": "Authentication credentials were not provided."}`
Access is still forbidden but let's offer the token we obtained:
`$ curl -X GET http://127.0.0.1:8088/auth/me/ -H 'Authorization: Token b704c9fc3655635646356ac2950269f352ea1139'`
`{"email": "", "username": "djoser"}`
Yay, it works!
* Now let's log out:
`curl -X POST http://127.0.0.1:8088/auth/logout/ -H 'Authorization: Token b704c9fc3655635646356ac2950269f352ea1139'`
And try access user profile again:
`$ curl -X GET http://127.0.0.1:8088/auth/me/ -H 'Authorization: Token b704c9fc3655635646356ac2950269f352ea1139'`
`{"detail": "Invalid token"}`
As we can see, user has been logged out successfully and the proper token has been removed.
## Customization
If you need to override some `djoser` behaviour, you could define your custom view/serializer.
Define custom urls instead of reusing `djoser.urls`:
```python
urlpatterns = patterns('',
(...),
url(r'^register/$', views.CustomRegistrationView.as_view()),
)
```
Define custom view/serializer (inherit from one of `djoser` class) and override necessary method/field:
```python
class CustomRegistrationView(djoser.views.RegistrationView):
def send_email(self, *args, **kwargs):
your_custom_email_sender(*args, **kwargs)
```
You could check `djoser` API in source code:
* [djoser.views](https://github.com/sunscrapers/djoser/blob/master/djoser/views.py)
* [djoser.serializers](https://github.com/sunscrapers/djoser/blob/master/djoser/serializers.py)
## Development
To start developing on **djoser**, clone the repository:
`$ git clone git@github.com:sunscrapers/djoser.git`
In order to run the tests create virtualenv, go to repo directory and then:
`$ pip install -r requirements-test.txt`
`$ cd testproject`
`$ ./manage.py migrate`
`$ ./manage.py test`
## Similar projects
List of projects related to Django, REST and authentication:
- [django-rest-auth](https://github.com/Tivix/django-rest-auth)
- [django-rest-framework-digestauth](https://github.com/juanriaza/django-rest-framework-digestauth)
- [django-oauth-toolkit](https://github.com/evonove/django-oauth-toolkit)
- [doac](https://github.com/Rediker-Software/doac)
- [django-rest-framework-jwt](https://github.com/GetBlimp/django-rest-framework-jwt)
- [django-rest-framework-httpsignature](https://github.com/etoccalino/django-rest-framework-httpsignature)
- [hawkrest](https://github.com/kumar303/hawkrest)
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
|