Check for server existence when connecting to a websocket
This commit is contained in:
parent
7f93e5f9d5
commit
fab489d264
|
@ -58,7 +58,7 @@ func ServerExists(c *gin.Context) {
|
|||
u, err := uuid.Parse(c.Param("server"))
|
||||
if err != nil || GetServer(u.String()) == nil {
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{
|
||||
"error": "The requested server does not exist.",
|
||||
"error": "The resource you requested does not exist.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ func Configure() *gin.Engine {
|
|||
// This route is special it sits above all of the other requests because we are
|
||||
// using a JWT to authorize access to it, therefore it needs to be publicly
|
||||
// accessible.
|
||||
router.GET("/api/servers/:server/ws", getServerWebsocket)
|
||||
router.GET("/api/servers/:server/ws", ServerExists, getServerWebsocket)
|
||||
|
||||
// This request is called by another daemon when a server is going to be transferred out.
|
||||
// This request does not need the AuthorizationMiddleware as the panel should never call it
|
||||
// and requests are authenticated through a JWT the panel issues to the other daemon.
|
||||
router.GET("/api/servers/:server/archive", getServerArchive)
|
||||
router.GET("/api/servers/:server/archive", ServerExists, getServerArchive)
|
||||
|
||||
// All of the routes beyond this mount will use an authorization middleware
|
||||
// and will not be accessible without the correct Authorization header provided.
|
||||
|
|
Loading…
Reference in New Issue
Block a user