Skip to content

Fix issue with dry-run access_request.spec.expires overwrite#59761

Merged
kopiczko merged 1 commit intomasterfrom
kopiczko/access_req_ttl_bug__client_side
Oct 3, 2025
Merged

Fix issue with dry-run access_request.spec.expires overwrite#59761
kopiczko merged 1 commit intomasterfrom
kopiczko/access_req_ttl_bug__client_side

Conversation

@kopiczko
Copy link
Copy Markdown
Contributor

@kopiczko kopiczko commented Sep 30, 2025

Issue #59606

After access_request.spec.max_duration field was introduced we started to set the spec.expiry to the max_duration if the conditions are met (i.e. max_duration is set and any of the roles allowing the requested resource has .spec.allow.request.max_duration set).

This that if the conditions for setting max_duration are met, access_request.spec.expiry may not (and usually is not) shorter than the current login session duration.

This in turn means that if such a request goes through the dry-run call first, the spec.expiry is set to spec.max_duration and this validation fails.

This PR is a little bit hacky fix dropping the request from the dry-run as there is no easy way out of this situation on the server side. The proper fix should be covered with #46001 (part 2) where we should revisit the whole access request spec and make things less confusing than they are right now.

Backports:

changelog: Fix the issue with automatic access requests for tsh ssh when spec.allow.request.max_duration is set on the requester role.

Comment thread tool/tsh/common/tsh.go Outdated
req.SetRequestReason("Dry run, this request will not be created. If you see this, there is a bug.")
if err := tc.WithRootClusterClient(ctx, func(clt authclient.ClientI) error {
req, err = clt.CreateAccessRequestV2(ctx, req)
_, err := clt.CreateAccessRequestV2(ctx, req)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the effect of not using the request returned by dry run? Or to phrase it differently, do you know why we're using this request in the first place and why does it return request with a wrong TTL set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason why we are making the requests is best described in the original PR description #13586

After some digging I don't think there is any other consequence than computing the requestable roles for the resource ID. So I modified the code to copy the calculated roles back to the original request.

@kopiczko kopiczko force-pushed the kopiczko/access_req_ttl_bug__client_side branch from ba11b34 to 5c0a0d0 Compare October 2, 2025 11:00
@kopiczko kopiczko marked this pull request as ready for review October 2, 2025 11:53
@kopiczko kopiczko requested a review from r0mant October 2, 2025 11:53
@github-actions github-actions bot added size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Oct 2, 2025
@github-actions github-actions bot requested review from espadolini and tcsc October 2, 2025 11:53
@r0mant r0mant requested a review from nklaassen October 2, 2025 17:43
@r0mant
Copy link
Copy Markdown
Collaborator

r0mant commented Oct 2, 2025

@nklaassen Do you mind taking a look at this as well since you worked on this part of the code a couple of years ago?

Comment thread tool/tsh/common/tsh.go
@kopiczko kopiczko force-pushed the kopiczko/access_req_ttl_bug__client_side branch from c5df613 to 72fd243 Compare October 3, 2025 09:12
@kopiczko kopiczko enabled auto-merge October 3, 2025 09:13
@kopiczko kopiczko added this pull request to the merge queue Oct 3, 2025
Merged via the queue into master with commit 4bee24c Oct 3, 2025
39 of 40 checks passed
@kopiczko kopiczko deleted the kopiczko/access_req_ttl_bug__client_side branch October 3, 2025 10:49
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@kopiczko See the table below for backport results.

Branch Result
branch/v17 Create PR
branch/v18 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v17 backport/branch/v18 size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants