Commit bc1ae921 by Karsa Zoltán István

token auth

parent c7fbfc51
...@@ -380,6 +380,7 @@ THIRD_PARTY_APPS = ( ...@@ -380,6 +380,7 @@ THIRD_PARTY_APPS = (
'simplesshkey', 'simplesshkey',
'pipeline', 'pipeline',
'rest_framework', 'rest_framework',
'rest_framework.authtoken',
) )
......
...@@ -33,6 +33,8 @@ from dashboard.views import ( ...@@ -33,6 +33,8 @@ from dashboard.views import (
from dashboard.forms import CirclePasswordResetForm, CircleSetPasswordForm from dashboard.forms import CirclePasswordResetForm, CircleSetPasswordForm
from firewall.views import add_blacklist_item from firewall.views import add_blacklist_item
from rest_framework.authtoken.views import obtain_auth_token
admin.autodiscover() admin.autodiscover()
urlpatterns = [ urlpatterns = [
...@@ -72,7 +74,8 @@ urlpatterns = [ ...@@ -72,7 +74,8 @@ urlpatterns = [
url(r'^info/resize-how-to/$', ResizeHelpView.as_view(), url(r'^info/resize-how-to/$', ResizeHelpView.as_view(),
name="info.resize"), name="info.resize"),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path('api-token-auth/', obtain_auth_token)
] ]
if 'rosetta' in settings.INSTALLED_APPS: if 'rosetta' in settings.INSTALLED_APPS:
......
...@@ -61,6 +61,15 @@ except NameError: ...@@ -61,6 +61,15 @@ except NameError:
logger = getLogger(__name__) logger = getLogger(__name__)
from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
from rest_framework.authtoken.models import Token
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
Token.objects.create(user=instance)
def pwgen(): def pwgen():
return User.objects.make_random_password() return User.objects.make_random_password()
......
...@@ -65,7 +65,7 @@ from .views.node import node_ops ...@@ -65,7 +65,7 @@ from .views.node import node_ops
from .views.vm import vm_ops, vm_mass_ops from .views.vm import vm_ops, vm_mass_ops
urlpatterns = [ urlpatterns = [
path('acpi/list', iac_vm_list), path('acpi/vmlist', iac_vm_list),
url(r'^$', IndexView.as_view(), name="dashboard.index"), url(r'^$', IndexView.as_view(), name="dashboard.index"),
url(r"^profile/list/$", UserList.as_view(), url(r"^profile/list/$", UserList.as_view(),
name="dashboard.views.user-list"), name="dashboard.views.user-list"),
......
...@@ -102,7 +102,6 @@ def iac_vm_list(request): ...@@ -102,7 +102,6 @@ def iac_vm_list(request):
'pk': i.pk, 'pk': i.pk,
'url': reverse('dashboard.views.detail', args=[i.pk]), 'url': reverse('dashboard.views.detail', args=[i.pk]),
'name': i.name, 'name': i.name,
'icon': i.get_status_icon(),
'host': i.short_hostname, 'host': i.short_hostname,
'status': i.get_status_display(), 'status': i.get_status_display(),
'owner': (i.owner.profile.get_display_name()), 'owner': (i.owner.profile.get_display_name()),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment