• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python client.get_auth函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中swiftclient.client.get_auth函数的典型用法代码示例。如果您正苦于以下问题:Python get_auth函数的具体用法?Python get_auth怎么用?Python get_auth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_auth函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_auth_v2_insecure

    def test_auth_v2_insecure(self):
        os_options = {'tenant_name': 'foo'}
        c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(
            os_options, None)

        auth_url_secure = 'https://www.tests.com'
        auth_url_insecure = 'https://www.tests.com/invalid-certificate'

        url, token = c.get_auth(auth_url_secure, 'asdf', 'asdf',
                                os_options=os_options, auth_version='2.0')
        self.assertTrue(url.startswith("http"))
        self.assertTrue(token)

        url, token = c.get_auth(auth_url_insecure, 'asdf', 'asdf',
                                os_options=os_options, auth_version='2.0',
                                insecure=True)
        self.assertTrue(url.startswith("http"))
        self.assertTrue(token)

        self.assertRaises(c.ClientException, c.get_auth,
                          auth_url_insecure, 'asdf', 'asdf',
                          os_options=os_options, auth_version='2.0')
        self.assertRaises(c.ClientException, c.get_auth,
                          auth_url_insecure, 'asdf', 'asdf',
                          os_options=os_options, auth_version='2.0',
                          insecure=False)
开发者ID:mgeisler,项目名称:python-swiftclient,代码行数:26,代码来源:test_swiftclient.py


示例2: test_auth_v2_insecure

    def test_auth_v2_insecure(self):
        os_options = {"tenant_name": "foo"}
        c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options, None)

        auth_url_secure = "https://www.tests.com"
        auth_url_insecure = "https://www.tests.com/invalid-certificate"

        url, token = c.get_auth(auth_url_secure, "asdf", "asdf", os_options=os_options, auth_version="2.0")
        self.assertTrue(url.startswith("http"))
        self.assertTrue(token)

        url, token = c.get_auth(
            auth_url_insecure, "asdf", "asdf", os_options=os_options, auth_version="2.0", insecure=True
        )
        self.assertTrue(url.startswith("http"))
        self.assertTrue(token)

        self.assertRaises(
            c.ClientException, c.get_auth, auth_url_insecure, "asdf", "asdf", os_options=os_options, auth_version="2.0"
        )
        self.assertRaises(
            c.ClientException,
            c.get_auth,
            auth_url_insecure,
            "asdf",
            "asdf",
            os_options=os_options,
            auth_version="2.0",
            insecure=False,
        )
开发者ID:AlphaStaxLLC,项目名称:python-swiftclient,代码行数:30,代码来源:test_swiftclient.py


示例3: wrapper

    def wrapper(*args, **kw):

        storage_url = args[0].session.get('storage_url', '')
        auth_token = args[0].session.get('auth_token', '')
        username = args[0].session.get('username', '')
        password = args[0].session.get('password', '')

        # If the following variables are available, attempt to get an
        # auth token
        if (storage_url and auth_token and username and password):
            try:
                client.head_account(storage_url, auth_token)
                return fn(*args, **kw)
            except:

                #Attempt to get a new auth token
                try:
                    auth_version = settings.SWIFT_AUTH_VERSION or 1
                    (storage_url, auth_token) = client.get_auth(
                        settings.SWIFT_AUTH_URL, username, password,
                        auth_version=auth_version)
                    args[0].session['auth_token'] = auth_token
                    args[0].session['storage_url'] = storage_url
                    return fn(*args, **kw)
                except:
                    # Failure to get an auth token, tell the user the session
                    # has expired.
                    messages.error(args[0], _("Session expired."))
        return redirect(swiftbrowser.views.login)
开发者ID:OLRC,项目名称:django-swiftbrowser,代码行数:29,代码来源:utils.py


示例4: test_auth_v2_with_tenant_user_in_user

 def test_auth_v2_with_tenant_user_in_user(self):
     c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0
     url, token = c.get_auth('http://www.test.com', 'foo:bar', 'asdf',
                             os_options={},
                             auth_version="2.0")
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:CiscoSystems,项目名称:python-swiftclient,代码行数:7,代码来源:test_swiftclient.py


示例5: test_auth_v2

 def test_auth_v2(self):
     c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0
     url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
                             os_options={'tenant_name': 'asdf'},
                             auth_version="2.0")
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:CiscoSystems,项目名称:python-swiftclient,代码行数:7,代码来源:test_swiftclient.py


示例6: main

def main():
    os_options = {'tenant_name': ACCOUNT}
    url, token = c.get_auth( 'http://' + AUTH_IP + ":" 
                             + AUTH_PORT + '/v2.0', 
                             ACCOUNT + ':' + USER_NAME, 
                             PASSWORD, 
                             os_options = os_options, 
                             auth_version = '2.0' )
    
    print 'Deploying Identity storlet and dependencies'
    
    deploy_storlet(url, token)
    
    print "Invoking Identity storlet on PUT"
    invoke_storlet(url, token,'PUT')
    progress_msg("Invoking Identity storlet on 1GB file PUT")
    invoke_storlet_on_1GB_file(url, token)    
    print "Invoking Identity storlet on PUT with execution of dependency"
    invoke_storlet(url, token,'PUT', {'execute' : 'true'})
    print "Invoking Identity storlet on PUT with double"
    invoke_storlet(url, token,'PUT', {'double' : 'true'})
    print "Invoking Identity storlet on GET"
    invoke_storlet(url, token,'GET')
    print "Invoking Identity storlet on GET with double"
    invoke_storlet(url, token,'GET', {'double' : 'true'})
    print "Invoking Identity storlet on GET with execution of dependency"
    invoke_storlet(url, token,'GET',{'execute' : 'true'})
    print "Invoking Identity storlet in Task"
开发者ID:ymoatti,项目名称:swift-storlets,代码行数:28,代码来源:identity_storlet_test.py


示例7: main

def main():
	os_options = {'tenant_name': ACCOUNT}
	url, token = c.get_auth( 'http://' + AUTH_IP + ":" 
		             + AUTH_PORT + '/v2.0', 
		             ACCOUNT + ':' + USER_NAME, 
		             PASSWORD, 
		             os_options = os_options, 
		             auth_version = '2.0' )

	print 'Deploying ReadHeaders storlet'
	deploy_storlet(url, token, 'ReadHeadersStorlet',
					 'readheadersstorlet-1.0.jar')

	print 'Deploying ReadHeaders dependency'
	put_storlet_dependency(url, token, 'json-simple-1.1.1.jar',
				 '../StorletSamples/ReadHeadersStorlet/lib')

	print 'Deploying CSS storlet'
	deploy_storlet(url, token, 'CssStorlet', 'cssstorlet-1.0.jar')

	print "Invoking CSS storlet in PUT mode"
	invoke_storlet(url, token, 'CssStorlet', 'cssstorlet-1.0.jar',
							 'testDataCss', 'PUT')

	print "Invoking ReadHeaders storlet in GET mode"
	headers, content = invoke_storlet(url, token, 'ReadHeadersStorlet',
				'readheadersstorlet-1.0.jar', 'testDataCss', 'GET')	

	assert '{"Square-Sums":"[2770444.6455999985, 1.9458262030000027E7,' \
		+ ' 95.17999999999981]","Lines-Num":"356","Sums":"[27037.0' \
		+ '40000000008, 83229.09999999998, 168.39999999999947]"}'\
		 == content
	
	print "ReadHeaders test finished"
开发者ID:Open-I-Beam,项目名称:swift-storlets,代码行数:34,代码来源:RH_and_CSS_test.py


示例8: main

def main():
    os_options = {"tenant_name": ACCOUNT}
    url, token = c.get_auth(
        "http://" + AUTH_IP + ":" + AUTH_PORT + "/v2.0",
        ACCOUNT + ":" + USER_NAME,
        PASSWORD,
        os_options=os_options,
        auth_version="2.0",
    )

    sys.stdout.write("Enter storlet jar name: ")
    storlet_jar = sys.stdin.readline().rstrip()
    print("Your jar file has the following classes:")
    list_classes(storlet_jar)
    sys.stdout.write("Please enter storlet main class: ")
    storlet_main_class = sys.stdin.readline().rstrip()
    print("Please enter dependency jars (leave a blank line when you are " "done):")
    dependency_jars = []
    dependencies = []
    dependency_jar = sys.stdin.readline().rstrip()
    while dependency_jar:
        dependency_jars.append(dependency_jar)
        dependencies.append(os.path.basename(dependency_jar))
        dependency_jar = sys.stdin.readline().rstrip()

    deploy_storlet(url, token, storlet_jar, storlet_main_class, dependency_jars, dependencies)
开发者ID:hroumani,项目名称:genericStorletStore,代码行数:26,代码来源:deploy_storlet.py


示例9: authDomainUser

    def authDomainUser(self, _realmname, username, password, environ):
        """Returns True if this username/password pair is valid for the realm,
        False otherwise. Used for basic authentication.
        """

        try:
            username = username.replace(';', ':')
            kwargs = {}
            if self.auth_version == 2:
                tenantname, username = username.split(':')
                kwargs = {
                    'os_options': {
                        'tenant_name': tenantname}, 'auth_version': 2}
            (storage_url, auth_token) = client.get_auth(
                self.swift_auth_url, username, password, **kwargs)
            print storage_url, auth_token
            environ["swift_storage_url"] = storage_url
            environ["swift_auth_token"] = auth_token
            environ["swift_usernampe"] = username
            environ["swift_password"] = password
            environ["swift_auth_url"] = self.swift_auth_url
            environ["insecure"] = self.insecure

            return True
        except client.ClientException:
            return False
        except socket.gaierror:
            return False
开发者ID:cschwede,项目名称:swiftdav,代码行数:28,代码来源:swiftdav.py


示例10: test_auth_v2_with_tenant_user_in_user_no_os_options

 def test_auth_v2_with_tenant_user_in_user_no_os_options(self):
     tenant_option = {'tenant_name': 'foo'}
     c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(tenant_option)
     url, token = c.get_auth('http://www.test.com', 'foo:bar', 'asdf',
                             auth_version="2.0")
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:mgeisler,项目名称:python-swiftclient,代码行数:7,代码来源:test_swiftclient.py


示例11: connect

    def connect(self, force=False):
        if self.http_conn is not None and not force:
            return

        swift_url, self.token = swift.get_auth(
            auth_url=self.auth_url,
            user=self.username,
            key=self.password,
            auth_version=self.auth_ver,
            tenant_name=self.tenant,
        )
        if self.debug:
            print(self.auth_url)
            print(self.token)
            print(self.swift_url)
            print(swift_url)
            print
        if not swift_url == self.swift_url:
            print("Different swift_url returned from swift")

        self.http_conn = swift.http_connection(self.swift_url)

        if self.debug:
            print(self.http_conn)
            print
开发者ID:jesusaurus,项目名称:openstack-tests,代码行数:25,代码来源:swiftTest.py


示例12: login

def login(request):
    """ Tries to login user and sets session data """
    request.session.flush()
    form = LoginForm(request.POST or None)
    if form.is_valid():
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']
        tenant = settings.SWIFT_TENANT_NAME + ":" + username
        try:
            auth_version = settings.SWIFT_AUTH_VERSION or 1
            (storage_url, auth_token) = client.get_auth(
                settings.SWIFT_AUTH_URL, tenant, password,
                auth_version=auth_version)
            request.session['auth_token'] = auth_token
            request.session['storage_url'] = storage_url
            request.session['username'] = tenant
            request.session['user'] = username
           
            return redirect(containerview)

        except client.ClientException:
            messages.add_message(request, messages.ERROR, _("Login failed."))

    return render_to_response('login.html', {'form': form, },
                              context_instance=RequestContext(request))
开发者ID:doana,项目名称:django-swiftbrowser,代码行数:25,代码来源:views.py


示例13: authenticate

def authenticate(request):
    """ Authenticating Swift user. Sets authentication credentials in cookies
    :param request: accepts JSON object containing account, user, password
    :returns Storage URL, Authentication Token"""

    try:
        request.session.flush()
        auth_data_dict = request.data
        (username, password) = auth_data_dict[account_key] + ':' + auth_data_dict[username_key], auth_data_dict[
            pass_key]
        auth_url = settings.SWIFT_AUTH_URL
        (storage_url, auth_token) = client.get_auth(auth_url, username, password)
        storage_url = settings.BASE_URL + storage_url.split(':8080')[1]
        request.session['auth_token'], request.session['storage_url'], request.session['username'] \
            = auth_token, storage_url, username
        request.session[pass_key] = password
        return Response({'username': username, 'auth_token': auth_token, 'storage_url': storage_url},
                        status=status.HTTP_200_OK)
    except swift_exception.ClientException as e:
        print e
        return Response(e.message, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
    except exceptions.KeyError as e:
        print e
        return Response('JSON object key error: ' + str(e), status=status.HTTP_400_BAD_REQUEST)
    except exceptions.ValueError:
        print 'No JSON FOUND'
        return Response('No JSON object found', status=status.HTTP_400_BAD_REQUEST)
    except Exception as e:
        print e
        return Response(e, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
开发者ID:InBetween,项目名称:AssetManager,代码行数:30,代码来源:views.py


示例14: main

def main():
    os_options = {'tenant_name': ACCOUNT}
    url, token = c.get_auth( 'http://' + AUTH_IP + ":" 
                             + AUTH_PORT + '/v2.0', 
                             ACCOUNT + ':' + USER_NAME, 
                             PASSWORD, 
                             os_options = os_options, 
                             auth_version = '2.0' )
    # print('Creating containers for auxiliary files')
    create_container(url, token, 'myobjects')
    create_container(url, token, 'container1')
    create_container(url, token, 'container2')
    create_container(url, token, 'container3')
    # print('Creating Auxiliary files')
    progress_msg("Creating SLO chunks for upload")
    create_local_chunks()
    progress_msg("Uploading SLO chunks and assembly")
    put_SLO(url, token)
    progress_msg("Downloading SLO")
    get_SLO(url, token)
    progress_msg("Invoking storlet on SLO in GET")
    invoke_identity_on_get_SLO(url, token)
    # YM comment out 2 lines - temporary only!
    progress_msg("Invoking storlet on SLO in GET with double")
    invoke_identity_on_get_SLO_double(url, token)

    #progress_msg("Invoking storlet on SLO in partial GET")
    #invoke_identity_on_partial_get_SLO(url, token)
    delete_local_chunks()
开发者ID:Open-I-Beam,项目名称:swift-storlets,代码行数:29,代码来源:SLO_test.py


示例15: test_auth_v2_tenant_name_no_os_options

 def test_auth_v2_tenant_name_no_os_options(self):
     tenant_option = {"tenant_name": "asdf"}
     c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(tenant_option)
     url, token = c.get_auth(
         "http://www.test.com", "asdf", "asdf", tenant_name="asdf", os_options={}, auth_version="2.0"
     )
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:AlphaStaxLLC,项目名称:python-swiftclient,代码行数:8,代码来源:test_swiftclient.py


示例16: get_token

def get_token():
    storageURL, authtoken = client.get_auth(authen.auth_url + ':35357/v2.0',
                                              authen.username,
                                              authen.password,
                                              tenant_name = authen.tenant_name,
                                              auth_version = 2
                                             )
    return storageURL, authtoken
开发者ID:daokhactuan48,项目名称:Admin-Dashboard,代码行数:8,代码来源:swift_test.py


示例17: test_auth_v2_tenant_name_no_os_options

 def test_auth_v2_tenant_name_no_os_options(self):
     tenant_option = {'tenant_name': 'asdf'}
     c.get_auth_keystone = fake_get_auth_keystone(tenant_option)
     url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
                             tenant_name='asdf',
                             os_options={},
                             auth_version="2.0")
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:AsherBond,项目名称:python-swiftclient,代码行数:9,代码来源:test_swiftclient.py


示例18: test_auth_v2_with_os_region_name

 def test_auth_v2_with_os_region_name(self):
     os_options = {'region_name': 'good-region',
                   'tenant_name': 'asdf'}
     c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options)
     url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
                             os_options=os_options,
                             auth_version="2.0")
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:mgeisler,项目名称:python-swiftclient,代码行数:9,代码来源:test_swiftclient.py


示例19: test_auth_v1_insecure

    def test_auth_v1_insecure(self):
        c.http_connection = self.fake_http_connection(200, auth_v1=True)
        url, token = c.get_auth("http://www.test.com/invalid_cert", "asdf", "asdf", auth_version="1.0", insecure=True)
        self.assertEqual(url, "storageURL")
        self.assertEqual(token, "someauthtoken")

        self.assertRaises(
            c.ClientException, c.get_auth, "http://www.test.com/invalid_cert", "asdf", "asdf", auth_version="1.0"
        )
开发者ID:AlphaStaxLLC,项目名称:python-swiftclient,代码行数:9,代码来源:test_swiftclient.py


示例20: test_auth_v2_with_os_options

 def test_auth_v2_with_os_options(self):
     os_options = {'service_type': 'object-store',
                   'endpoint_type': 'internalURL',
                   'tenant_name': 'asdf'}
     c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options)
     url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
                             os_options=os_options,
                             auth_version="2.0")
     self.assertTrue(url.startswith("http"))
     self.assertTrue(token)
开发者ID:mgeisler,项目名称:python-swiftclient,代码行数:10,代码来源:test_swiftclient.py



注:本文中的swiftclient.client.get_auth函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python client.get_container函数代码示例发布时间:2022-05-27
下一篇:
Python client.get_account函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap