add token for authentication

This commit is contained in:
ioxygen 2021-07-29 15:05:58 +08:00
parent b701438617
commit 79691ee949
12 changed files with 22 additions and 20 deletions

View File

@ -3,5 +3,6 @@
<PropertyGroup>
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
</PropertyGroup>
</Project>

View File

@ -57,6 +57,7 @@
"LocalPort": 3389, // windows3389
"RemotePort": 1274 // 访 ip:1274 window
}
]
],
"Token": "TOKEN_FOR_CLIENT_AUTHENTICATION"
}
}

View File

@ -145,7 +145,6 @@ namespace FastTunnel.Core.Client
}
_client.Connect();
_logger.LogInformation("连接成功");
}
catch (Exception)
@ -160,6 +159,7 @@ namespace FastTunnel.Core.Client
{
Webs = ClientConfig.Webs,
SSH = ClientConfig.SSH,
Token = ClientConfig.Attach
},
};

View File

@ -13,5 +13,7 @@ namespace FastTunnel.Core.Config
public IEnumerable<WebConfig> Webs { get; set; }
public IEnumerable<SSHConfig> SSH { get; set; }
public string Attach { get; set; }
}
}

View File

@ -22,5 +22,7 @@ namespace FastTunnel.Core.Config
public bool WebHasNginxProxy { get; set; } = false;
public bool SSHEnabled { get; set; } = false;
public string Token { get; set; }
}
}

View File

@ -31,5 +31,7 @@ namespace FastTunnel.Core.Config
#endregion
bool SSHEnabled { get; set; }
public string Token { get; set; }
}
}

View File

@ -16,5 +16,10 @@ namespace FastTunnel.Core.Models
/// 端口转发隧道列表
/// </summary>
public IEnumerable<SSHConfig> SSH { get; set; }
/// <summary>
/// 客户端附加信息
/// </summary>
public string Token { get; set; }
}
}

View File

@ -16,7 +16,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FastTunel.Core.WebApi\FastTunel.Core.WebApi.csproj" />
<ProjectReference Include="..\FastTunnel.Core\FastTunnel.Core.csproj" />
</ItemGroup>
@ -30,6 +29,4 @@
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties config_4appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -13,7 +13,10 @@ namespace FastTunnel.Server.Filters
{
public bool Authentication(FastTunnelServer server, LogInMassage requet)
{
if (string.IsNullOrEmpty(server.ServerSettings.Token))
return true;
return server.ServerSettings.Token.Equals(requet.Token);
}
}
}

View File

@ -1,6 +0,0 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<div style="text-align:center;padding:50px;">Soming soon!</div>

View File

@ -27,6 +27,8 @@
"WebAllowAccessIps": [],
// SSHSSH.false
"SSHEnabled": true
"SSHEnabled": true,
"Token": "TOKEN_FOR_CLIENT_AUTHENTICATION"
}
}

View File

@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastTunnel.Server", "FastTu
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{0E2A9DA2-26AE-4657-B4C5-3A913E2F5A3C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastTunel.Core.WebApi", "FastTunel.Core.WebApi\FastTunel.Core.WebApi.csproj", "{79B1CA3F-D9E9-45F2-8A50-72084B41A0E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -31,17 +29,12 @@ Global
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEF2E322-9075-4C3F-9967-7EAF0EE28CEB}.Release|Any CPU.Build.0 = Release|Any CPU
{79B1CA3F-D9E9-45F2-8A50-72084B41A0E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79B1CA3F-D9E9-45F2-8A50-72084B41A0E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79B1CA3F-D9E9-45F2-8A50-72084B41A0E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79B1CA3F-D9E9-45F2-8A50-72084B41A0E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C8ADFEB1-59DB-4CE3-8D04-5B547107BCCB} = {0E2A9DA2-26AE-4657-B4C5-3A913E2F5A3C}
{79B1CA3F-D9E9-45F2-8A50-72084B41A0E6} = {0E2A9DA2-26AE-4657-B4C5-3A913E2F5A3C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3D9C6B44-6706-4EE8-9043-802BBE474A2E}