flask-login
flask-login copied to clipboard
config keys should be prefixed
Extensions should namespace any values they use in app.config and g with their name (without the "Flask-" prefix). It's usually a good idea to set the default config in init_app as well and access them with []. This makes it easier to reason about what extension manages what config.
Flask-Login currently uses the following keys:
USE_SESSION_FOR_NEXT, defaultFalseREMEMBER_COOKIE_NAME, default"remember_token"REMEMBER_COOKIE_DOMAIN, defaultNoneREMEMBER_COOKIE_PATH, default"/"REMEMBER_COOKIE_SECURE, defaultFalseREMEMBER_COOKIE_HTTPONLY, defaultTrueREMEMBER_COOKIE_SAMESITE, defaultNoneREMEMBER_COOKIE_DURATION, defaulttimedelta(days=365), converts intREMEMBER_COOKIE_REFRESH_EACH_REQUEST, defaultNone, should probably beFalseAUTH_HEADER_NAME, default"Authorization", removed in 0.7 along withheader_loaderSESSION_PROTECTION, defaultself.session_protection, default"basic"FORCE_HOST_FOR_REDIRECTS, defaultNoneLOGIN_DISABLED, defaultFalse
I'm considering whether we should get rid of a lot of the REMEMBER_COOKIE_ config and have it use the same values as Flask's SESSION_ config. It seems the only ones that should ever be different are NAME and DURATION.
In Flask-Security-Too - I have 2 config variables - one for the name, the other is a dict which is passed straight to response.set_cookie.
Such as:
"CSRF_COOKIE_NAME": None, "CSRF_COOKIE": { "samesite": "Strict", "httponly": False, "secure": False, },
Nowadays I'm moving to dicts as well, since app.config.from_prefixed_env supports nested keys. If I get to this eventually, I'll look into it.