How to use the itsdangerous.TimedJSONWebSignatureSerializer function in itsdangerous

To help you get started, we’ve selected a few itsdangerous examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AsylumConnect / asylum-connect-catalog / app / models / user.py View on Github external
def confirm_account(self, token):
        """Verify that the provided token is for this user's id."""
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except (BadSignature, SignatureExpired):
            return False
        if data.get('confirm') != self.id:
            return False
        self.confirmed = True
        db.session.add(self)
        db.session.commit()
        return True
github enjeyw / Data-App-Boilerplate / server / utils / auth.py View on Github external
def verify_token(token):
    s = Serializer(app.config['SECRET_KEY'])
    try:
        data = s.loads(token)
    except (BadSignature, SignatureExpired):
        return None
    user = models.User.query.get(data['id'])
    return user
github grin-pool / grin-pool / grin-py / grinbase / model / users.py View on Github external
def generate_auth_token(self, key, expiration = 10080):
        s = Serializer(key, expires_in = expiration)
        return s.dumps({ 'id': self.id })
github quanpower / smart-iiot / app / models / user.py View on Github external
def change_email(self, token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            data = s.loads(token.encode('utf-8'))
        except:
            return False
        if data.get('change_email') != self.id:
            return False
        new_email = data.get('new_email')
        if new_email is None:
            return False
        if self.query.filter_by(email=new_email).first() is not None:
            return False
        self.email = new_email
        self.avatar_hash = self.gravatar_hash()
        db.session.add(self)
        return True
github JoneXiong / oejia_weshop / models / wxapp_access_token.py View on Github external
def generate_token(self, sub_domain):
        entry = self.env['wxapp.config'].get_entry(sub_domain)
        secret_key = entry.get_config('secret')
        app_id = entry.get_config('app_id')
        if not secret_key or not app_id:
            raise exceptions.ValidationError('未设置 secret_key 或 appId')

        s = Serializer(secret_key=secret_key, salt=app_id, expires_in=AccessToken._transient_max_hours * 3600)
        timestamp = time.time()
        return s.dumps({'session_key': self.session_key, 'open_id': self.open_id, 'iat': timestamp})
github abessifi / pyatta / api / base_setup.py View on Github external
def verify_auth_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except SignatureExpired:
            return None    # valid token, but expired
        except BadSignature:
            return None    # invalid token
        user = User.query.get(data['id'])
        return user
github mysilver / comp9321 / lab_06_Authentication / auth.py View on Github external
def authenticate_by_token(token):
    if token is None:
        return False
    s = Serializer(SECRET_KEY)
    try:
        username = s.loads(token.encode())
        if username == 'admin':
            return True
    except:
        return False

    return False
github saasforge / open-source-saas-boilerpate / src / shared / db_models / user.py View on Github external
def confirm(self, token):
        s = Serializer(get_config_var('SECRET_KEY'))
        try:
            data = s.loads(token.encode('utf-8'))
        except:
            return False
        if data.get('confirm') != self.id.__str__():
            return False
        self.confirmed = True
        return True
github dternyak / React-Redux-Flask / application / utils / auth.py View on Github external
def verify_token(token):
    s = Serializer(app.config['SECRET_KEY'])
    try:
        data = s.loads(token)
    except (BadSignature, SignatureExpired):
        return None
    return data