@@ -26,7 +26,6 @@ import ai.tock.bot.connector.media.MediaAction
26
26
import ai.tock.bot.connector.media.MediaCard
27
27
import ai.tock.bot.connector.media.MediaCarousel
28
28
import ai.tock.bot.connector.media.MediaMessage
29
- import ai.tock.bot.connector.web.channel.ChannelMongoDAO
30
29
import ai.tock.bot.connector.web.channel.Channels
31
30
import ai.tock.bot.connector.web.send.PostbackButton
32
31
import ai.tock.bot.connector.web.send.UrlButton
@@ -57,6 +56,7 @@ import ai.tock.shared.injector
57
56
import ai.tock.shared.jackson.mapper
58
57
import ai.tock.shared.listProperty
59
58
import ai.tock.shared.longProperty
59
+ import ai.tock.shared.property
60
60
import ai.tock.shared.propertyOrNull
61
61
import ai.tock.shared.provide
62
62
import ai.tock.shared.vertx.vertx
@@ -83,10 +83,12 @@ private const val TOCK_USER_ID = "tock_user_id"
83
83
*/
84
84
val webConnectorType = ConnectorType (WEB_CONNECTOR_ID )
85
85
86
+ private val corsPattern = property(" tock_web_cors_pattern" , " .*" )
86
87
private val sseEnabled = booleanProperty(" tock_web_sse" , false )
87
88
private val sseKeepaliveDelay = longProperty(" tock_web_sse_keepalive_delay" , 10 )
88
89
private val cookieAuth = booleanProperty(" tock_web_cookie_auth" , false )
89
90
private val cookieAuthMaxAge = longProperty(" tock_web_cookie_auth_max_age" , - 1 )
91
+ private val cookieAuthPath = propertyOrNull(" tock_web_cookie_auth_path" )
90
92
91
93
private val webConnectorBridgeEnabled = booleanProperty(" tock_web_connector_bridge_enabled" , false )
92
94
@@ -125,7 +127,7 @@ class WebConnector internal constructor(
125
127
router.route(path)
126
128
.handler(
127
129
CorsHandler .create()
128
- .addRelativeOrigin(" .* " ) // "*"+credentials is rejected by browsers, so we use the equivalent regex instead
130
+ .addRelativeOrigin(corsPattern)
129
131
.allowedMethod(HttpMethod .POST )
130
132
.run {
131
133
if (sseEnabled) allowedMethod(HttpMethod .GET ) else this
@@ -217,6 +219,10 @@ class WebConnector internal constructor(
217
219
cookie.setMaxAge(cookieAuthMaxAge)
218
220
}
219
221
222
+ if (cookieAuthPath != null ) {
223
+ cookie.setPath(cookieAuthPath)
224
+ }
225
+
220
226
context.response().addCookie(cookie)
221
227
222
228
cookieValue
0 commit comments