Hong Phuc
12/27/2024, 3:03 AMSession
plugin, I saw that the providerData
will not be empty if a session provider is configured, meaning the client doesn't need to have a session cookies or session header to trigger the "Session found for" log when the client hit an endpoint. Is this the intended design or a bug? If there is any ktor dev in the channel may you guys have a look? Thanks in advance.
public val Sessions: RouteScopedPlugin<SessionsConfig> = createRouteScopedPlugin("Sessions", ::SessionsConfig) {
val providers = pluginConfig.providers.toList()
application.attributes.put(SessionProvidersKey, providers)
onCall { call ->
// For each call, call each provider and retrieve session data if needed.
// Capture data in the attribute's value
val providerData = providers.associateBy({ it.name }) {
it.receiveSessionData(call)
}
if (providerData.isEmpty()) {
LOGGER.trace("No sessions found for ${call.request.uri}")
} else {
val sessions = providerData.keys.joinToString()
LOGGER.trace("Sessions found for ${call.request.uri}: $sessions")
}
val sessionData = SessionData(providerData)
call.attributes.put(SessionDataKey, sessionData)
}
Aleksei Tirman [JB]
01/02/2025, 1:58 PM