这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@coolheavynest
Copy link
Contributor

Always extract the principal from ssh certs.
When --cloud_run enabled, use principal as username for authentication.

Tested with make sshcatests

@google-oss-prow
Copy link

Hi @coolheavynest. Thanks for your PR.

I'm waiting for a GoogleCloudPlatform member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@ericdand ericdand left a comment

Choose a reason for hiding this comment

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

Generally LGTM, just a few style suggestions and a request for a comment or two more. :)

opts.fingerprint = fingerprint;
opts.fp_len = fp_len;

if (cloud_run) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Call me a functional programming purist, but IMO it's usually a bad code smell to reassign a variable outside of a loop.

You've already got the principal variable as a separate variable. Rather than replace user_name blindly here, please check that it's as expected (in this case, you expect it to always be "root," right?) and then call AuthorizeUser on the principal (i.e. call AuthorizeUser(principal, opts, *user_response, cloud_run) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense! I'd put a root check for now. We probably need to support non-root user later but that will happen later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, sounds good. :)

}

if (GetString(&tmp_prin, &tmp_prin_len, principal, NULL) < 0) {
SysLogErr("Failed to read princiapl.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo spotted. ;)

But also, what is this function call doing? It appears to be dissecting the valid_principals field, but it could use a comment explaining why it's valid to call this function with only 3 of 4 parameters set (previously it was only called with all 4, or with 2 of 4).

Copy link
Contributor Author

@coolheavynest coolheavynest Jul 16, 2025

Choose a reason for hiding this comment

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

I could put something like the field valid_principal is a self described/sized buffer. Just like how the follwoing extension field work. But tbh I don't really know hwo this works behind the scene (guess the peek32 does the trick). One thing I am sure about is that without dissecting itself the tmp_prin won't contain the correct content.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding those comments. You're indeed using GetString correctly here, it just needed a bit of explaining. :)

@google-oss-prow google-oss-prow bot added size/L and removed size/M labels Jul 16, 2025
@coolheavynest coolheavynest requested a review from ericdand July 16, 2025 00:51
opts.fingerprint = fingerprint;
opts.fp_len = fp_len;

if (cloud_run) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, sounds good. :)

}

if (GetString(&tmp_prin, &tmp_prin_len, principal, NULL) < 0) {
SysLogErr("Failed to read princiapl.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding those comments. You're indeed using GetString correctly here, it just needed a bit of explaining. :)

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: coolheavynest, ericdand

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ericdand
Copy link
Contributor

/lgtm

@google-oss-prow google-oss-prow bot merged commit ee0251d into GoogleCloudPlatform:master Jul 17, 2025
4 checks passed
ericdand pushed a commit to ericdand/guest-oslogin that referenced this pull request Oct 21, 2025
…latform#164)

* extract the principal from certs when cloud_run enabled

* add comments for cert extractaion and use the principal for AuthorizeUser call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants