diff --git a/lib/auth/api.go b/lib/auth/api.go index 2f97b306bae3c..6afdcfbf0f33d 100644 --- a/lib/auth/api.go +++ b/lib/auth/api.go @@ -973,6 +973,9 @@ type Cache interface { // GetAppSession gets an application web session. GetAppSession(context.Context, types.GetAppSessionRequest) (types.WebSession, error) + // ListAppSessions returns a page of application web sessions. + ListAppSessions(ctx context.Context, pageSize int, pageToken, user string) ([]types.WebSession, string, error) + // GetSnowflakeSession gets a Snowflake web session. GetSnowflakeSession(context.Context, types.GetSnowflakeSessionRequest) (types.WebSession, error) diff --git a/lib/cache/cache.go b/lib/cache/cache.go index 0131d2bb8973a..9c2d04694c287 100644 --- a/lib/cache/cache.go +++ b/lib/cache/cache.go @@ -2292,6 +2292,19 @@ func (c *Cache) GetAppSession(ctx context.Context, req types.GetAppSessionReques return sess, trace.Wrap(err) } +// ListAppSessions returns a page of application web sessions. +func (c *Cache) ListAppSessions(ctx context.Context, pageSize int, pageToken, user string) ([]types.WebSession, string, error) { + ctx, span := c.Tracer.Start(ctx, "cache/ListAppSessions") + defer span.End() + + rg, err := readCollectionCache(c, c.collections.appSessions) + if err != nil { + return nil, "", trace.Wrap(err) + } + defer rg.Release() + return rg.reader.ListAppSessions(ctx, pageSize, pageToken, user) +} + // GetSnowflakeSession gets Snowflake web session. func (c *Cache) GetSnowflakeSession(ctx context.Context, req types.GetSnowflakeSessionRequest) (types.WebSession, error) { ctx, span := c.Tracer.Start(ctx, "cache/GetSnowflakeSession") diff --git a/lib/cache/collections.go b/lib/cache/collections.go index 01de74c710864..71d1e5b4b41e2 100644 --- a/lib/cache/collections.go +++ b/lib/cache/collections.go @@ -1466,6 +1466,7 @@ func (appSessionExecutor) getReader(cache *Cache, cacheOK bool) appSessionGetter type appSessionGetter interface { GetAppSession(ctx context.Context, req types.GetAppSessionRequest) (types.WebSession, error) + ListAppSessions(ctx context.Context, pageSize int, pageToken, user string) ([]types.WebSession, string, error) } var _ executor[types.WebSession, appSessionGetter] = appSessionExecutor{}