-
Notifications
You must be signed in to change notification settings - Fork 389
Use ID token from metadata server when sending tasks for extensions #1812
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
*/ | ||
function requestIDToken(client: HttpClient, request: HttpRequestConfig): Promise<string> { | ||
return client.send(request).then((resp) => { | ||
return resp.text || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we explicitly handle the cases where resp.text
is undefined, or is it safe to just return an empty token here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - we probably should throw in this case (since if were requesting an id token & get an empty string, we'll almost certainly get an error later).
: await this.getUrl(resources, FIREBASE_FUNCTION_URL_FORMAT); | ||
task.httpRequest.url = functionUrl; | ||
// When run from a deployed extension, we should be using ComputeEngineCredentials | ||
if (extensionId && this.app.options.credential instanceof ComputeEngineCredential) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use validator.isNonEmptyString(extensionId)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Use an ID token from the compute metadata server when sending tasks from an extension.