2

I'm pretty sure it is me and not a bug - but assitance in figuring it out would be appreciated

I'm getting a crash in itsdangerous

    def derive_key(self):
        """This method is called to derive the key.  If you're unhappy with
            the default key derivation choices you can override them here.
            Keep in mind that the key derivation in itsdangerous is not intended
            to be used as a security method to make a complex key out of a short
            password.  Instead you should use large random secret keys.
            """
        salt = want_bytes(self.salt)
        if self.key_derivation == 'concat':
            return self.digest_method(salt + self.secret_key).digest()
        elif self.key_derivation == 'django-concat':
            print salt
            print self.secret_key
            return self.digest_method(salt + b'signer' +
>               self.secret_key).digest()

 TypeError: cannot concatenate 'str' and 'NoneType' objects

.env/lib/python2.7/site-packages/itsdangerous.py:336: TypeError and the relevant traceback part is:

flask_app/mgmt_admin.py:28: in login
    return jsonify(success=True, token=user.get_auth_token())
.env/lib/python2.7/site-packages/flask_security/core.py:313: in get_auth_token
    return _security.remember_token_serializer.dumps(data)
.env/lib/python2.7/site-packages/itsdangerous.py:568: in dumps
    rv = self.make_signer(salt).sign(payload)
.env/lib/python2.7/site-packages/itsdangerous.py:414: in sign
    return value + sep + self.get_signature(value)
.env/lib/python2.7/site-packages/itsdangerous.py:349: in get_signature
    key = self.derive_key()

I'm defining the app pretty straight forward:

app.config["SECRET_KEY"] = "testing_key"
app.config["TESTING"] = True

from printing the values I see that:

salt: remember-salt
self.secret_key: None
Boaz
  • 4,864
  • 12
  • 50
  • 90
  • The secret is simply taken from Flask, see https://github.com/mattupstate/flask-security/blob/develop/flask_security/core.py#L255-L258. You appear to have a Flask setup problem somewhere. – Martijn Pieters Aug 08 '15 at 16:47
  • Found the configuration problem. Was initializing the SECRET_KEY too late. Thanks for the pointer on the init function – Boaz Aug 08 '15 at 16:57

0 Answers0