示例#1
0
 def confirm_validate_token(self, token, expiration=3600):
     # 序列化对象
     serilizer = utsr(self.secret_key)
     try:
         res = serilizer.loads(token, salt=self.salt, max_age=expiration)
     except SignatureExpired:  #token过期
         return -1
     except BadSignature:
         return -2
     except:
         return -3
     return res
示例#2
0
    def confirm_validate_token(self, token, expiration=3600):
        '''
		只要令牌没过期,那它就会返回一个用户名,过期时间为3600秒。
		'''
        serializer = utsr(self.security_key)
        return serializer.loads(token, salt=self.salt, max_age=expiration)
示例#3
0
	def confirm_validate_token(self, token, expiration=3600):
		'''
		只要令牌没过期,那它就会返回一个用户名,过期时间为3600秒。
		'''
		serializer = utsr(self.security_key)
		return serializer.loads(token, salt=self.salt, max_age=expiration)
示例#4
0
	def generate_validate_token(self, user_name):
		serializer = utsr(self.security_key)
		return serializer.dumps(user_name, self.salt)
示例#5
0
 def confirm_validate_token(self, token, expiration=3600):
     serializer = utsr(self.security_key)
     # max_age,时间限制,在max_age之前的秒不能用,即3600=60*60,则有效时间为一个小时
     return serializer.loads(token, salt=self.salt, max_age=expiration)
示例#6
0
 def confirm_validate_token(self,token,expiration=3600):
     serializer = utsr(self.security_key)
     return serializer.loads(token,
 salt=self.salt,
 max_age=expiration) 
示例#7
0
 def remove_validate_token(self, token):
     serializer = utsr(self.security_key)
     print(serializer.loads(token, salt=self.salt))
     return serializer.loads(token, salt=self.salt)
示例#8
0
 def confirm_token(cls, token, expiration=3600):
     try:
         serializer = utsr(cls.security_key)
         return serializer.loads(token, salt=cls.salt, max_age=expiration)
     except Exception, e:
         return ''
示例#9
0
 def generate_validate_token(self, username):
     serializer = utsr(self.security_key)
     timeStamp = TimestampSigner(self.security_key)
     username = timeStamp.sign(username)
     return serializer.dumps(username, self.salt)
示例#10
0
 def generate_validate_token(self,uid):
     #序列化对象
     serilizer = utsr(self.secret_key)
     #返回token值
     return serilizer.dumps(uid,self.salt)
示例#11
0
 def generate_validate_token(cls, data):
     serializer = utsr(cls.security_key)
     return serializer.dumps(data, cls.salt)
示例#12
0
 def generate_validate_token(self, username):
     serializer = utsr(self.security_key)
     # convert the serializer to the json form
     return serializer.dumps(username, self.salt)
示例#13
0
 def confirm_validate_token(self,
                            token,
                            expiration=settings.TOKEN_EXPIRATION):
     #验证口令的函数
     serializer = utsr(self.security_key)
     return serializer.loads(token, salt=self.salt, max_age=expiration)
示例#14
0
 def generate_validate_token(self, email):
     serializer = utsr(self.security_key)
     return serializer.dumps(email, self.salt)
示例#15
0
def confirm_validate_token(token,
                           expiration=settings.SMALL_WEIXIN_TOKEN_VALID_TIME):
    serializer = utsr(settings.SECRET_KEY)
    salt = base64.encodestring(settings.SECRET_KEY)
    return serializer.loads(token, salt=salt, max_age=expiration)
示例#16
0
 def remove_validate_token(self, token):
     serializer = utsr(self.security_key)
     timeStamp = TimestampSigner(self.security_key)
     username = serializer.loads(token, salt=self.salt)
     username = timeStamp.unsign(username)
     return username
示例#17
0
def generate_validate_token(openid):
    serializer = utsr(settings.SECRET_KEY)
    salt = base64.encodestring(settings.SECRET_KEY)
    return serializer.dumps(openid, salt)
示例#18
0
 def confirm_validate_token(self,token,expiration=3600*24):
     serializer = utsr(self.security_key)
     return serializer.loads(token,
                       salt=self.salt,
                       max_age=expiration)
示例#19
0
 def confirm_validate_token(self, token):
     serializer = utsr(self.security_key)
     return serializer.loads(
         token,
         salt=self.salt,
     )
示例#20
0
 def generate_validate_token(self, useremail):  # 生成令牌环
     serializer = utsr(self.security_key)
     return serializer.dumps(useremail, self.salt)  # 转换为json格式化数据
示例#21
0
 def generate_validate_token(self, username):
     serializer = utsr(self.security_key)
     return serializer.dumps(username, self.salt)
示例#22
0
 def remove_validate_token(self, token):
     serializer = utsr(self.secret_key)
     return serializer.loads(token, salt=self.salt)