Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

feat: implements the OAuth token exchange spec based on rfc8693 - #1026

Merged
JustinBeckwith merged 5 commits into
googleapis:byoidfrom
bojeil-google:sts-spec
Aug 11, 2020
Merged

JustinBeckwith merged 5 commits into
googleapis:byoidfrom
bojeil-google:sts-spec

Conversation

@bojeil-google

Copy link
Copy Markdown
Contributor

Implements an internal utility for exchanging OAuth tokens using the rfc/8693 spec.

@bojeil-google
bojeil-google requested a review from a team August 7, 2020 06:45
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 7, 2020
@codecov

codecov Bot commented Aug 7, 2020 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (byoid@3f1368d). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f1368d...2dd4ae5. Read the comment docs.

@JustinBeckwith JustinBeckwith left a comment

Copy link
Copy Markdown
Contributor

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;

Copy link
Copy Markdown
Contributor

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/auth/stscredentials.ts Outdated
actor_token_type?: string;
client_id?: string;
client_secret?: string;
[key: string]: string | undefined;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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(

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

@bcoe

bcoe commented Aug 11, 2020

Copy link
Copy Markdown

@bojeil-google if you rebase with master I believe it will address the docs failures you're seeing.

@JustinBeckwith
JustinBeckwith merged commit 7f8b124 into googleapis:byoid Aug 11, 2020
bcoe pushed a commit that referenced this pull request Feb 6, 2021
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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants