|
@@ -139,6 +139,10 @@ func WsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
config.Logger.Warn(errmsg)
|
|
config.Logger.Warn(errmsg)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // default to unauth
|
|
|
|
|
+ if !auth.WsAuthCheck(conn) {
|
|
|
|
|
+ unauthHandler(conn, r)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// validate password and add to auth session map
|
|
// validate password and add to auth session map
|
|
@@ -168,6 +172,21 @@ func loginHandler(conn *websocket.Conn, msg []byte, payload structs.WsPayload) e
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+// broadcast the unauth payload
|
|
|
|
|
+func unauthHandler(conn *websocket.Conn, r *http.Request) {
|
|
|
|
|
+ blob := structs.UnauthBroadcast
|
|
|
|
|
+ blob.Type = "structure"
|
|
|
|
|
+ blob.AuthLevel = "unauthorized"
|
|
|
|
|
+ blob.Login = struct{
|
|
|
|
|
+ Remainder: 0
|
|
|
|
|
+ }
|
|
|
|
|
+ resp := json.Marshal(blob)
|
|
|
|
|
+ if err := conn.WriteMessage(websocket.TextMessage, respJson); err != nil {
|
|
|
|
|
+ config.Logger.Error(fmt.Sprintf("Error writing response: %v", err))
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// client send:
|
|
// client send:
|
|
|
// {
|
|
// {
|
|
|
// "type": "verify",
|
|
// "type": "verify",
|