-
Notifications
You must be signed in to change notification settings - Fork 383
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
feat: implements the OAuth token exchange spec based on rfc8693 #1026
Conversation
Codecov Report
@@ Coverage Diff @@
## byoid #1026 +/- ##
========================================
Coverage ? 92.32%
========================================
Files ? 23
Lines ? 4550
Branches ? 524
========================================
Hits ? 4201
Misses ? 349
Partials ? 0 Continue to review full report at Codecov.
|
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 with a few nits
* https://tools.ietf.org/html/rfc8693#section-2.1 | ||
*/ | ||
export interface StsCredentialsOptions { | ||
grantType: string; |
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.
I don't know if the spec lays these out clearly, but I like to pull whatever text they have (if of appropriate value and length) to include in comments above the interface properties. Like:
/**
* REQUIRED. The value "urn:ietf:params:oauth:grant-type:token-exchange" indicates that a token exchange is being performed.
*/
grantType: string;
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.
Done
src/auth/stscredentials.ts
Outdated
actor_token_type?: string; | ||
client_id?: string; | ||
client_secret?: string; | ||
[key: string]: string | undefined; |
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.
That is less than ideal :/ It effectively means any string key is value here with a string value. Is this really an open property bag?
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.
Ok. Currently there is only one non-standard field here. I manually added it.
opts | ||
); | ||
// Successful response. | ||
const stsSuccessfulResponse = response.data; |
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.
I'm curious - why return the response
object along with the data?
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.
Mostly following the existing pattern established here and elsewhere in that file.
} catch (error) { | ||
// Translate error to OAuthError. | ||
if (error.response) { | ||
throw getErrorFromOAuthErrorResponse( |
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.
Just to double check - does this method create a new Error
, or modify the message on the existing? I want to be about not creating a new error, because we want to preserve the original stack trace.
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.
It was creating a new error and not preserving the original error data. I have extended this to preserve the original error data (including stack) but to modify the error message.
Extends `getErrorFromOAuthErrorResponse` to preserve the original error properties.
@bojeil-google if you rebase with |
feat: implements the OAuth token exchange spec based on rfc8693 (#1026) feat: defines ExternalAccountClient abstract class for external_account credentials (#1030) feat: adds service account impersonation to `ExternalAccountClient` (#1041) feat: defines `IdentityPoolClient` used for K8s and Azure workloads (#1042) feat: implements AWS signature version 4 for signing requests (#1047) feat: defines `ExternalAccountClient` used to instantiate external account clients (#1050) feat!: integrates external_accounts with `GoogleAuth` and ADC (#1052) feat: adds text/json credential_source support to IdentityPoolClients (#1059) feat: get AWS region from environment variable (#1067) Co-authored-by: Wilfred van der Deijl <wilfred@vanderdeijl.com> Co-authored-by: Benjamin E. Coe <bencoe@google.com>
Implements an internal utility for exchanging OAuth tokens using the rfc/8693 spec.