Skip to content

Commit

Permalink
Avoid network authentication calls if unnecessary.
Browse files Browse the repository at this point in the history
If a token is invalid locally, it will also be invalid on
a network call. Network calls only detect if a valid
token has since been revoked.
  • Loading branch information
ewlsh committed Aug 25, 2020
1 parent 4a81876 commit 784534f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/middleware/auth/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export function initializeAuth(auth: auth.Auth) {
const [, idToken] = parts;

auth
.verifyIdToken(idToken, true)
.verifyIdToken(idToken)
// Only confirm that a token hasn't been revoked _after_ we are sure it is a valid token.
.then(() => auth.verifyIdToken(idToken, true))
.then(claims => {
return claims.admin === true;
})
Expand Down

0 comments on commit 784534f

Please sign in to comment.