0001-backends-add-last_connection_date-and-creation_date-.patch
mandaye/backends/default.py | ||
---|---|---|
1 | 1 | |
2 |
from datetime import datetime |
|
2 | 3 |
from importlib import import_module |
3 | 4 | |
4 | 5 |
from mandaye import config |
... | ... | |
68 | 69 |
pass |
69 | 70 | |
70 | 71 |
@staticmethod |
71 |
def update_or_create(sp_name, sp_login, sp_post_values, idp_unique_id, idp_name): |
|
72 |
def update_or_create(sp_name, sp_login, sp_post_values, idp_unique_id, |
|
73 |
idp_name='default', creation_date=datetime.utcnow(), |
|
74 |
last_connection_date=datetime.utcnow()): |
|
72 | 75 |
""" update or create an associtaion which match the following values |
73 | 76 |
return the association id |
74 | 77 |
""" |
mandaye/backends/ldap_back.py | ||
---|---|---|
1 | 1 | |
2 |
import datetime |
|
3 | 2 |
import json |
4 | 3 |
import ldap |
5 | 4 |
import ldap.modlist |
6 | 5 |
import random |
7 | 6 | |
7 |
from datetime import datetime |
|
8 | ||
8 | 9 |
from mandaye import config |
9 | 10 |
from mandaye.log import logger |
10 | 11 |
from mandaye.backends.default import storage_conn |
... | ... | |
33 | 34 |
'sp_post_values': json.loads(ldap_object['spPostValues'][0]), |
34 | 35 |
'idp_unique_id': ldap_object['idpUniqueID'][0], |
35 | 36 |
'idp_name': ldap_object['idpName'][0], |
36 |
'last_connection': datetime.datetime.strptime(
|
|
37 |
'last_connection': datetime.strptime( |
|
37 | 38 |
ldap_object['lastConnectionDate'][0][:14], |
38 | 39 |
'%Y%m%d%H%M%S'), |
39 |
'creation_date': datetime.datetime.strptime(
|
|
40 |
'creation_date': datetime.strptime( |
|
40 | 41 |
ldap_object['creationDate'][0][:14], |
41 | 42 |
'%Y%m%d%H%M%S'), |
42 | 43 |
} |
... | ... | |
73 | 74 |
return False |
74 | 75 | |
75 | 76 |
@staticmethod |
76 |
def update_or_create(sp_name, sp_login, sp_post_values, idp_unique_id, idp_name='default'): |
|
77 |
def update_or_create(sp_name, sp_login, sp_post_values, idp_unique_id, |
|
78 |
idp_name='default', creation_date=datetime.utcnow(), |
|
79 |
last_connection_date=datetime.utcnow()): |
|
77 | 80 |
""" update or create an associtaion which match the following values |
78 | 81 |
return the association id |
79 | 82 |
""" |
... | ... | |
86 | 89 |
'spPostValues': json.dumps(sp_post_values), |
87 | 90 |
'idpUniqueID': str(idp_unique_id), |
88 | 91 |
'idpName': str(idp_name), |
89 |
'creationDate': datetime.datetime.utcnow().strftime('%Y%m%d%H%M%SZ'),
|
|
90 |
'lastConnectionDate': datetime.datetime.utcnow().strftime('%Y%m%d%H%M%SZ'),
|
|
92 |
'creationDate': datetime.utcnow().strftime('%Y%m%d%H%M%SZ'), |
|
93 |
'lastConnectionDate': datetime.utcnow().strftime('%Y%m%d%H%M%SZ'), |
|
91 | 94 |
'objectClass': 'MandayeUser' |
92 | 95 |
} |
93 | 96 |
mod_list = ldap.modlist.addModlist(association) |
... | ... | |
131 | 134 |
""" update the association last connection time with the current time |
132 | 135 |
return a dict of the association |
133 | 136 |
""" |
134 |
last_connection = datetime.datetime.utcnow().strftime("%Y%m%d%H%M%SZ")
|
|
137 |
last_connection = datetime.utcnow().strftime("%Y%m%d%H%M%SZ") |
|
135 | 138 |
dn = "uniqueID=%s,%s" % (asso_id, config.ldap_base_dn) |
136 | 139 |
mod_list = [(ldap.MOD_REPLACE, 'lastConnectionDate', last_connection)] |
137 | 140 |
storage_conn.modify_s(dn, mod_list) |
mandaye/backends/sql.py | ||
---|---|---|
71 | 71 |
return False |
72 | 72 | |
73 | 73 |
@staticmethod |
74 |
def update_or_create(sp_name, sp_login, sp_post_values, idp_unique_id, idp_name='default'): |
|
74 |
def update_or_create(sp_name, sp_login, sp_post_values, idp_unique_id, |
|
75 |
idp_name='default', creation_date=datetime.utcnow(), |
|
76 |
last_connection_date=datetime.utcnow()): |
|
75 | 77 |
""" update or create an associtaion which match the following values |
76 | 78 |
return the association id |
77 | 79 |
""" |
... | ... | |
109 | 111 |
login=sp_login, |
110 | 112 |
post_values=sp_post_values, |
111 | 113 |
idp_user=idp_user, |
112 |
service_provider=service_provider |
|
114 |
service_provider=service_provider, |
|
115 |
creation_date=creation_date, |
|
116 |
last_connection=last_connection_date |
|
113 | 117 |
) |
114 | 118 |
storage_conn.add(sp_user) |
115 | 119 |
try: |
116 |
- |