Skip to content

Commit 40cff56

Browse files
docs(local-strategy): added revokedtokenrepository reference (#29)
1 parent 46ce084 commit 40cff56

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ export class BearerTokenVerifyProvider
306306
) {}
307307

308308
value(): VerifyFunction.BearerFn {
309-
return async (token) => {
309+
return async token => {
310+
if (token && (await this.revokedTokenRepository.get(token))) {
311+
throw new HttpErrors.Unauthorized('Token Revoked');
312+
}
310313
const user = verify(token, process.env.JWT_SECRET as string, {
311314
issuer: process.env.JWT_ISSUER,
312315
}) as User;
@@ -315,6 +318,7 @@ export class BearerTokenVerifyProvider
315318
}
316319
}
317320
```
321+
The above example has an import and injection of a RevokedTokenRepository, which could be used to keep track of revoked tokens in a datasource like Redis. You can find an implementation of this repository [here](https://github.com/sourcefuse/loopback4-starter/blob/master/src/repositories/revoked-token.repository.ts) and the Redis datasource [here](https://github.com/sourcefuse/loopback4-starter/blob/master/src/datasources/redis.datasource.ts).
318322

319323
Please note the Verify function type _VerifyFunction.BearerFn_
320324

0 commit comments

Comments
 (0)