Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

Model - AccessToken - refresh #315

Open
ikb42 opened this issue Feb 12, 2016 · 2 comments
Open

Model - AccessToken - refresh #315

ikb42 opened this issue Feb 12, 2016 · 2 comments

Comments

@ikb42
Copy link

ikb42 commented Feb 12, 2016

This currently does

AccessToken.insert({
      iss: settings.issuer,
      uid: at.uid,
      cid: at.cid,
      ei: at.ei,
      rt: random(settings.refresh_token_bytes_range)(),
      scope: at.scope
    }, function (err, token) {
      if (err) { return callback(err) }

      // we should destroy the current token
      AccessToken.delete(at.at, function (err) {
        if (err) { return callback(err) }
        callback(null, token)
      })
    })

The problem with doing the delete after the insert is that if for example the rt or perhaps even the at is the same as before then it would be deleted right after being created - or worse perhaps parts could be deleted, such as the rt.
In my case this is happening because I am preserving the rt but it could happen in the general case too, although unlikely.

@PetrSnobelt
Copy link

I also have problem with refresh tokens, but I don't see how rt or at can be same. Will be great if you provide unit test.

@ikb42
Copy link
Author

ikb42 commented Sep 28, 2016

Can't remember the reason, but I needed to keep the refresh token the same which lead to a bug for me with my refresh token being deleted after the new access token was created.
With the random refresh token this should not happen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants