feat(session): let a session share expire - #2987
QuentinBisson wants to merge 3 commits into
Conversation
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
EItanya
left a comment
There was a problem hiding this comment.
This feature is looking great! Do you think you can add a ceiling value to the server so that admins can set a maximum valid time
|
I definitely can, thanks for the review :) |
CreateSessionShareRequest takes an optional ttl. The share records expires_at, and token resolution treats an expired share like an unknown token. The owner still lists an expired share so it can be revoked. Signed-off-by: QuentinBisson <quentin@giantswarm.io>
KAGENT_SESSION_SHARE_MAX_TTL (controller.sessionShareMaxTTL) sets the longest ttl a share may request. A longer ttl is refused, and a share created without one receives the maximum. Zero, the default, leaves shares unbounded; a negative value fails controller startup. Signed-off-by: QuentinBisson <quentin@giantswarm.io>
59b1965 to
fd8bcda
Compare
|
I pushed the new maximum valid time :) |
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
| func sameExpiry(payload *timestamppb.Timestamp, column *time.Time) bool { | ||
| if payload == nil || column == nil { | ||
| return payload == nil && column == nil | ||
| } | ||
| return payload.AsTime().Equal(*column) | ||
| } |
There was a problem hiding this comment.
Do we really need this? How could these get out of sync, we have many times we do something similar and we don't have this check
There was a problem hiding this comment.
You are right, this field is only set when we create a share and cannot be updated unless someone does it in the database. I'll simplify this
There was a problem hiding this comment.
The expiry is only stored in the column now, so sameExpiry and the truncation are gone.
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
| not_in: 0 | ||
| }]; | ||
| // How long the share's token grants access, from its creation. Unset means | ||
| // until the share is revoked or the session deleted. |
There was a problem hiding this comment.
unset gets the server max when one is configured
| if ttl < 0 { | ||
| return nil, "", serviceerrors.NewInvalidArgument("share ttl must be positive", nil) | ||
| } | ||
| if s.shareMaxTTL > 0 { |
There was a problem hiding this comment.
enabling the cap later leaves older no-ttl shares unbounded
There was a problem hiding this comment.
That's ok, we're pre-alpha
Problem
A session share's token grants access until the share is revoked or the session is deleted:
CreateSessionShareRequesttakes no lifetime, andGetSessionShareByTokenHashchecks nothing but the hash and the session's state. A client that keeps one share per conversation, for the people the owner lets in, has no way to bound it once the conversation is abandoned. AREAD_WRITEshare can also rename, suspend and delete the session.Change
CreateSessionShareRequest.ttlis optional and must be positive when set. The share recordsexpires_atin a nullablesession_share.expires_atcolumn, added to the unreleased000001baseline.ListSessionSharesstill returns an expired share, so the owner can revoke it.KAGENT_SESSION_SHARE_MAX_TTL(controller.sessionShareMaxTTL) lets admins cap share lifetime. A longerttlis refused withInvalidArgument, and a share created withoutttlreceives the maximum. The default0keeps shares unbounded, so a share created withoutttlbehaves as before.The migration immutability check fails because the column is folded into
000001, as its header asks until release (same as #2970).