Esempio n. 1
0
import redis
from libs.environment import ENV
current_env = ENV()

class Redis_base:
    def __init__(self):
        try:
            self.conn = redis.Redis(host=current_env.get_config("REDIS_SERVER"), port=6379,db=1)
        except Exception as e:
            print('redis连接失败,错误信息%s' % e)

    #根据key值获取
    def get(self,key):
        res = self.conn.get(key)
        if res:
            return res.decode()
        else:
            return False

    #写入了一个键值对
    def set(self, key, value):
        return self.conn.set(key, value)

    #将一个或多个值 value 插入到列表 key 的表头
    def lpush(self,key,value):
        return self.conn.lpush(key,value)

    #获取在存储于列表的key索引的元素
    def lindex(self,key,index):
        res = self.conn.lindex(key,index)
        if res:
Esempio n. 2
0
import djcelery
import ldap
import os
from django_auth_ldap.config import LDAPSearch, NestedOrganizationalRoleGroupType, GroupOfUniqueNamesType
import pymysql
from libs.environment import ENV
os.environ['DJANGO_SETTINGS_MODULE'] = 'ldap_server.settings'
from django.core.management import settings
from ldap_server.ldap_config import auth_ldap_bind_dn, auth_ldap_bind_password, user_ldapsearch, \
    user_scope_subtree, group_ldapsearch, group_scope_subtree, is_active, is_staff, is_superuser, \
    ldap_server_url, login_model, ldap_name
from ldap_server.database_connect import DATABASE
current_env = ENV()

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_URL = current_env.get_config("BASE_URL")
SECRET_KEY = current_env.get_config("SECRET_KEY")
DEBUG = current_env.get_config("DEBUG")

ALLOWED_HOSTS = ['*']

INSTALLED_APPS = [
    # 'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # applications
Esempio n. 3
0
import pymysql
from libs.environment import ENV
current_env = ENV()

db = pymysql.connect(current_env.get_config("DB_HOST"),
                     current_env.get_config("DB_USER"),
                     current_env.get_config("DB_PASSWORD"),
                     current_env.get_config("DB_NAME"))
cursor = db.cursor()
sql = 'select * from setup_loginldapconfig'
cursor.execute(sql)
reslist = cursor.fetchall()
try:
    loginconfig = reslist[0]
    auth_ldap_bind_dn = loginconfig[1]
    auth_ldap_bind_password = loginconfig[2]
    user_ldapsearch = loginconfig[3]
    user_scope_subtree = loginconfig[4]
    group_ldapsearch = loginconfig[5]
    group_scope_subtree = loginconfig[6]
    is_active = loginconfig[7]
    is_staff = loginconfig[8]
    is_superuser = loginconfig[9]
    ldap_server_url = loginconfig[10]
    login_model = loginconfig[11]
    ldap_name = loginconfig[12]
except:
    login_model = 2
    auth_ldap_bind_dn = ""
    auth_ldap_bind_password = ""
    user_ldapsearch = ""
Esempio n. 4
0
import os

from libs.environment import ENV
os.environ['DJANGO_SETTINGS_MODULE'] = 'ldap_server.settings'
from ldap_server.ldap_config import auth_ldap_bind_dn, auth_ldap_bind_password, login_model, ldap_name
current_env = ENV()

if login_model == 2:
    DATABASE = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'HOST': current_env.get_config("DB_HOST"),
            'NAME': current_env.get_config("DB_NAME"),
            'USER': current_env.get_config("DB_USER"),
            'PASSWORD': current_env.get_config("DB_PASSWORD"),
            'PORT': current_env.get_config("DB_PORT")
        }
    }
else:
    DATABASE = {
        'ldap': {
            'ENGINE': 'ldapdb.backends.ldap',
            'NAME': ldap_name,
            'USER': auth_ldap_bind_dn,
            'PASSWORD': auth_ldap_bind_password,
        },
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'HOST': current_env.get_config("DB_HOST"),
            'NAME': current_env.get_config("DB_NAME"),
            'USER': current_env.get_config("DB_USER"),
Esempio n. 5
0
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

import os
import ldap
import djcelery
from django_auth_ldap.config import LDAPSearch, NestedOrganizationalRoleGroupType, GroupOfUniqueNamesType

from libs.environment import ENV

current_env = ENV()

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_URL = current_env.get_config("BASE_URL")
SECRET_KEY = current_env.get_config("SECRET_KEY")
DEBUG = current_env.get_config("DEBUG")

ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',