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

[cmd] Add new command token in the CLI tool #375

Merged
merged 14 commits into from Feb 27, 2024
Merged

[cmd] Add new command token in the CLI tool #375

merged 14 commits into from Feb 27, 2024

Conversation

Ruide
Copy link
Collaborator

@Ruide Ruide commented Oct 14, 2023

Command Description: Fetch an attestation report from GCE VM vTPM and send it to Google Attestation Service for an OIDC token.

This command improves usability for a GCE VM user.

This PR replaces closed #368. Branch name changed.

@Ruide
Copy link
Collaborator Author

Ruide commented Oct 14, 2023

@jkl73 @kongoshuu Could you take a look?

@jkl73
Copy link
Contributor

jkl73 commented Oct 17, 2023

LGTM, let's hold the merge until the ek cert is more available on gce instance.

@jkl73
Copy link
Contributor

jkl73 commented Oct 17, 2023

/gcbrun

@deeglaze
Copy link
Contributor

deeglaze commented Jan 4, 2024

Please hold off merging until the internal privacy policy reviewers give the go-ahead, since this is sending data from a user (should be a nonce, but could be anything) to a Google service.

@Ruide Ruide force-pushed the main branch 3 times, most recently from 2a3ddb5 to 209ba23 Compare February 8, 2024 00:34
@Ruide
Copy link
Collaborator Author

Ruide commented Feb 20, 2024

LGTM, let's hold the merge until the ek cert is more available on gce instance.

Hi @jkl73, could we resume the merge? The ek cert is now available on gce instance. And the privacy review is passed.

@jkl73
Copy link
Contributor

jkl73 commented Feb 20, 2024

/gcbrun

@Ruide Ruide force-pushed the main branch 2 times, most recently from 19961e6 to d268962 Compare February 20, 2024 19:50
@Ruide
Copy link
Collaborator Author

Ruide commented Feb 20, 2024

/gcbrun

Copy link
Contributor

@jkl73 jkl73 left a comment

Choose a reason for hiding this comment

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

most comments are nits

cmd/flags.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
cmd/token.go Outdated Show resolved Hide resolved
@Ruide
Copy link
Collaborator Author

Ruide commented Feb 27, 2024

/gcbrun

@jkl73 jkl73 merged commit b22bad0 into google:main Feb 27, 2024
11 checks passed
cmd/token.go Show resolved Hide resolved
Use: "token",
Short: "Attest and fetch an OIDC token from Google Attestation Verification Service.",
Long: `Gather attestation report and send it to Google Attestation Verification Service for an OIDC token.
The OIDC token includes claims regarding the GCE VM, which is verified by Attestation Verification Service. Note that Confidential Computing API needs to be enabled for your account to access Google Attestation Verification Service https://pantheon.corp.google.com/apis/api/confidentialcomputing.googleapis.com.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the external-facing URL is console.cloud.google.com :).

So, https://console.cloud.google.com/apis/api/confidentialcomputing.googleapis.com

return err
}
if gceAK.Cert() == nil {
return errors.New("failed to find gceAKCert on this VM: try creating a new VM or verifying the VM has an EK cert using get-shielded-identity gcloud command. The used key algorithm is: " + usedKeyAlgo)
Copy link
Contributor

Choose a reason for hiding this comment

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

"failed to find GCE AK Certificate on this..."

Comment on lines +85 to +102
// Supports GCE VM. Hard code the AK type. Set GCE AK (EK signing) cert
var gceAK *client.Key
var usedKeyAlgo string
if keyAlgo == tpm2.AlgRSA {
usedKeyAlgo = "RSA"
gceAK, err = client.GceAttestationKeyRSA(rwc)
}
if keyAlgo == tpm2.AlgECC {
usedKeyAlgo = "ECC"
gceAK, err = client.GceAttestationKeyECC(rwc)
}
if err != nil {
return err
}
if gceAK.Cert() == nil {
return errors.New("failed to find gceAKCert on this VM: try creating a new VM or verifying the VM has an EK cert using get-shielded-identity gcloud command. The used key algorithm is: " + usedKeyAlgo)
}
gceAK.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

This has a lot in common with the attest command. We should refactor out common logic.

"github.com/containerd/containerd/namespaces"
"github.com/golang-jwt/jwt/v4"
"github.com/google/go-tpm-tools/client"
"github.com/google/go-tpm-tools/launcher/agent"
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR encodes a dependency on the launcher submodule. We should separate out the agent logic if it will be used between the two.

Ruide added a commit that referenced this pull request Mar 15, 2024
* refactor verifier

* move rest_network_test to agent_test

* resolve token command comments in #375 

* refactor token cmd without depending on launcher agent

* decouple launcher agent from cloud logger

* extract agent common functions to package util

* extract getRestClient function

* extract getRegion function

* fix fake_oauth2_server

* use constants in the fake

* move util to internal

* replace fakeOauth2Credential with os.CreateTemp

* refactor principalFetcher

* add PrincipleFetcher unit test
alexmwu added a commit to alexmwu/go-tpm-tools that referenced this pull request Mar 29, 2024
Breaking Changes:
[launcher/cmd] Refactor verifier for issue google#419
* Unexport `cmd.Instance`, `cmd.MetadataServer`,
  `cmd.NewMetadataServer`.
* Move package `verifier` from launcher to go-tpm-tools.
  * `verifier.Client`, `verifier.Challenge`, etc.
* Move package `fake` from launcher to go-tpm-tools.
  * `fake.Claims`, `fake.NewClient`, etc.
* Move package `rest` from launcher to go-tpm-tools.
  * `rest.NewClient`, `rest.BadRegionError`, etc.

New Features:
[cmd] Add new command token in the CLI tool google#375
[cmd] add records to cloud logging when fetching token from attestation verifier google#417

Bug Fixes:
Statically link binaries built by goreleaser google#425

Other Changes:
Update readme to include the instruction to use the prebuilt gotpm tool. google#424

New Contributors:
@Ruide in google#375
@qinkunbao in google#424
@alexmwu alexmwu mentioned this pull request Mar 29, 2024
alexmwu added a commit to alexmwu/go-tpm-tools that referenced this pull request Mar 29, 2024
Breaking Changes:
[launcher/cmd] Refactor verifier for issue google#419
* Unexport `cmd.Instance`, `cmd.MetadataServer`,
  `cmd.NewMetadataServer`.
* Move package `verifier` from launcher to go-tpm-tools.
  * `verifier.Client`, `verifier.Challenge`, etc.
* Move package `fake` from launcher to go-tpm-tools.
  * `fake.Claims`, `fake.NewClient`, etc.
* Move package `rest` from launcher to go-tpm-tools.
  * `rest.NewClient`, `rest.BadRegionError`, etc.

New Features:
[cmd] Add new command token in the CLI tool google#375
[cmd] add records to cloud logging when fetching token from attestation verifier google#417

Bug Fixes:
Statically link binaries built by goreleaser google#425

Other Changes:
Update readme to gotpm CLi instructions. google#424, google#426

New Contributors:
@Ruide in google#375
@qinkunbao in google#424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants