Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix OsLogin authentication when running Packer with GCE service account #105

Merged
merged 3 commits into from
Jul 27, 2022

Conversation

nywilken
Copy link
Contributor

@nywilken nywilken commented Jul 25, 2022

The userinfo.email auth scope is required for obtaining access to the
service account email associated with a token. Previously this scope was
not provided resulting in no email information for the returned token.
The email is needed for properly importing an OsLogin SSH key, thus
causing a regression when using use_os_login with the DefaultTokenSource
authentication method.

Closes #82

Test results before change

=== RUN   TestAccBuilder_DefaultTokenSource
    pluginacc.go:143: Error running plugin acceptance tests: Bad exit code. Logfile: packer_log_googlecompute-packer-default-ts.txt
        Logs can be found at /Users/wilkenrivera/Development/packer-plugin-googlecompute/builder/googlecompute/packer_log_googlecompute-packer-default-ts.txt
        and the acceptance test template can be found at /Users/wilkenrivera/Development/packer-plugin-googlecompute/builder/googlecompute/googlecompute-packer-default-ts.pkr.hcl
--- FAIL: TestAccBuilder_DefaultTokenSource (7.43s)

Test results after change

=== RUN   TestAccBuilder_DefaultTokenSource
--- PASS: TestAccBuilder_DefaultTokenSource (58.56s)

@nywilken nywilken requested a review from a team as a code owner July 25, 2022 15:29
@nywilken nywilken marked this pull request as draft July 25, 2022 15:29
@nywilken nywilken changed the title Add email scope to driver Fix OsLogin authentication when running Packer with GCE service account Jul 25, 2022
The userinfo.email auth scope is required for obtaining access to the
service account email associated with a token. Previously this scope was
not provided resulting in no email information for the returned token.
The email is needed for properly importing an OsLogin SSH key, thus
causing a regression when using `use_os_login` with the
DefaultTokenSource authentication method.

Closes #82
* Add a basic test case for using account_file
* Add test case for oslogin regression

Test results before change
```
=== RUN   TestAccBuilder_DefaultTokenSource
    pluginacc.go:143: Error running plugin acceptance tests: Bad exit code. Logfile: packer_log_googlecompute-packer-default-ts.txt
        Logs can be found at /Users/wilkenrivera/Development/packer-plugin-googlecompute/builder/googlecompute/packer_log_googlecompute-packer-default-ts.txt
        and the acceptance test template can be found at /Users/wilkenrivera/Development/packer-plugin-googlecompute/builder/googlecompute/googlecompute-packer-default-ts.pkr.hcl
--- FAIL: TestAccBuilder_DefaultTokenSource (7.43s)
```

Test results after change
```
=== RUN   TestAccBuilder_DefaultTokenSource
--- PASS: TestAccBuilder_DefaultTokenSource (58.56s)
```
Copy link
Contributor

@sylviamoss sylviamoss left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

@nywilken nywilken merged commit 1dfa194 into main Jul 27, 2022
@nywilken nywilken deleted the fix-oslogin-gce branch July 27, 2022 17:07
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken OSLogin service account authentication on Packer 1.0.10
2 participants