Archived
Kerberos could work now
This commit is contained in:
1 parent
3dfd23ec30
commit
a32485a903
2 files changed
+12
-12
No files matched your search
+9
-9
@@ -10,10 +10,10 @@ import settings
|
||||
|
||||
def get_kerberos_principal(username):
|
||||
principal = u"{0}@{1}".format(username, settings.KERBEROS_REALM)
|
||||
kadmin_query = u"-p {0} -w {1} -q 'get_principal {2}'".format(settings.KERBEROS_PASSWORD_CHANGING_PRINCIPAL,
|
||||
settings.KERBEROS_PASSWORD,
|
||||
principal)
|
||||
p = Popen(['kadmin', kadmin_query], stdout=PIPE)
|
||||
kadmin_query = u" -p '{0}' -w {1} -q 'get_principal {2}'".format(settings.KERBEROS_PASSWORD_CHANGING_PRINCIPAL,
|
||||
settings.KERBEROS_PASSWORD,
|
||||
principal)
|
||||
p = Popen('kadmin' + kadmin_query, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
output, error = p.communicate()
|
||||
if error:
|
||||
# Can not init with KDC?
|
||||
@@ -29,11 +29,11 @@ def get_kerberos_principal(username):
|
||||
|
||||
def set_kerberos_password(username, raw_password):
|
||||
principal = u"{0}@{1}".format(username, settings.KERBEROS_REALM)
|
||||
kadmin_query = u"-p {0} -w {1} -q 'change_password {2} -pw {3}'".format(settings.KERBEROS_PASSWORD_CHANGING_PRINCIPAL,
|
||||
settings.KERBEROS_PASSWORD,
|
||||
principal,
|
||||
raw_password)
|
||||
p = Popen(['kadmin', kadmin_query], stdout=PIPE)
|
||||
kadmin_query = u" -p {0} -w {1} -q 'change_password {2} -pw {3}'".format(settings.KERBEROS_PASSWORD_CHANGING_PRINCIPAL,
|
||||
settings.KERBEROS_PASSWORD,
|
||||
principal,
|
||||
raw_password)
|
||||
p = Popen('kadmin' + kadmin_query, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
output, error = p.communicate()
|
||||
if error:
|
||||
# Can not init with KDC?
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
# coding: utf-8
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
import simplejson as json
|
||||
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
@@ -51,8 +51,8 @@ def profile(request):
|
||||
def client_status(request):
|
||||
krb5_principal = utils.get_kerberos_principal(request.user)
|
||||
if krb5_principal:
|
||||
last_succ_auth = datetime.strptime(krb5_principal['Last successful authentication'],
|
||||
'%a %b %m %H:%M:%S %Z %Y')
|
||||
last_succ_auth = datetime.datetime.strptime(krb5_principal['Last successful authentication'],
|
||||
'%a %b %d %H:%M:%S %Z %Y')
|
||||
status = { 'active' : True,
|
||||
'last_successful_auth' : last_succ_auth.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'last_modified' : krb5_principal['Last modified'] }
|
||||
|
||||
Reference in new issue
Block a user