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

Fix setting pending request TTL pass the access expiry time #39548

Merged
merged 7 commits into from
Mar 22, 2024

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Mar 19, 2024

part of #35436

recommend reviewing by commit

There's two commits to this PR:

  1. Mostly about preventing users from setting a pending request TTL pass the access expiry time. This led to the access request being in the list pass its access expiry time, and it disappears from the list right after approving.

  2. When a role max_duration isn't set it means max_duration: 0. Before, if a user sent a request with a max duration, this max duration got silently ignored and got set to the session TTL instead. So if my sessionTTL is 12 hours, and user requested a duration of 1hr, it got overwrote to 12 hours. This PR allows requested max duration less than the sessionTTL to be respected.

@zmb3
Copy link
Collaborator

zmb3 commented Mar 19, 2024

Recommend replacing "pass" with "beyond" in the changelog entry.

@kimlisa
Copy link
Contributor Author

kimlisa commented Mar 19, 2024

Recommend replacing "pass" with "beyond" in the changelog entry.

@zmb3 actually, do i need a changelog? i think this bug got introduced with this PR but it didn't get backported yet

edit: removed changelog

@kimlisa
Copy link
Contributor Author

kimlisa commented Mar 20, 2024

friendly ping @jakule @fspmarshall

@kimlisa kimlisa added the no-changelog Indicates that a PR does not require a changelog entry label Mar 21, 2024
Copy link
Contributor

@jakule jakule left a comment

Choose a reason for hiding this comment

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

LGTM, I think we're only missing a test that covers session TTL, max duration and pending expiry.

// calculatePendingRequestTTL calculates the TTL of the Access Request (how long it will await
// approval). request TTL is capped to the smaller value between the const requsetTTL and the
// access request access expiry.
func (m *RequestValidator) calculatePendingRequestTTL(ctx context.Context, identity tlsca.Identity, r types.AccessRequest) (time.Duration, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ctx and identity are not being used in the receiver.

@kimlisa kimlisa force-pushed the lisa/fix-request-pending-ttl branch from 3855f71 to 41961cc Compare March 22, 2024 15:05
@kimlisa kimlisa enabled auto-merge March 22, 2024 16:11
@kimlisa kimlisa force-pushed the lisa/fix-request-pending-ttl branch from f8a13c2 to 9ba1a81 Compare March 22, 2024 18:32
@kimlisa kimlisa force-pushed the lisa/fix-request-pending-ttl branch from 9ba1a81 to 30fa6d0 Compare March 22, 2024 18:57
@r0mant
Copy link
Collaborator

r0mant commented Mar 22, 2024

/excludeflake *

@kimlisa kimlisa added this pull request to the merge queue Mar 22, 2024
Merged via the queue into master with commit 6c16cb5 Mar 22, 2024
34 checks passed
@kimlisa kimlisa deleted the lisa/fix-request-pending-ttl branch March 22, 2024 22:05
@public-teleport-github-review-bot

@kimlisa See the table below for backport results.

Branch Result
branch/v15 Failed

mdwn pushed a commit that referenced this pull request Mar 26, 2024
* Prevent setting pending request TTL pass the access expiry time

* Allow setting max duration less than sessionTTL when role max_duration is not set

* Add more test, clarify comment

* Remove unused params

* Add a test for respecting both pending and max duration request

* Add a fakeclock to fix access request time diff check differences
github-merge-queue bot pushed a commit that referenced this pull request Mar 28, 2024
* Set default access request TTL to 1 week.

The TTL for a request now defaults to 1 week. This will allow reviewers more
time to review an access request before it disappears.

Co-authored-by: Lisa Kim <[email protected]>

* Fix setting pending request TTL pass the access expiry time (#39548)

* Prevent setting pending request TTL pass the access expiry time

* Allow setting max duration less than sessionTTL when role max_duration is not set

* Add more test, clarify comment

* Remove unused params

* Add a test for respecting both pending and max duration request

* Add a fakeclock to fix access request time diff check differences

---------

Co-authored-by: Lisa Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v15 no-changelog Indicates that a PR does not require a changelog entry size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants