Nouvelle appli ldap correspondant au connecteur

This commit is contained in:
Paul Marillonnet 2017-02-24 10:58:10 +01:00
parent 209173d7d4
commit 0693644e37
7 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,42 @@
from django.db import models
from passerelle.base.models import BaseResource
from passerelle.utils.jsonresponse import APIError
from passerelle.utils.api import endpoint
#import lookups
import sys
sys.path.insert(0, "/home/paul/Documents/paul-synchro/django/sp_sso/saml/")
import utils
#TODO
# ldap3 instead of python-ldap
# derive CsvDataSource connector
# Create your models here.
def format_person(p):
data = {} #TODO format to LDAP InetOrgPerson schema?
return data
def format_org_unit(u):
data = {}
return data
def get_org_unit(u):
return 0
class LDAPConnector(BaseResource):
@classmethod
def get_icon_class(cls):
return 'grid'
@classmethod
def get_verbose_name(cls):
return "LDAP Connector"
@classmethod
def is_enabled(cls):
return True

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,32 @@
# passerelle - uniform access to multiple data sources and services
# Copyright (C) 2016 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import patterns, include, url
from .views import *
urlpatterns = patterns('',
url(r'^(?P<slug>[\w,-]+)/data$', LDAPConnectorView.as_view(), name='ldap_conn-data'),
)
management_urlpatterns = patterns('',
url(r'^(?P<connector_slug>[\w,-]+)/download/$',
LDAPDownload.as_view(), name='csv-download'),
url(r'^(?P<connector_slug>[\w,-]+)/queries/new/$',
NewQueryView.as_view(), name='ldap-new-query'),
url(r'^(?P<connector_slug>[\w,-]+)/queries/(?P<pk>[\w,-]+)/$',
UpdateQueryView.as_view(), name='ldap-edit-query'),
)

View File

@ -0,0 +1,31 @@
from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import os
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.views.generic.detail import SingleObjectMixin
from django.views.generic import View, UpdateView, CreateView
from passerelle import utils
from .forms import QueryForm
from .models import CsvDataSource, Query
#TODO
# derive csv connector
# use ldap3 instead of python-ldap
# Create your views here.
def dummy_view(request):
return HttpResponse("Dummy LDAP connector view.")
class LDAPConnectorView(View, SingleObjectMixin):
def get(request, *args, **kwargs):
return HttpResponse("Got the LDAP!")