Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webapp-lib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CS-214
ul2024
webapp-lib
Merge requests
!35
server: Protect against cross-origin websocket requests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
server: Protect against cross-origin websocket requests
cpc/websocket-origin
into
main
Overview
19
Commits
4
Pipelines
0
Changes
4
Merged
Clément Pit-Claudel
requested to merge
cpc/websocket-origin
into
main
5 months ago
Overview
14
Commits
4
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
main
version 6
172bcc26
5 months ago
version 5
cfcd863f
5 months ago
version 4
7eb9c770
5 months ago
version 3
383856de
5 months ago
version 2
43c76ef0
5 months ago
version 1
73354969
5 months ago
main (base)
and
latest version
latest version
a8cf4b49
4 commits,
5 months ago
version 6
172bcc26
10 commits,
5 months ago
version 5
cfcd863f
8 commits,
5 months ago
version 4
7eb9c770
7 commits,
5 months ago
version 3
383856de
6 commits,
5 months ago
version 2
43c76ef0
1 commit,
5 months ago
version 1
73354969
1 commit,
5 months ago
4 files
+
61
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
jvm/src/main/scala/cs214/webapp/server/web/WebServerRoutes.scala
+
4
−
1
Options
@@ -7,6 +7,8 @@ import scala.jdk.CollectionConverters.*
import
scala.util.Try
import
cask.endpoints.JsonData
import
decorators.checkOriginHeader
/** HTTP routes of the WebServer */
private
[
server
]
final
case
class
WebServerRoutes
()(
using
cc
:
castor.Context
,
log
:
cask.Logger
)
extends
cask
.
Routes
:
/**
Paths
where
the
static
content
served
by
the
server
is
stored
*/
@@ -72,8 +74,9 @@ private[server] final case class WebServerRoutes()(using cc: castor.Context, log
CreateInstanceResponse
.
Wire
.
encode
(
CreateInstanceResponse
(
appId
))
response
@checkOriginHeader
@cask
.
websocket
(
f
"${Endpoints.WebSocket}/:instanceId/:userId"
)
def
websocket
(
instanceId
:
String
,
userId
:
String
)
:
cask.WebsocketResult
=
def
websocket
(
instanceId
:
String
,
userId
:
String
,
request
:
cask.Request
)
:
cask.WebsocketResult
=
WebServer
.
instances
.
get
(
instanceId
)
match
case
Some
(
app
)
=>
app
.
connect
(
userId
)
case
None
=>
cask
.
Response
(
f
"Unknown instance id $instanceId"
,
400
)
Loading