Skip to content
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

auth: Support URL type external account source #239

Merged
merged 5 commits into from
Mar 12, 2024

Conversation

moricho
Copy link
Contributor

@moricho moricho commented Mar 6, 2024

This PR updates google-cloud-auth to support URL type external account source. By this update, Workload Identity Federation for Github Actions can be enabled.

From: #233

@moricho moricho changed the title auth: Support URL type token source auth: Support URL type external account source Mar 7, 2024
@moricho moricho marked this pull request as ready for review March 7, 2024 12:08
@yoshidan yoshidan added the safe to test safe to test label Mar 8, 2024
@@ -95,16 +96,19 @@ impl TokenSource for ExternalAccountTokenSource {
async fn subject_token_source(
audience: Option<String>,
source: CredentialSource,
) -> Result<impl SubjectTokenSource, Error> {
) -> Result<Box<dyn SubjectTokenSource>, Error> {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there any particular reason for changing from impl SubjectTokenSource to Box<dyn SubjectTokenSource>?
There seems to be no need for the change since the function return is limited to AWSSubjectTokenSource and UrlSubjectTokenSource.

(I was looking at this PR and noticed that I can remove the async_trait of the SubjectTokenSource in rust 1.75. Thank you very much.)

Copy link
Contributor Author

@moricho moricho Mar 10, 2024

Choose a reason for hiding this comment

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

@yoshidan
impl SubjectTokenSource can return either AWSSubjectTokenSource or UrlSubjectTokenSource. However, if the type returned changes depending on the CredentialSource within the same function, it becomes impossible to specify the type at compile time, so dynamic dispatch may be required
(I might be misunderstanding something 🙏 )

Actually, the following error occurs when I specify impl SubjectTokenSource at the return position

error[E0308]: mismatched types
   --> foundation/auth/src/token_source/external_account_source/mod.rs:109:12
    |
109 |         Ok(ts)
    |         -- ^^ expected `AWSSubjectTokenSource`, found `UrlSubjectTokenSource`
    |         |
    |         arguments to this enum variant are incorrect
    |

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks. you are right.

@yoshidan yoshidan merged commit 7a46db4 into yoshidan:main Mar 12, 2024
6 checks passed
@moricho moricho deleted the auth/url-cred branch March 12, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants