Replies: 1 comment
-
Even without the refresh mechanism, you could externalise the auth to a third party such as github, which provides accessToken and refreshToken. Then use the short lived github accessToken to get a surrealdb short lived accessToken so that you can have a session for whatever duration you think is appropriate. Then when that expires or you loose it, to re-create a new one, you can use github's refresh mechanism to get an access token, trade that with surreal, to re-instanciate the session. Bonus is that you don't have to store refresh tokens and do the dance twice with surreal, you just do it once with github and once with surreal. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi team - the following is off the back of a lengthy discussion on SurrealDB's Auth capability and the current situation where "refreshing" of $token is not (yet) available.
Original Discord discussion: https://discord.com/channels/902568124350599239/1303884244313182238
I think I've formulated a solution that achieves the same effect as a Refresh Token, but I'd love to know what others think!
PURPOSE:
Hopefully, I've not unwittingly created some terrifying security vulnerability or hazard in the following so I'd greatly appreciate people's reviews and comments!
NOTE:
SITUATION:
Setting up Authentication for an App that might be similar to a social media app,
eg:
.authenticate
) prior to every request made to the sdb database.PROBLEM:
db.authenticate(token)
) check for each CRUD op, I have to rely on $session being valid - even if the $token was somehow stolen, or needed to destroyed, it can't be modified/invalidated externally and will continue to Validate until session duration expires.SOLUTION:
In hindsight, the setup of SHORT EXPIRY / 20m / using
sessionLast
is perhaps not necessary... Maybe if I wanted additional controls for a "Shorter Expiry" I'd throw those functions inside there🤔BTW, to test this in my client, I used these functions to trigger different things and review results in Surrealist:
Link to this discussion (if continued) in discord: https://discord.com/channels/902568124350599239/1018618253695795261/1306132221203185705
Beta Was this translation helpful? Give feedback.
All reactions