Skip to content

Allows TokenVendor to read SA from JWT.SUB #539

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

Merged
merged 4 commits into from
Jun 4, 2025
Merged

Conversation

rastislav-vcrs
Copy link
Contributor

@rastislav-vcrs rastislav-vcrs commented May 29, 2025

Changes implementation of token vendor OAuth2 endpoit to read custom service account information from JWT.SUB instead from request body.

Callers cannot easily add extra information to JWT Token request body as common libraries do not allow to alter the resulting request from outside before it is sent to the server. This change ensures that callers can specify service account in a JWT Claim SUBJECT field which is then considered by TokenVendor when issuing a new token. This field was previously unused by TV and feels very natural to be provided without need for custom claims to be introduced. The device ID information is passed in ISS field of the JWT Request.

RobotAuth implementation provides two code paths for generating JWT tokens for robot. One is used to exclusively communicate with TokenVendor, this one is not modified. The second path is used for obtaining GCP tokens. This path allows setting custom SA in subject claim.

Changes implementation of token vendor OAuth2 endpoit to read
custom service account information from JWT.SUB instead from
request body.

Callers cannot easily add extra information to JWT Token request
body as common libraries do not allow to alter the resulting
request from outside before it is sent to the server. This
change ensures that callers can specify service account in a JWT
Claim SUBJECT field which is then considered by TokenVendor when
issuing a new token. This field was previously unused by TV and
feels very natural to be provided without need for custom claims
to be introduced. The device ID information is passed in ISS field
of the JWT Request.

RobotAuth implementatiuon provides two code paths for generating
JWT tokens for robot. One is used to exclusively communicate with
TokenVendor, this one is not modified. The second path is used
for obtaining GCP tokens. This path allows setting custom SA
in subject claim.
@rastislav-vcrs rastislav-vcrs requested review from ensonic, drigz and Ongy May 29, 2025 17:02
@drigz
Copy link
Contributor

drigz commented May 30, 2025

@rastislav-vcrs is it intentional that we've been added while it's in draft status? not clear if I should review / take a high-level glance / wait for status change.

Copy link
Contributor

@ensonic ensonic left a comment

Choose a reason for hiding this comment

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

@rastislav-vcrs
Copy link
Contributor Author

@rastislav-vcrs is it intentional that we've been added while it's in draft status? not clear if I should review / take a high-level glance / wait for status change.

@drigz It is intentional, so you can take a look and tell me if I overlooked something before we go through the formal approval. So take a high-level look if that direction makes sense from your perspective or not. Thank you.

@ensonic ensonic marked this pull request as ready for review June 3, 2025 09:27
@ensonic ensonic removed the request for review from drigz June 3, 2025 09:27
Copy link
Contributor

@ensonic ensonic left a comment

Choose a reason for hiding this comment

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

Just one nit

@rastislav-vcrs rastislav-vcrs merged commit 4d0c8f3 into main Jun 4, 2025
7 checks passed
@rastislav-vcrs rastislav-vcrs deleted the rko-jwt-sa branch June 4, 2025 14:40
ensonic added a commit that referenced this pull request Jun 17, 2025
ensonic added a commit that referenced this pull request Jun 17, 2025
This reverts commit 4d0c8f3,
https://cloudlogging.app.goo.gl/M1JMPrN1rMJf37Y68

See https://cloudlogging.app.goo.gl/4rL1Y3WxtwGJLmiT9
```
Error: "service account "dev-ensonic1-c-googlers-com" not allowed"
message: "unable to retrieve cloud access token with given JWT"
```

Rollback tested on robco-ensonic:

![image](https://github.com/user-attachments/assets/6d6fd89b-ae15-44fc-8553-69693ee804e6)
rastislav-vcrs added a commit that referenced this pull request Jun 18, 2025
rastislav-vcrs added a commit that referenced this pull request Jun 20, 2025
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.

4 participants