Browse Source

Added basic auth endpoints

api
Felipe Martín 7 years ago
parent
commit
65f05ea0ef
  1. 5
      config/requirements.txt
  2. 28
      shelfzilla/settings/base.py
  3. 11
      shelfzilla/urls.py
  4. 11
      shelfzilla/views.py

5
config/requirements.txt

@ -25,3 +25,8 @@ django-filer==0.9.8
# Blog
django-ckeditor-updated==4.4.4
# API
djoser==0.2.1
djangorestframework==3.1.1
django-cors-headers==1.0.0

28
shelfzilla/settings/base.py

@ -70,6 +70,12 @@ INSTALLED_APPS = (
'shelfzilla.apps.manga',
'shelfzilla.apps.blog',
'shelfzilla.apps.pjax',
# API
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'djoser',
)
TEMPLATE_CONTEXT_PROCESSORS = (
@ -94,6 +100,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
MIDDLEWARE_CLASSES = (
'reversion.middleware.RevisionMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@ -297,3 +304,24 @@ CKEDITOR_CONFIGS = {
# AUTH
#
AUTH_USER_MODEL = 'account.User'
#
# API
#
CORS_ORIGIN_ALLOW_ALL = True
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
}
DJOSER = {
'DOMAIN': 'shelfzilla.com',
'SITE_NAME': 'Shelfzilla',
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'LOGIN_AFTER_ACTIVATION': True,
'SEND_ACTIVATION_EMAIL': False,
}

11
shelfzilla/urls.py

@ -2,7 +2,7 @@ from django.conf.urls import patterns, include, url
from django.conf import settings
from django.contrib import admin
from .views import MessagesView
from .views import MessagesView, BlockedView
admin.autodiscover()
@ -21,6 +21,15 @@ urlpatterns = patterns(
url(r'^search/', include('shelfzilla.apps.manga.urls.search')),
url(r'^_admin/', include('shelfzilla.apps._admin.urls')),
url(r'^admin/', include(admin.site.urls)),
# url(r'^feedback/',
# include('object_feedback.urls', namespace="object_feedback")),
)
# API
urlpatterns += patterns(
'',
url(r'^api/v1/auth/register/', BlockedView.as_view()),
url(r'^api/v1/auth/', include('djoser.urls', namespace='api')),
)
if settings.DEBUG:

11
shelfzilla/views.py

@ -1,9 +1,15 @@
# coding: utf-8
# python
import json
# django
from django.views.generic import View as DjangoView
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.contrib import messages
from django.core.exceptions import PermissionDenied
class View(DjangoView):
@ -46,3 +52,8 @@ class MessagesView(View):
)
return result
class BlockedView(View):
def dispatch(self, *args, **kwargs):
raise PermissionDenied