当前位置: 首页>>代码示例>>Python>>正文


Python utils.web2py_uuid方法代码示例

本文整理汇总了Python中gluon.utils.web2py_uuid方法的典型用法代码示例。如果您正苦于以下问题:Python utils.web2py_uuid方法的具体用法?Python utils.web2py_uuid怎么用?Python utils.web2py_uuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gluon.utils的用法示例。


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

示例1: refresh_token

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def refresh_token(self, orig_payload):
        now = time.mktime(datetime.datetime.now().timetuple())
        if self.verify_expiration:
            orig_exp = orig_payload['exp']
            if orig_exp + self.leeway < now:
                # token already expired, can't be used for refresh
                raise HTTP(400, u'Token already expired')
        orig_iat = orig_payload.get('orig_iat') or orig_payload['iat']
        if orig_iat + self.refresh_expiration_delta < now:
            # refreshed too long ago
            raise HTTP(400, u'Token issued too long ago')
        expires = now + self.expiration
        orig_payload.update(
            orig_iat=orig_iat,
            iat=now,
            exp=expires,
            hmac_key=web2py_uuid()
        )
        self.alter_payload(orig_payload)
        return orig_payload 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:22,代码来源:tools.py

示例2: email_registration

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def email_registration(self, subject, body, user):
        """
        Sends and email invitation to a user informing they have been registered with the application
        """
        reset_password_key = str(int(time.time())) + '-' + web2py_uuid()
        link = self.url(self.settings.function,
                        args=('confirm_registration',), vars={'key': reset_password_key},
                        scheme=True)
        d = dict(user)
        d.update(dict(key=reset_password_key, link=link, site=current.request.env.http_host))
        if self.settings.mailer and self.settings.mailer.send(
            to=user.email,
            subject=subject % d,
                message=body % d):
            user.update_record(reset_password_key=reset_password_key)
            return True
        return False 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:19,代码来源:tools.py

示例3: login_user

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def login_user(self, user):
        """
        Logins the `user = db.auth_user(id)`
        """
        from gluon.settings import global_settings
        if global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user, 'password')
        else:
            user = Row(user)
            for key, value in user.items():
                if callable(value) or key == 'password':
                    delattr(user, key)
        if self.settings.renew_session_onlogin:
            current.session.renew(clear_session=not self.settings.keep_session_onlogin)
        current.session.auth = Storage(user=user,
                                       last_visit=current.request.now,
                                       expiration=self.settings.expiration,
                                       hmac_key=web2py_uuid())
        self.user = user
        self.update_groups() 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:23,代码来源:tools.py

示例4: plaid_exchange

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def plaid_exchange():
    import urllib
    import urllib2
    import json
    from gluon.utils import web2py_uuid

    data = urllib.urlencode(dict(public_token=request.vars.public_token,
                                 account_id=request.vars.account_id,
                                 client_id=PLAID_CLIENT_ID,
                                 secret=PLAID_SECRET))
    exchange = json.loads(urllib2.urlopen(PLAID_EXCHANGE_URL,
                          data=data).read())
    session.payment_tokens = dict(
        stripe_bank_account_token=exchange.get('stripe_bank_account_token'),
        transaction_token=web2py_uuid())

    response.headers['Content-Type'] = 'application/json'
    return json.dumps(dict(institution=request.vars.institution.get('name'),
                           name=request.vars.account.get('name'),
                           transaction_token=session.payment_tokens['transaction_token'])) 
开发者ID:mdipierro,项目名称:web2py-cordova,代码行数:22,代码来源:default.py

示例5: login_user

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def login_user(self, user):
        """
        Logins the `user = db.auth_user(id)`
        """
        from gluon.settings import global_settings
        if global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user, 'password')
        else:
            user = Row(user)
            for key in list(user.keys()):
                value = user[key]
                if callable(value) or key == 'password':
                    delattr(user, key)
        if self.settings.renew_session_onlogin:
            current.session.renew(clear_session=not self.settings.keep_session_onlogin)
        current.session.auth = Storage(user=user,
                                       last_visit=current.request.now,
                                       expiration=self.settings.expiration,
                                       hmac_key=web2py_uuid())
        self.user = user
        self.update_groups() 
开发者ID:rekall-innovations,项目名称:rekall-agent-server,代码行数:24,代码来源:tools.py

示例6: refresh_token

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def refresh_token(self, orig_payload):
        now = time.mktime(datetime.datetime.utcnow().timetuple())
        if self.verify_expiration:
            orig_exp = orig_payload['exp']
            if orig_exp + self.leeway < now:
                # token already expired, can't be used for refresh
                raise HTTP(400, u'Token already expired')
        orig_iat = orig_payload.get('orig_iat') or orig_payload['iat']
        if orig_iat + self.refresh_expiration_delta < now:
            # refreshed too long ago
            raise HTTP(400, u'Token issued too long ago')
        expires = now + self.refresh_expiration_delta
        orig_payload.update(
            orig_iat=orig_iat,
            iat=now,
            exp=expires,
            hmac_key=web2py_uuid()
        )
        self.alter_payload(orig_payload)
        return orig_payload 
开发者ID:web2py,项目名称:web3py,代码行数:22,代码来源:auth.py

示例7: login_user

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def login_user(self, user):
        """
        Logins the `user = db.auth_user(id)`
        """
        if False: # FIX THIS global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user, 'password')
        else:
            user = Row(user)
            for key, value in user.items():
                if callable(value) or key == 'password':
                    delattr(user, key)
        if self.settings.renew_session_onlogin:
            current.session.renew(clear_session=not self.settings.keep_session_onlogin)
        current.session.auth = Storage(user=user,
                                       last_visit=current.request.now,
                                       expiration=self.settings.expiration,
                                       hmac_key=web2py_uuid())
        self.user = user
        self.update_groups() 
开发者ID:web2py,项目名称:web3py,代码行数:22,代码来源:auth.py

示例8: login_user

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def login_user(self, user):
        """
        Logins the `user = db.auth_user(id)`
        """
        from gluon.settings import global_settings
        if global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user,'password')
        else:
            user = Row(user)
            for key, value in user.items():
                if callable(value) or key=='password':
                    delattr(user,key)
        if self.settings.renew_session_onlogin:
            current.session.renew(clear_session=not self.settings.keep_session_onlogin)
        current.session.auth = Storage(
            user = user,
            last_visit=current.request.now,
            expiration=self.settings.expiration,
            hmac_key=web2py_uuid())
        self.user = user
        self.update_groups() 
开发者ID:StuffShare,项目名称:StuffShare,代码行数:24,代码来源:tools.py

示例9: _create_id

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def _create_id(self):
        return long(web2py_uuid().replace('-',''),16) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:4,代码来源:memdb.py

示例10: saml2_handler

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def saml2_handler(session, request, config_filename = None):
    config_filename = config_filename or os.path.join(request.folder,'private','sp_conf')
    client = Saml2Client(config_file = config_filename)
    idps = client.metadata.with_descriptor("idpsso")
    entityid = idps.keys()[0]
    bindings = [BINDING_HTTP_REDIRECT, BINDING_HTTP_POST]
    binding, destination = client.pick_binding(
        "single_sign_on_service", bindings, "idpsso", entity_id=entityid)
    if request.env.request_method == 'GET':
        binding = BINDING_HTTP_REDIRECT 
    elif request.env.request_method == 'POST':
        binding = BINDING_HTTP_POST
    if not request.vars.SAMLResponse:
        req_id, req = client.create_authn_request(destination, binding=binding)
        relay_state = web2py_uuid().replace('-','')
        session.saml_outstanding_queries = {req_id: request.url}
        session.saml_req_id = req_id
        http_args = client.apply_binding(binding, str(req), destination,
                                         relay_state=relay_state)
        return {'url':dict(http_args["headers"])['Location']}
    else:
        relay_state = request.vars.RelayState
        req_id = session.saml_req_id
        unquoted_response = request.vars.SAMLResponse
        res =  {}
        try:
            data = client.parse_authn_request_response(
                unquoted_response, binding, session.saml_outstanding_queries)
            res['response'] = data if data else {}
        except Exception as e:
            import traceback
            res['error'] = traceback.format_exc()
        return res 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:35,代码来源:saml2_auth.py

示例11: compute_uuid

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def compute_uuid(self):
        self._uuid = '%s/%s.%s.%s' % (
            self.application,
            self.client.replace(':', '_'),
            self.now.strftime('%Y-%m-%d.%H-%M-%S'),
            web2py_uuid())
        return self._uuid 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:9,代码来源:globals.py

示例12: _update_session_user

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def _update_session_user(self, user):
        if global_settings.web2py_runtime_gae:
            user = Row(self.table_user()._filter_fields(user, id=True))
            delattr(user, self.settings.password_field)
        else:
            user = Row(user)
            for key in list(user.keys()):
                value = user[key]
                if callable(value) or key == self.settings.password_field:
                    delattr(user, key)
        current.session.auth = Storage(user=user,
                                       last_visit=current.request.now,
                                       expiration=self.settings.expiration,
                                       hmac_key=web2py_uuid())
        return user 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:17,代码来源:authapi.py

示例13: get_or_create_key

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def get_or_create_key(filename=None, alg='sha512'):
        request = current.request
        if not filename:
            filename = os.path.join(request.folder, 'private', 'auth.key')
        if os.path.exists(filename):
            key = open(filename, 'r').read().strip()
        else:
            key = alg + ':' + web2py_uuid()
            open(filename, 'w').write(key)
        return key 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:12,代码来源:tools.py

示例14: __str__

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def __str__(self):
        """
        Encrypted self.password and caches it in self.crypted.
        If self.crypt.salt the output is in the format <algorithm>$<salt>$<hash>

        Try get the digest_alg from the key (if it exists)
        else assume the default digest_alg. If not key at all, set key=''

        If a salt is specified use it, if salt is True, set salt to uuid
        (this should all be backward compatible)

        Options:
        key = 'uuid'
        key = 'md5:uuid'
        key = 'sha512:uuid'
        ...
        key = 'pbkdf2(1000,64,sha512):uuid' 1000 iterations and 64 chars length
        """
        if self.crypted:
            return self.crypted
        if self.crypt.key:
            if ':' in self.crypt.key:
                digest_alg, key = self.crypt.key.split(':', 1)
            else:
                digest_alg, key = self.crypt.digest_alg, self.crypt.key
        else:
            digest_alg, key = self.crypt.digest_alg, ''
        if self.crypt.salt:
            if self.crypt.salt is True:
                salt = str(web2py_uuid()).replace('-', '')[-16:]
            else:
                salt = self.crypt.salt
        else:
            salt = ''
        hashed = simple_hash(self.password, key, salt, digest_alg)
        self.crypted = '%s$%s$%s' % (digest_alg, salt, hashed)
        return self.crypted 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:39,代码来源:validators.py

示例15: test_web2py_uuid

# 需要导入模块: from gluon import utils [as 别名]
# 或者: from gluon.utils import web2py_uuid [as 别名]
def test_web2py_uuid(self):
        from uuid import UUID
        self.assertTrue(UUID(web2py_uuid())) 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:5,代码来源:test_utils.py


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