Merge pull request #15 from vdchuyen/master

Add Active directory authentication and Timeout for large zone
This commit is contained in:
Khanh Ngo 2016-03-17 20:06:10 +07:00
commit 7c46c149f8
3 changed files with 14 additions and 3 deletions

View File

@ -3,6 +3,9 @@ import sys
import json
import requests
import urlparse
from app import app
TIMEOUT = app.config['TIMEOUT']
def auth_from_url(url):
auth = None
@ -18,7 +21,7 @@ def fetch_remote(remote_url, method='GET', data=None, accept=None, params=None,
data = json.dumps(data)
if timeout is None:
timeout = 1.5
timeout = TIMEOUT
verify = False
@ -125,4 +128,4 @@ def display_time(amount, units='s', remove_seconds=True):
final_string = final_string[:final_string.rfind(' ')]
return final_string[:final_string.rfind(' ')]
return final_string
return final_string

View File

@ -18,6 +18,7 @@ LDAP_URI = app.config['LDAP_URI']
LDAP_USERNAME = app.config['LDAP_USERNAME']
LDAP_PASSWORD = app.config['LDAP_PASSWORD']
LDAP_SEARCH_BASE = app.config['LDAP_SEARCH_BASE']
LDAP_TYPE = app.config['LDAP_TYPE']
PDNS_STATS_URL = app.config['PDNS_STATS_URL']
PDNS_API_KEY = app.config['PDNS_API_KEY']
@ -146,7 +147,10 @@ class User(db.Model):
return False
elif method == 'LDAP':
searchFilter = "cn=%s" % self.username
if LDAP_TYPE == 'ldap':
searchFilter = "cn=%s" % self.username
else:
searchFilter = "(&(objectcategory=person)(samaccountname=%s))" % self.username
try:
result = self.ldap_search(searchFilter, LDAP_SEARCH_BASE)
except Exception, e:

View File

@ -6,6 +6,9 @@ WTF_CSRF_ENABLED = True
SECRET_KEY = 'We are the world'
PORT = 9393
# TIMEOUT - for large zones
TIMEOUT = 10
# LOG CONFIG
LOG_LEVEL = 'DEBUG'
LOG_FILE = 'logfile.log'
@ -23,6 +26,7 @@ LDAP_URI = 'ldaps://your-ldap-server:636'
LDAP_USERNAME = 'cn=dnsuser,ou=users,ou=services,dc=duykhanh,dc=me'
LDAP_PASSWORD = 'dnsuser'
LDAP_SEARCH_BASE = 'ou=System Admins,ou=People,dc=duykhanh,dc=me'
LDAP_TYPE = 'ldap' // or 'ad'
# POWERDNS CONFIG
PDNS_STATS_URL = 'http://172.16.214.131:8081/'