Lines 405-410
class ResourceBase(object):
|
Link Here
|
---|
|
405 |
def parse_authorization(self, authorization): |
405 |
def parse_authorization(self, authorization): |
406 |
if authorization in self.authenticated: |
406 |
if authorization in self.authenticated: |
407 |
(self.request.user_dn, self.request.username, self.ldap_connection, self.ldap_position) = self.authenticated[authorization] |
407 |
(self.request.user_dn, self.request.username, self.ldap_connection, self.ldap_position) = self.authenticated[authorization] |
|
|
408 |
MODULE.warn("[{}] Using cached LDAP connection.".format(os.getpid())) |
408 |
if self.ldap_connection.whoami(): |
409 |
if self.ldap_connection.whoami(): |
409 |
return # the ldap connection is still valid and bound |
410 |
return # the ldap connection is still valid and bound |
410 |
try: |
411 |
try: |
Lines 414-419
class ResourceBase(object):
|
Link Here
|
---|
|
414 |
except (ValueError, IndexError, binascii.Error): |
415 |
except (ValueError, IndexError, binascii.Error): |
415 |
raise HTTPError(400) |
416 |
raise HTTPError(400) |
416 |
|
417 |
|
|
|
418 |
MODULE.warn("[{}] Getting fresh LDAP connection.".format(os.getpid())) |
417 |
lo, po = get_machine_connection(write=False) |
419 |
lo, po = get_machine_connection(write=False) |
418 |
try: |
420 |
try: |
419 |
userdn = lo.searchDn(filter_format('(&(objectClass=person)(uid=%s))', [username]), unique=True)[0] |
421 |
userdn = lo.searchDn(filter_format('(&(objectClass=person)(uid=%s))', [username]), unique=True)[0] |
Lines 2540-2545
class Object(FormBase, Resource):
|
Link Here
|
---|
|
2540 |
"""Get a representation of the {} object {} with all its properties, policies, options, metadata and references. |
2542 |
"""Get a representation of the {} object {} with all its properties, policies, options, metadata and references. |
2541 |
Includes also instructions how to modify, remove or move the object. |
2543 |
Includes also instructions how to modify, remove or move the object. |
2542 |
""" |
2544 |
""" |
|
|
2545 |
MODULE.warn("[{}] Get {}...".format(os.getpid(), object_type)) |
2543 |
dn = unquote_dn(dn) |
2546 |
dn = unquote_dn(dn) |
2544 |
copy = bool(self.get_query_argument('copy', None)) # TODO: move into own resource: ./copy |
2547 |
copy = bool(self.get_query_argument('copy', None)) # TODO: move into own resource: ./copy |
2545 |
|
2548 |
|
Lines 2719-2724
class Object(FormBase, Resource):
|
Link Here
|
---|
|
2719 |
@tornado.gen.coroutine |
2722 |
@tornado.gen.coroutine |
2720 |
def put(self, object_type, dn): |
2723 |
def put(self, object_type, dn): |
2721 |
"""Modify or move the {} object {}.""" |
2724 |
"""Modify or move the {} object {}.""" |
|
|
2725 |
MODULE.warn("[{}] Put {}...".format(os.getpid(), object_type)) |
2722 |
dn = unquote_dn(dn) |
2726 |
dn = unquote_dn(dn) |
2723 |
module = get_module(object_type, dn, self.ldap_connection) |
2727 |
module = get_module(object_type, dn, self.ldap_connection) |
2724 |
if not module: |
2728 |
if not module: |
Lines 2757-2762
class Object(FormBase, Resource):
|
Link Here
|
---|
|
2757 |
@tornado.gen.coroutine |
2761 |
@tornado.gen.coroutine |
2758 |
def patch(self, object_type, dn): |
2762 |
def patch(self, object_type, dn): |
2759 |
"""Modify partial properties of the {} object {}.""" |
2763 |
"""Modify partial properties of the {} object {}.""" |
|
|
2764 |
MODULE.warn("[{}] Patch {}...".format(os.getpid(), object_type)) |
2760 |
dn = unquote_dn(dn) |
2765 |
dn = unquote_dn(dn) |
2761 |
module = get_module(object_type, dn, self.ldap_connection) |
2766 |
module = get_module(object_type, dn, self.ldap_connection) |
2762 |
if not module: |
2767 |
if not module: |
Lines 2786-2791
class Object(FormBase, Resource):
|
Link Here
|
---|
|
2786 |
|
2791 |
|
2787 |
@tornado.gen.coroutine |
2792 |
@tornado.gen.coroutine |
2788 |
def create(self, object_type, dn=None): |
2793 |
def create(self, object_type, dn=None): |
|
|
2794 |
MODULE.warn("[{}] Create {}...".format(os.getpid(), object_type)) |
2789 |
module = self.get_module(object_type) |
2795 |
module = self.get_module(object_type) |
2790 |
container = self.request.body_arguments['position'] |
2796 |
container = self.request.body_arguments['position'] |
2791 |
superordinate = self.request.body_arguments['superordinate'] |
2797 |
superordinate = self.request.body_arguments['superordinate'] |
Lines 2905-2910
class Object(FormBase, Resource):
|
Link Here
|
---|
|
2905 |
@tornado.gen.coroutine |
2911 |
@tornado.gen.coroutine |
2906 |
def delete(self, object_type, dn): |
2912 |
def delete(self, object_type, dn): |
2907 |
"""Remove the {} object {}.""" |
2913 |
"""Remove the {} object {}.""" |
|
|
2914 |
MODULE.warn("[{}] Delete {}...".format(os.getpid(), object_type)) |
2908 |
dn = unquote_dn(dn) |
2915 |
dn = unquote_dn(dn) |
2909 |
module = get_module(object_type, dn, self.ldap_connection) |
2916 |
module = get_module(object_type, dn, self.ldap_connection) |
2910 |
if not module: |
2917 |
if not module: |
Lines 3688-3693
class Application(tornado.web.Application):
|
Link Here
|
---|
|
3688 |
(r"/udm/progress/([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})", Operations), |
3695 |
(r"/udm/progress/([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})", Operations), |
3689 |
# TODO: decorator for dn argument, which makes sure no invalid dn syntax is used |
3696 |
# TODO: decorator for dn argument, which makes sure no invalid dn syntax is used |
3690 |
], default_handler_class=Nothing, **kwargs) |
3697 |
], default_handler_class=Nothing, **kwargs) |
|
|
3698 |
MODULE.warn("[{}] Initialized.".format(os.getpid())) |
3691 |
|
3699 |
|
3692 |
def multi_regex(self, chars): |
3700 |
def multi_regex(self, chars): |
3693 |
# Bug in tornado: requests go against the raw url; https://github.com/tornadoweb/tornado/issues/2548, therefore we must match =, %3d, %3D |
3701 |
# Bug in tornado: requests go against the raw url; https://github.com/tornadoweb/tornado/issues/2548, therefore we must match =, %3d, %3D |