-
I'm working on a standalone App, and using Flask-Security (thanks for maintaining it!) for a backend API. It doesn't seem like Flask-Security supports Refresh Tokens, so I am in a position where I either need to have very long lived Authentication Tokens (not great) or ask the user for their password again (also not great). Is there a preferred way to do this, or is there support possible? I could try writing up my own, but this is not something I'd want to do if I didn't have it (leaving it to the pros, and all that). Also entirely possible I am totally confused, so feel free to point me in a different direction, if so. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
It is true that FS doesn't support the concept of refresh tokens - which is a 'oauth' concept. This sort of depends on what you are trying to do - if this is a web application - then I strongly recommend using session cookies - not auth tokens. If this is a script - then refresh tokens aren't really all that useful? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. I agree with what you've said. As it happens, though, it is neither a web app or a script, it is a standalone desktop executable (think non-mobile game). There may be a way to use sessions for this exe, I will look into what might be possible there. The refresh token seemed like the recommended way to avoid storing password data and allowing short lived auth tokens. Does this have any impact on your thinking, or do you still recommend sessions? Maybe a different way to ask it would be how auth tokens are expected to be used in FS? Short-lived only and then require the username/password to get a new one? Or as long lasting API keys that don't expire? I know FS supports both ways, just curious your thinking on my situation. Thanks again! |
Beta Was this translation helpful? Give feedback.
-
I don't pretend to me an expert here - but I would think that for a desktop app - you would use the local OS 'vault' - e.g. keychain on a mac to store (if the user allows) the credentials (user/pass) - then have your app generate a auth token that is valid say for a day - then once your app gets a 401 it gets the creds from the vault and re-authenticates getting a new auth token. Note that in FS passwords are basically 'revokable' - either by the user changing it or administratively.
I can go into more details if this is interesting. |
Beta Was this translation helpful? Give feedback.
I don't pretend to me an expert here - but I would think that for a desktop app - you would use the local OS 'vault' - e.g. keychain on a mac to store (if the user allows) the credentials (user/pass) - then have your app generate a auth token that is valid say for a day - then once your app gets a 401 it gets the creds from the vault and re-authenticates getting a new auth token. Note that in FS passwords are basically 'revokable' - either by the user changing it or administratively.
A question is - what precisely are you worried about having a long-lived access token? Is the security posture of your app worth the hassle?
You could of course create your own 'refresh token' pretty easily (…