Skip to content

Commit

Permalink
WebRDP related changes added.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarathy365 committed May 3, 2020
1 parent 166a223 commit aeabd57
Show file tree
Hide file tree
Showing 15 changed files with 506 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Myrtille.Web/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ public static void RegisterBundles(BundleCollection bundles)
bundles.Add(new Bundle("~/js/xterm/xterm.js").Include("~/js/xterm/xterm.js"));
bundles.Add(new Bundle("~/js/xterm/addons/fit/fit.js").Include("~/js/xterm/addons/fit/fit.js"));
bundles.Add(new Bundle("~/js/audio/audiowebsocket.js").Include("~/js/audio/audiowebsocket.js"));
bundles.Add(new Bundle("~/js/securden.js").Include("~/js/securden.js"));

// styles

// same comments as above; replace "Bundle" by "StyleBundle" for minification

bundles.Add(new Bundle("~/css/Default.css").Include("~/css/Default.css"));
bundles.Add(new Bundle("~/css/xterm.css").Include("~/css/xterm.css"));
bundles.Add(new Bundle("~/css/securden.css").Include("~/css/securden.css"));
}
}
}
52 changes: 49 additions & 3 deletions Myrtille.Web/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
<!-- mobile devices -->
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"/>

<title>RDP Session<%=RemoteSession != null && !RemoteSession.ConnectionService && (RemoteSession.State == RemoteSessionState.Connecting || RemoteSession.State == RemoteSessionState.Connected) && !string.IsNullOrEmpty(RemoteSession.ServerAddress) ? " - " + RemoteSession.ServerAddress.ToString() : ""%></title>
<title>RDP Session<%=RemoteSession != null && !RemoteSession.ConnectionService && (RemoteSession.State == RemoteSessionState.Connecting || RemoteSession.State == RemoteSessionState.Connected) && !string.IsNullOrEmpty(RemoteSession.ServerAddress) ? (" - " + ((!string.IsNullOrEmpty(RemoteSession.UserDomain))? RemoteSession.UserDomain.ToString() + "\\" : "") + RemoteSession.UserName.ToString() + "@" + RemoteSession.ServerAddress.ToString()) : ""%></title>

<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<link rel="stylesheet" type="text/css" href="<%=BundleTable.Bundles.ResolveBundleUrl("~/css/Default.css", true)%>"/>
<link rel="stylesheet" type="text/css" href="<%=BundleTable.Bundles.ResolveBundleUrl("~/css/xterm.css", true)%>"/>
<link rel="stylesheet" type="text/css" href="<%=BundleTable.Bundles.ResolveBundleUrl("~/css/securden.css", true)%>"/>

<script language="javascript" type="text/javascript" src="<%=BundleTable.Bundles.ResolveBundleUrl("~/js/tools/common.js", true)%>"></script>
<script language="javascript" type="text/javascript" src="<%=BundleTable.Bundles.ResolveBundleUrl("~/js/tools/convert.js", true)%>"></script>
Expand All @@ -62,6 +63,7 @@
<script language="javascript" type="text/javascript" src="<%=BundleTable.Bundles.ResolveBundleUrl("~/js/xterm/xterm.js", true)%>"></script>
<script language="javascript" type="text/javascript" src="<%=BundleTable.Bundles.ResolveBundleUrl("~/js/xterm/addons/fit/fit.js", true)%>"></script>
<script language="javascript" type="text/javascript" src="<%=BundleTable.Bundles.ResolveBundleUrl("~/js/audio/audiowebsocket.js", true)%>"></script>
<script language="javascript" type="text/javascript" src="<%=BundleTable.Bundles.ResolveBundleUrl("~/js/securden.js", true)%>"></script>

</head>

Expand Down Expand Up @@ -249,7 +251,7 @@
<img src="img/icons8-menu-horizontal-21.png" alt="show/hide toolbar" width="21px" height="21px" onclick="toggleToolbar();"/>
</div>

<div runat="server" id="toolbar" visible="false" style="visibility:hidden;display:none;">
<div runat="server" id="toolbar" visible="False" style="visibility:hidden;display:none;">

<!-- server info -->
<input type="text" runat="server" id="serverInfo" title="connected server" disabled="disabled"/>
Expand Down Expand Up @@ -312,6 +314,50 @@

</form>

<!-- Securden start block -->
<form id="dummy_form" action="/" method="post">
<input type="hidden" id="dummy_data" value=""/>
</form>

<div runat="server" id="certificateDiv" visible="False">
Certificate accepted.
</div>

<div runat="server" id="loadingDiv" visible="False">
<div class="sec-loading-wrap">
<div class="sec-loading-circle">
<label>●</label>
<label>●</label>
<label>●</label>
<label>●</label>
<label>●</label>
<label>●</label>
</div>
<div class="loading-text">Loading...</div>
</div>
</div>

<div class="container webrdp-container-body" style="display:none;" id="errorMessageDialogEle">
<div id="status" class="error-message-div">
<span id="webrdp-error-icon" class="webrdp-error-icon"></span>
<span id="webrdp-error-text" class="webrdp-error-text">Connection failed.</span>
<span id="webrdp-back-home-btn" class="webrdp-back-btn" onclick="window.close();">Close</span>
</div>
</div>

<div runat="server" id="remoteOperationsDivWrap" visible="False">
<div runat="server" id="remoteOperationsDiv">
<div id="remoteOperationsHeader" title="Click to move"><p>. . .</p><p>. . .</p></div>
<div class="remote-oper-label-text" onclick="sendCtrlAltDel();">Ctrl+Alt+Delete</div>
<div class="remote-oper-label-text" onclick="openPopup('pasteClipboardPopup', 'PasteClipboard.aspx');">Clipboard</div>
<div class="remote-oper-label-text" onclick="disconnectSession();">Disconnect</div>
</div>
<script type="text/javascript">
dragElement(document.getElementById("remoteOperationsDiv"));
</script>
</div>
<!-- Securden end block -->

<script type="text/javascript" language="javascript" defer="defer">
initDisplay();
Expand Down Expand Up @@ -469,4 +515,4 @@

</body>

</html>
</html>
38 changes: 33 additions & 5 deletions Myrtille.Web/Default.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected void Page_Init(
}

// connect from a login page or url
if (!bool.TryParse(ConfigurationManager.AppSettings["LoginEnabled"], out _loginEnabled) || Request.RawUrl.Contains("auth_key"))
if (!bool.TryParse(ConfigurationManager.AppSettings["LoginEnabled"], out _loginEnabled) || (Request.RawUrl.Contains("auth_key") && Request.RawUrl.Contains("referrer")))
{
_loginEnabled = true;
}
Expand Down Expand Up @@ -236,6 +236,10 @@ protected void Page_Load(

ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), script, true);
}
else
{
Response.Write("<script>alert('Session closed.'); window.close();</script>");
}

// cleanup
Session[HttpSessionStateVariables.RemoteSession.ToString()] = null;
Expand Down Expand Up @@ -314,6 +318,11 @@ protected void Page_Load(
// disable the browser cache; in addition to a "noCache" dummy param, with current time, on long-polling and xhr requests
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

if (RemoteSession == null && (string.IsNullOrEmpty(Request["auth_key"]) || string.IsNullOrEmpty(Request["referrer"])))
{
certificateDiv.Visible = true;
}
}

/// <summary>
Expand Down Expand Up @@ -341,6 +350,16 @@ private void UpdateControls()
// remote session toolbar
if (RemoteSession != null && (RemoteSession.State == RemoteSessionState.Connecting || RemoteSession.State == RemoteSessionState.Connected))
{
remoteOperationsDivWrap.Visible = true;
if (RemoteSession.State == RemoteSessionState.Connecting)
{
loadingDiv.Visible = true;
remoteOperationsDiv.Style.Add("display", "none");
}
else
{
remoteOperationsDiv.Style.Add("display", "block");
}
if (_toolbarEnabled)
{
// interacting with the remote session is available to guests with control access, but only the remote session owner should have control on the remote session itself
Expand Down Expand Up @@ -380,7 +399,7 @@ private void UpdateControls()
else
{
// connection params are sent when the login form is submitted, either through http post (the default form method) or http get (querystring)
login.Visible = _loginEnabled;
//login.Visible = _loginEnabled;

// MFA
if (_mfaAuthClient.GetState())
Expand Down Expand Up @@ -562,11 +581,11 @@ private JObject ProcessLaunchRequest(string serverUrl, string authKey)
{
if ((string)response["type"] == "WEB_RDP")
{
returnObj = (JObject)response["details"];
returnObj = response;
}
else
{
Response.Write("<script>alert('Invalid option'); window.close();</script>");
Response.Write("<script>alert('Invalid option.'); window.close();</script>");
}
}
else
Expand Down Expand Up @@ -602,7 +621,9 @@ private bool ConnectRemoteServer()
Response.Write("<script>alert('Invalid command.'); window.close();</script>");
return false;
}
else if (RemoteSession == null)
long userProfileId = 0;
long userSessionId = 0;
if (RemoteSession == null)
{
JObject connectionDetails = ProcessLaunchRequest(Request["referrer"], Request["auth_key"]);
if (connectionDetails == null)
Expand All @@ -611,6 +632,9 @@ private bool ConnectRemoteServer()
}
else
{
//userProfileId = (long)connectionDetails["user_profile_id"];
//userSessionId = (long)connectionDetails["user_session_id"];
connectionDetails = (JObject)connectionDetails["details"];
loginServer = (string)connectionDetails["address"];
loginDomain = "";
loginUser = (string)connectionDetails["username"];
Expand Down Expand Up @@ -762,12 +786,16 @@ private bool ConnectRemoteServer()
Request["cid"] != null
);

RemoteSession.UserProfileId = userProfileId;
RemoteSession.UserSessionId = userSessionId;

// bind the remote session to the current http session
Session[HttpSessionStateVariables.RemoteSession.ToString()] = RemoteSession;

// register the remote session at the application level
var remoteSessions = (IDictionary<Guid, RemoteSession>)Application[HttpApplicationStateVariables.RemoteSessions.ToString()];
remoteSessions.Add(RemoteSession.Id, RemoteSession);

}
catch (Exception exc)
{
Expand Down
36 changes: 36 additions & 0 deletions Myrtille.Web/Default.aspx.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Myrtille.Web/Myrtille.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="css\securden.css" />
<Content Include="css\xterm.css" />
<Content Include="favicon.ico" />
<Content Include="GetHash.aspx" />
Expand All @@ -274,6 +275,7 @@
<Content Include="js\display\canvas.js" />
<Content Include="js\display\divs.js" />
<Content Include="js\display\terminaldiv.js" />
<Content Include="js\securden.js" />
<Content Include="js\network\websocket.js" />
<Content Include="js\tools\convert.js" />
<Content Include="js\tools\common.js" />
Expand Down
4 changes: 2 additions & 2 deletions Myrtille.Web/Web.Base.config
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@
<!-- if the browser window/tab of the remote session owner is closed without disconnecting first, or if the connection is lost, delay (ms) before the remote session is disconnected by the gateway. value must be greater than "browserPulseInterval" defined into config.js (default 10 secs). 0 to disable -->
<add key="ClientIdleTimeout" value="30000"/>
<!-- audio buffer. improves the audio quality at the expense of a slight latency -->
<add key="AudioBuffering" value="true"/>
<add key="AudioBuffering" value="false"/>
<!-- show or hide the toolbar (you can hide it if using your own UI) -->
<add key="ToolbarEnabled" value="true"/>
<add key="ToolbarEnabled" value="false"/>
<!-- connect from a login page or url (you can disable it if using a connection API) -->
<add key="LoginEnabled" value="false"/>
<!-- if login is enabled, url of the login page (change it if using your own page or leave empty to use the default page) -->
Expand Down
4 changes: 2 additions & 2 deletions Myrtille.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@
<!-- if the browser window/tab of the remote session owner is closed without disconnecting first, or if the connection is lost, delay (ms) before the remote session is disconnected by the gateway. value must be greater than "browserPulseInterval" defined into config.js (default 10 secs). 0 to disable -->
<add key="ClientIdleTimeout" value="30000"/>
<!-- audio buffer. improves the audio quality at the expense of a slight latency -->
<add key="AudioBuffering" value="true"/>
<add key="AudioBuffering" value="false"/>
<!-- show or hide the toolbar (you can hide it if using your own UI) -->
<add key="ToolbarEnabled" value="true"/>
<add key="ToolbarEnabled" value="false"/>
<!-- connect from a login page or url (you can disable it if using a connection API) -->
<add key="LoginEnabled" value="false"/>
<!-- if login is enabled, url of the login page (change it if using your own page or leave empty to use the default page) -->
Expand Down
Loading

0 comments on commit aeabd57

Please sign in to comment.