feat(embed): add backend embed channels with auth and rate limiting (#1657)
Introduce embed_channels storage, publish-token and session-token auth, origin allowlist enforcement, shared Redis rate limiter, public embed API routes, webhooks with SSRF validation, and session listing by embed source.
This commit is contained in:
@@ -222,3 +222,26 @@ func TestSessionRepositoryQueryPagedKeepsClearedIMSessionsOutOfWeb(t *testing.T)
|
||||
require.ElementsMatch(t, []string{active.ID, cleared.ID}, listItemIDsForTest(wecomItems),
|
||||
"wecom must include both the active and the cleared IM session")
|
||||
}
|
||||
|
||||
func TestSessionRepositoryQueryPagedSplitsWebAndEmbedSessions(t *testing.T) {
|
||||
repo, db := newSessionRepositoryForTest(t)
|
||||
require.NoError(t, db.AutoMigrate(&testIMChannelSession{}))
|
||||
ctx := context.Background()
|
||||
|
||||
web := createSessionForTest(t, db, 1, "alice")
|
||||
embed := createSessionForTest(t, db, 1, "alice")
|
||||
require.NoError(t, db.Model(&types.Session{}).Where("id = ?", embed.ID).
|
||||
Update("description", types.EmbedSessionMarkerPrefix+"ch-1").Error)
|
||||
|
||||
webItems, _, err := repo.QueryPaged(ctx, &types.SessionListQuery{
|
||||
TenantID: 1, UserID: "alice", Source: "web", Page: 1, PageSize: 50,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{web.ID}, listItemIDsForTest(webItems))
|
||||
|
||||
embedItems, _, err := repo.QueryPaged(ctx, &types.SessionListQuery{
|
||||
TenantID: 1, UserID: "alice", Source: "embed:ch-1", Page: 1, PageSize: 50,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{embed.ID}, listItemIDsForTest(embedItems))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user