fix(sessions): add an expiration date filter to list sessions api (#10384)

# Which Problems Are Solved

The deletion of expired sessions does not go through even though a
success response is returned to the user. These expired and supposedly
deleted (to the user) sessions are then returned when the `ListSessions`
API is called.

This PR fixes this issue by:
1. Allowing deletion of expired sessions
2. Providing an `expiration_date` filter in `ListSession` API to filter
sessions by expiration date

# How the Problems Are Solved

1. Remove expired session check during deletion
2. Add an `expiration_date` filter to the  `ListSession` API

# Additional Changes
N/A

# Additional Context
- Closes #10045

---------

Co-authored-by: Marco A. <marco@zitadel.com>
This commit is contained in:
Gayathri Vijayan
2025-08-07 14:58:59 +02:00
committed by Stefan Benz
parent a2938416d5
commit f13380954f
8 changed files with 280 additions and 13 deletions

View File

@@ -675,6 +675,9 @@ type TimestampQuery struct {
}
func NewTimestampQuery(c Column, value time.Time, compare TimestampComparison) (*TimestampQuery, error) {
if c.isZero() {
return nil, ErrMissingColumn
}
return &TimestampQuery{
Column: c,
Compare: compare,

View File

@@ -342,6 +342,10 @@ func NewCreationDateQuery(datetime time.Time, compare TimestampComparison) (Sear
return NewTimestampQuery(SessionColumnCreationDate, datetime, compare)
}
func NewExpirationDateQuery(datetime time.Time, compare TimestampComparison) (SearchQuery, error) {
return NewTimestampQuery(SessionColumnExpiration, datetime, compare)
}
func prepareSessionQuery() (sq.SelectBuilder, func(*sql.Row) (*Session, string, error)) {
return sq.Select(
SessionColumnID.identifier(),