validateToken function
A middleware that validates the signature and contents of the request token for a Google Cloud service account.
This middleware builds on top of Dart Frog's bearerAuthentication
middleware and provides with token parsing and verification.
It expects to find public keys in the request context and uses them to
verify the token signature.
Don't use this middleware directly but instead use verifyServiceAccount.
Implementation
Middleware validateToken({required bool verifyAudience, String? issuer}) {
return (handler) {
return (context) async {
return handler.use(
_validateToken<Jwk>(
audience: verifyAudience ? context.request.uri.toString() : null,
issuer: issuer,
),
)(context);
};
};
}