begin phasing in vpn support [poc]
This commit is contained in:
parent
0fd5ac18cd
commit
7f32d05cd4
10 changed files with 137 additions and 4 deletions
|
|
@ -3,7 +3,7 @@ from django.db import transaction
|
|||
from ldap3.core.exceptions import LDAPEntryAlreadyExistsResult
|
||||
from rest_framework import serializers
|
||||
|
||||
from uncloud_pay import AMOUNT_DECIMALS, AMOUNT_MAX_DIGITS
|
||||
from uncloud import AMOUNT_DECIMALS, AMOUNT_MAX_DIGITS
|
||||
from uncloud_pay.models import BillingAddress
|
||||
|
||||
from .ungleich_ldap import LdapManager
|
||||
|
|
|
|||
13
uncloud_auth/templates/uncloud_auth/login.html
Normal file
13
uncloud_auth/templates/uncloud_auth/login.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{% extends 'uncloud/base.html' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
42
uncloud_auth/uldap.py
Normal file
42
uncloud_auth/uldap.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import ldap
|
||||
# from django.conf import settings
|
||||
|
||||
AUTH_LDAP_SERVER_URI = "ldaps://ldap1.ungleich.ch,ldaps://ldap2.ungleich.ch"
|
||||
AUTH_LDAP_BIND_DN="uid=django-create,ou=system,dc=ungleich,dc=ch"
|
||||
AUTH_LDAP_BIND_PASSWORD="kS#e+v\zjKn]L!,RIu2}V+DUS"
|
||||
# AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=ungleich,dc=ch",
|
||||
# ldap.SCOPE_SUBTREE,
|
||||
# "(uid=%(user)s)")
|
||||
|
||||
|
||||
|
||||
ldap_object = ldap.initialize(AUTH_LDAP_SERVER_URI)
|
||||
cancelid = ldap_object.bind(AUTH_LDAP_BIND_DN, AUTH_LDAP_BIND_PASSWORD)
|
||||
|
||||
res = ldap_object.search_s("dc=ungleich,dc=ch", ldap.SCOPE_SUBTREE, "(uid=nico)")
|
||||
print(res)
|
||||
|
||||
# class LDAP(object):
|
||||
# """
|
||||
# Managing users in LDAP
|
||||
|
||||
# Requires the following settings?
|
||||
|
||||
# LDAP_USER_DN: where to create users in the tree
|
||||
|
||||
# LDAP_ADMIN_DN: which DN to use for managing users
|
||||
# LDAP_ADMIN_PASSWORD: which password to used
|
||||
|
||||
# This module will reuse information from djagno_auth_ldap, including:
|
||||
|
||||
# AUTH_LDAP_SERVER_URI
|
||||
|
||||
# """
|
||||
# def __init__(self):
|
||||
# pass
|
||||
|
||||
# def create_user(self):
|
||||
# pass
|
||||
|
||||
# def change_password(self):
|
||||
# pass
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth import logout
|
||||
|
||||
from django_auth_ldap.backend import LDAPBackend
|
||||
from rest_framework import mixins, permissions, status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
|
|
@ -6,6 +9,14 @@ from rest_framework.response import Response
|
|||
from .serializers import *
|
||||
|
||||
|
||||
class LoginView(auth_views.LoginView):
|
||||
template_name = 'uncloud_auth/login.html'
|
||||
|
||||
class LogoutView(auth_views.LogoutView):
|
||||
pass
|
||||
# template_name = 'uncloud_auth/logo.html'
|
||||
|
||||
|
||||
class UserViewSet(viewsets.GenericViewSet):
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
serializer_class = UserSerializer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue