-
Notifications
You must be signed in to change notification settings - Fork 2
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: Add ability to use GitHub OIDC #161
feat: Add ability to use GitHub OIDC #161
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found.
📢 Thoughts on this report? Let us know! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files
☔ View full report in Codecov by Sentry. |
Bundle ReportChanges will increase total bundle size by 183.02kB ⬆️
|
Bundle ReportChanges will increase total bundle size by 446.46kB ⬆️
|
9d5df6b
to
63ac370
Compare
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.
Awesome stuff!! 🚀
Sorry for the long comments - let me know what you think!
url = output.oidc.OIDCEndpoint; | ||
let token = ""; | ||
try { | ||
token = await Core.getIDToken(output.oidc.OIDCEndpoint); |
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.
From the docs, it seems we need to pass to getIDToken()
the audience
to match that as we set in codecov-api
here.
For example in prod that would be either settings.CODECOV_API_URL = https://api.codecov.io or settings.CODECOV_URL = https://codecov.io
Given that I think we should name that variable something like gitHubOIDCTokenAudience
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.
So the audience is the OIDC endpoint, which I can rename to your suggestion. To implement this I followed along with how we have this done up in our action
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.
Ah gotcha. I'd argue the variable over there is misnamed too 🙃 . And arguably relying on a (potentially changing) implementation detail of our codecov-api server.
As in re: "the audience is the OIDC endpoint" - that works as long as the server consuming the JWT token issued through GitHub OIDC validates the JWT expecting the audience to be the same string as the url host. Which may not always hold true, but happens to in our case. Other servers perhaps may be hosted at https://mysubdomain.myhost.com
while the audience is expected to be https://*.myhost.com
or https://myhost.com
or other..
In any case I like what you've got here now - thank you for all this!
* | ||
* Defaults to `https://codecov.io` | ||
*/ | ||
OIDCEndpoint?: 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.
(See other PR comment re: this variable.)
Technically, something like below may be a little clearer:
/**
* The expected audience in the GitHub OIDC JWT token to be validated by the apiUrl.
*
* Defaults to `https://codecov.io`
*/
gitHubOIDCTokenAudience?: string;
The value of this string needs to match that at codecov-api here.
We are never actually hitting this "endpoint" and technically the value of this doesn't need to be a url at all.
packages/bundler-plugin-core/src/utils/__tests__/getPreSignedURL.test.ts
Dismissed
Show dismissed
Hide dismissed
packages/bundler-plugin-core/src/utils/__tests__/getPreSignedURL.test.ts
Dismissed
Show dismissed
Hide dismissed
packages/bundler-plugin-core/src/utils/__tests__/getPreSignedURL.test.ts
Dismissed
Show dismissed
Hide dismissed
packages/bundler-plugin-core/src/utils/__tests__/getPreSignedURL.test.ts
Dismissed
Show dismissed
Hide dismissed
packages/bundler-plugin-core/src/utils/__tests__/getPreSignedURL.test.ts
Dismissed
Show dismissed
Hide dismissed
red( | ||
`Failed to get OIDC token with url:\`${oidc.gitHubOIDCTokenAudience}\`. ${err.message}`, | ||
); | ||
throw new FailedOIDCFetchError( |
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.
we should attach err
as the error.cause
of the FailedOIDCFetchError
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.
Hrm, I'm getting type errors trying to add a second argument to Error
, I see it in the MDN docs. I tried updating the @types/node
however that didn't resolve the issue, any other ideas/guidance 👀
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.
Hmm it might be because of the tsconfig here:
"lib": ["DOM", "DOM.Iterable", "ES2021"], |
try setting it to be ES2022?
if that doesn't work feel free to ignore this and more forward.
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.
ahh yea that did the trick
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.
This is amazing, thank you so much for all this work!!
Description
This PR adds in support for using GitHub OIDC with the bundler plugins.
Closes codecov/engineering-team#2209
Notable Changes
@actions/core
packagegetPreSignedUrl
to grab the token through GitHub OIDC