예제 #1
0
파일: policy.py 프로젝트: liuliuxiaoge/XDRS
def enforce(context, action, target, do_raise=True):
    """
    Verifies that the action is valid on the target in this context.
    """
    """
    ======================================================================================
    context = <xdrs.context.RequestContext object at 0x6dcf050>
    target = {'project_id': u'4537aca4a4a4462fa4c59ad5b5581f00', 'user_id': u'91d732b65831491d8bd952b3111e62dd'}
    action = xdrs:get_algorithms
    ======================================================================================
    """
    init()
    
    credentials = context.to_dict()
    """
    ======================================================================================
    credentials = {'project_name': u'admin', 'user_id': u'91d732b65831491d8bd952b3111e62dd', 'roles': [u'heat_stack_owner', u'_member_', u'admin'], 'timestamp': '2015-03-10T06:48:40.110653', 'auth_token': 'MIIT9wYJKoZIhvcNAQcCoIIT6DCCE+QCAQExCTAHBgUrDgMCGjCCEk0GCSqGSIb3DQEHAaCCEj4EghI6eyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wMy0xMFQwNjo0ODozOS41MzU2NjEiLCAiZXhwaXJlcyI6ICIyMDE1LTAzLTEwVDA3OjQ4OjM5WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImRlc2NyaXB0aW9uIjogImFkbWluIHRlbmFudCIsICJlbmFibGVkIjogdHJ1ZSwgImlkIjogIjQ1MzdhY2E0YTRhNDQ2MmZhNGM1OWFkNWI1NTgxZjAwIiwgIm5hbWUiOiAiYWRtaW4ifX0sICJzZXJ2aWNlQ2F0YWxvZyI6IFt7ImVuZHBvaW50cyI6IFt7ImFkbWluVVJMIjogImh0dHA6Ly8xNzIuMjEuNy40MDo4Nzc0L3YyLzQ1MzdhY2E0YTRhNDQ2MmZhNGM1OWFkNWI1NTgxZjAwIiwgInJlZ2lvbiI6ICJSZWdpb25PbmUiLCAiaW50ZXJuYWxVUkwiOiAiaHR0cDovLzE3Mi4yMS43LjQwOjg3NzQvdjIvNDUzN2FjYTRhNGE0NDYyZmE0YzU5YWQ1YjU1ODFmMDAiLCAia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geyJuYW1lIjogIl9tZW1iZXJfIn0sIHsibmFtZSI6ICJhZG1pbiJ9XSwgIm5hbWUiOiAiYWRtaW4ifSwgIm1ldGFkYXRhIjogeyJpc19hZG1pbiI6IDAsICJyb2xlcyI6IFsiZDlmZGVlODI1NjE3NGJlNWE3MmFjZGZmNDNkM2VkZDMiLCAiOWZlMmZmOWVlNDM4NGIxODk0YTkwODc4ZDNlOTJiYWIiLCAiN2E1ZTg5MmFiYTE5NDI3NWI3ZjQxZWM4Njg2ZDUwOGYiXX19fTGCAYEwggF9AgEBMFwwVzELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVVuc2V0MQ4wDAYDVQQHDAVVbnNldDEOMAwGA1UECgwFVW5zZXQxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQIBATAHBgUrDgMCGjANBgkqhkiG9w0BAQEFAASCAQBkwVlwVgYM+mCIXICViGPgW+AZ--Y3NfWjW92GTBqW4keVrPosYxz--b2SVSGqwOHI1xFPqIx1+fzBCcilE5rIuJ3gxAc2VEWl4whMkriqWo6M8YY+GxGJ07h1NZ3Jc9Mrk7RTWPwU9YPilWPSU9sRx4bv+y7XpL8EIEvi+0dvHKgGI+nvqEYVFIf1vYQN5bvSnAgC1rZ9oB0M4Pg1wd47xQcenZL+XOWb8uxUReAvT-lfjXav7DhwUzPgmlY2XpN+9yfhAXAFF0GkokwjncvC5YTILOa41eMUg8ip47+rijNpQ2FuxVpRhQ-xL9it8+vAYkGLqe7eaQylsf0Nu6JJ', 'remote_address': '172.21.7.40', 'quota_class': None, 'is_admin': True, 'tenant': u'4537aca4a4a4462fa4c59ad5b5581f00', 'service_catalog': [{u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'region': u'RegionOne', u'publicURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'id': u'0a1c8da4f156495aad2130e2c0691982', u'internalURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00'}], u'type': u'volume', u'name': u'cinder'}], 'request_id': 'req-c0439276-3600-49cb-8de5-680b3f7d735c', 'instance_lock_checked': False, 'project_id': u'4537aca4a4a4462fa4c59ad5b5581f00', 'user_name': u'admin', 'read_deleted': 'no', 'user': u'91d732b65831491d8bd952b3111e62dd'}
    ======================================================================================
    """

    # Add the exception arguments if asked to do a raise
    extra = {}
    if do_raise:
        extra.update(exc=exception.PolicyNotAuthorized, action=action)

    """
    ======================================================================================
    action = xdrs:get_algorithms
    target = <xdrs.objects.instance.Instance object at 0x62b4a50>
    credentials = {'project_name': u'admin', 'user_id': u'91d732b65831491d8bd952b3111e62dd', 'roles': [u'heat_stack_owner', u'_member_', u'admin'], 'timestamp': '2015-03-10T06:48:40.110653', 'auth_token': 'MIIT9wYJKoZIhvcNAQcCoIIT6DCCE+QCAQExCTAHBgUrDgMCGjCCEk0GCSqGSIb3DQEHAaCCEj4EghI6eyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wMy0xMFQwNjo0ODozOS41MzU2NjEiLCAiZXhwaXJlcyI6ICIyMDE1LTAzLTEwVDA3OjQ4OjM5WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImRlc2NyaXB0aW9uIjogImFkbWluIHRlbmFudCIsICJlbmFibGVkIjogdHJ1ZSwgImlkIjogIjQ1MzdhY2E0YTRhNDQ2MmZhNGM1OWFkNWI1NTgxZjAwIiwgIm5hbWUiOiAiYWRtaW4ifX0sICJzZXJ2aWNlQ2F0YWxvZyI6IFt7ImVuZHBvaW50cyI6IFt7ImFkbWluVVJMIjogImh0dHA6Ly8xNzIuMjEuNy40MDo4Nzc0L3YyLzQ1MzdhY2E0YTRhNDQ2MmZhNGM1OWFkNWI1NTgxZjAwIiwgInJlZ2lvbiI6ICJSZWdpb25PbmUiLCAiaW50ZXJuYWxVUkwiOiAiaHR0cDovLz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DkxZDhiZDk1MmIzMTExZTYyZGQiLCAicm9sZXMiOiBbeyJuYW1lIjogImhlYXRfc3RhY2tfb3duZXIifSwgeyJuYW1lIjogIl9tZW1iZXJfIn0sIHsibmFtZSI6ICJhZG1pbiJ9XSwgIm5hbWUiOiAiYWRtaW4ifSwgIm1ldGFkYXRhIjogeyJpc19hZG1pbiI6IDAsICJyb2xlcyI6IFsiZDlmZGVlODI1NjE3NGJlNWE3MmFjZGZmNDNkM2VkZDMiLCAiOWZlMmZmOWVlNDM4NGIxODk0YTkwODc4ZDNlOTJiYWIiLCAiN2E1ZTg5MmFiYTE5NDI3NWI3ZjQxZWM4Njg2ZDUwOGYiXX19fTGCAYEwggF9AgEBMFwwVzELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVVuc2V0MQ4wDAYDVQQHDAVVbnNldDEOMAwGA1UECgwFVW5zZXQxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQIBATAHBgUrDgMCGjANBgkqhkiG9w0BAQEFAASCAQBkwVlwVgYM+mCIXICViGPgW+AZ--Y3NfWjW92GTBqW4keVrPosYxz--b2SVSGqwOHI1xFPqIx1+fzBCcilE5rIuJ3gxAc2VEWl4whMkriqWo6M8YY+GxGJ07h1NZ3Jc9Mrk7RTWPwU9YPilWPSU9sRx4bv+y7XpL8EIEvi+0dvHKgGI+nvqEYVFIf1vYQN5bvSnAgC1rZ9oB0M4Pg1wd47xQcenZL+XOWb8uxUReAvT-lfjXav7DhwUzPgmlY2XpN+9yfhAXAFF0GkokwjncvC5YTILOa41eMUg8ip47+rijNpQ2FuxVpRhQ-xL9it8+vAYkGLqe7eaQylsf0Nu6JJ', 'remote_address': '172.21.7.40', 'quota_class': None, 'is_admin': True, 'tenant': u'4537aca4a4a4462fa4c59ad5b5581f00', 'service_catalog': [{u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'region': u'RegionOne', u'publicURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'id': u'0a1c8da4f156495aad2130e2c0691982', u'internalURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00'}], u'type': u'volume', u'name': u'cinder'}], 'request_id': 'req-c0439276-3600-49cb-8de5-680b3f7d735c', 'instance_lock_checked': False, 'project_id': u'4537aca4a4a4462fa4c59ad5b5581f00', 'user_name': u'admin', 'read_deleted': 'no', 'user': u'91d732b65831491d8bd952b3111e62dd'}
    extra = {'action': 'xdrs:get_algorithms', 'exc': <class 'xdrs.exception.PolicyNotAuthorized'>}
    ======================================================================================
    """
    return policy.check(action, target, credentials, **extra)
예제 #2
0
def enforce(context, action, target, do_raise=True):
    """
    Verifies that the action is valid on the target in this context.
    """
    """
    ======================================================================================
    context = <xdrs.context.RequestContext object at 0x6dcf050>
    target = {'project_id': u'4537aca4a4a4462fa4c59ad5b5581f00', 'user_id': u'91d732b65831491d8bd952b3111e62dd'}
    action = xdrs:get_algorithms
    ======================================================================================
    """
    init()

    credentials = context.to_dict()
    """
    ======================================================================================
    credentials = {'project_name': u'admin', 'user_id': u'91d732b65831491d8bd952b3111e62dd', 'roles': [u'heat_stack_owner', u'_member_', u'admin'], 'timestamp': '2015-03-10T06:48:40.110653', 'auth_token': 'MIIT9wYJKoZIhvcNAQcCoIIT6DCCE+QCAQExCTAHBgUrDgMCGjCCEk0GCSqGSIb3DQEHAaCCEj4EghI6eyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wMy0xMFQwNjo0ODozOS41MzU2NjEiLCAiZXhwaXJlcyI6ICIyMDE1LTAzLTEwVDA3OjQ4OjM5WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImRlc2NyaXB0aW9uIjogImFkbWluIHRlbmFudCIsICJlbmFibGVkIjogdHJ1ZSwgImlkIjogIjQ1MzdhY2E0YTRhNDQ2MmZhNGM1OWFkNWI1N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GkokwjncvC5YTILOa41eMUg8ip47+rijNpQ2FuxVpRhQ-xL9it8+vAYkGLqe7eaQylsf0Nu6JJ', 'remote_address': '172.21.7.40', 'quota_class': None, 'is_admin': True, 'tenant': u'4537aca4a4a4462fa4c59ad5b5581f00', 'service_catalog': [{u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'region': u'RegionOne', u'publicURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'id': u'0a1c8da4f156495aad2130e2c0691982', u'internalURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00'}], u'type': u'volume', u'name': u'cinder'}], 'request_id': 'req-c0439276-3600-49cb-8de5-680b3f7d735c', 'instance_lock_checked': False, 'project_id': u'4537aca4a4a4462fa4c59ad5b5581f00', 'user_name': u'admin', 'read_deleted': 'no', 'user': u'91d732b65831491d8bd952b3111e62dd'}
    ======================================================================================
    """

    # Add the exception arguments if asked to do a raise
    extra = {}
    if do_raise:
        extra.update(exc=exception.PolicyNotAuthorized, action=action)
    """
    ======================================================================================
    action = xdrs:get_algorithms
    target = <xdrs.objects.instance.Instance object at 0x62b4a50>
    credentials = {'project_name': u'admin', 'user_id': u'91d732b65831491d8bd952b3111e62dd', 'roles': [u'heat_stack_owner', u'_member_', u'admin'], 'timestamp': '2015-03-10T06:48:40.110653', 'auth_token': 'MIIT9wYJKoZIhvcNAQcCoIIT6DCCE+QCAQExCTAHBgUrDgMCGjCCEk0GCSqGSIb3DQEHAaCCEj4EghI6eyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wMy0xMFQwNjo0ODozOS41MzU2NjEiLCAiZXhwaXJlcyI6ICIyMDE1LTAzLTEwVDA3OjQ4OjM5WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJ0ZW5hbnQiOiB7ImRlc2NyaXB0aW9uIjogImFkbWluIHR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5bvSnAgC1rZ9oB0M4Pg1wd47xQcenZL+XOWb8uxUReAvT-lfjXav7DhwUzPgmlY2XpN+9yfhAXAFF0GkokwjncvC5YTILOa41eMUg8ip47+rijNpQ2FuxVpRhQ-xL9it8+vAYkGLqe7eaQylsf0Nu6JJ', 'remote_address': '172.21.7.40', 'quota_class': None, 'is_admin': True, 'tenant': u'4537aca4a4a4462fa4c59ad5b5581f00', 'service_catalog': [{u'endpoints_links': [], u'endpoints': [{u'adminURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'region': u'RegionOne', u'publicURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00', u'id': u'0a1c8da4f156495aad2130e2c0691982', u'internalURL': u'http://172.21.7.40:8776/v1/4537aca4a4a4462fa4c59ad5b5581f00'}], u'type': u'volume', u'name': u'cinder'}], 'request_id': 'req-c0439276-3600-49cb-8de5-680b3f7d735c', 'instance_lock_checked': False, 'project_id': u'4537aca4a4a4462fa4c59ad5b5581f00', 'user_name': u'admin', 'read_deleted': 'no', 'user': u'91d732b65831491d8bd952b3111e62dd'}
    extra = {'action': 'xdrs:get_algorithms', 'exc': <class 'xdrs.exception.PolicyNotAuthorized'>}
    ======================================================================================
    """
    return policy.check(action, target, credentials, **extra)
예제 #3
0
파일: policy.py 프로젝트: liuliuxiaoge/XDRS
def check_is_admin(context):
    """
    Whether or not roles contains 'admin' role according to policy setting.
    """
    init()

    #the target is user-self
    credentials = context.to_dict()
    target = credentials

    return policy.check('context_is_admin', target, credentials)
예제 #4
0
def check_is_admin(context):
    """
    Whether or not roles contains 'admin' role according to policy setting.
    """
    init()

    #the target is user-self
    credentials = context.to_dict()
    target = credentials

    return policy.check('context_is_admin', target, credentials)