Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite loop if refresh function returns an invalid token #3

Open
mypark opened this issue Dec 16, 2016 · 4 comments · May be fixed by #6
Open

infinite loop if refresh function returns an invalid token #3

mypark opened this issue Dec 16, 2016 · 4 comments · May be fixed by #6

Comments

@mypark
Copy link

mypark commented Dec 16, 2016

it keeps trying even if the refresh function returns an invalid token or has an error - causing an infinite loop

@cainlevy
Copy link

cainlevy commented Feb 7, 2017

This issue makes prototyping and debugging difficult.

@mmiller42
Copy link

This is a pretty big issue which causes clients to effectively DOS your token endpoint with infinite requests if their session has expired. Fair warning to anyone who uses or plans to use this library in production; even if you patch it, you may be dealing with clients with an outdated copy of your frontend in a long-lived browser session.

@landonwilkins
Copy link

in the case of DOSing yourself, consider adding parameters to the token request to help debug the source of the spam

(lokka version, your project's git sha, whatever)

@ginnwork ginnwork linked a pull request Sep 18, 2020 that will close this issue
@ginnwork
Copy link

ginnwork commented Sep 27, 2020

In case anyone wants a quick fix to prevent DDoS:

import Lokka from 'lokka'
import Transport from 'lokka-transport-jwt-auth'

// Refresh function returns the bearer token string or undefined
import refresh from './refresh'

// Creates a promise that simply resolves after 10 seconds
const delay = () => new Promise((resolve) => setTimeout(resolve, 10 * 1000))

// Waits for 10 seconds before firing the refresh function again
const transport = new Transport(url, async () => refresh() || await delay() || refresh())

// Don't create a new Lokka instance until your refresh authentication is ready
// since the transport immediately attempts to refresh the JWT
const lokka = new Lokka({ transport })

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

Successfully merging a pull request may close this issue.

5 participants