Initial MVP.
This commit is contained in:
commit
07e08aa5ce
14 changed files with 243 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
**/bin
|
||||||
|
**/obj
|
3
.nyoki
Normal file
3
.nyoki
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"instanceId": "de389c65-2419-4451-b350-a029cded3175"
|
||||||
|
}
|
36
AutoMFA.sln
Normal file
36
AutoMFA.sln
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.31903.59
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{BFFC3FE0-F692-4AE3-B895-C459E949089E}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoMFA.Server", "src\AutoMFA.Server\AutoMFA.Server.csproj", "{60293B32-7FBE-49DB-AE7F-C8B0933B8822}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F1A4AF86-865D-4B0F-A47C-A84F73565A41}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoMFA.Test", "test\AutoMFA.Test\AutoMFA.Test.csproj", "{AEEDBEB2-14F9-4D50-83FD-774035CA00B0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{60293B32-7FBE-49DB-AE7F-C8B0933B8822}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{60293B32-7FBE-49DB-AE7F-C8B0933B8822}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{60293B32-7FBE-49DB-AE7F-C8B0933B8822}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{60293B32-7FBE-49DB-AE7F-C8B0933B8822}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AEEDBEB2-14F9-4D50-83FD-774035CA00B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AEEDBEB2-14F9-4D50-83FD-774035CA00B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AEEDBEB2-14F9-4D50-83FD-774035CA00B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AEEDBEB2-14F9-4D50-83FD-774035CA00B0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{60293B32-7FBE-49DB-AE7F-C8B0933B8822} = {BFFC3FE0-F692-4AE3-B895-C459E949089E}
|
||||||
|
{AEEDBEB2-14F9-4D50-83FD-774035CA00B0} = {F1A4AF86-865D-4B0F-A47C-A84F73565A41}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
15
src/AutoMFA.Server/AutoMFA.Server.csproj
Normal file
15
src/AutoMFA.Server/AutoMFA.Server.csproj
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.3" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
<PackageReference Include="TextCopy" Version="6.2.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
39
src/AutoMFA.Server/Controllers/DataController.cs
Normal file
39
src/AutoMFA.Server/Controllers/DataController.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using AutoMFA.Server.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using TextCopy;
|
||||||
|
|
||||||
|
namespace AutoMFA.Server.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("/data")]
|
||||||
|
public partial class DataController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<DataController> _logger;
|
||||||
|
private readonly IClipboard _clipboard;
|
||||||
|
|
||||||
|
public DataController(ILogger<DataController> logger, IClipboard clipboard)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_clipboard = clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("publish")]
|
||||||
|
public async Task<IActionResult> Publish([FromBody] MessageModel model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("SMS at {}", model.Timestamp);
|
||||||
|
|
||||||
|
string msg = model.MessageRaw;
|
||||||
|
var match = _mBankRegex().Match(msg);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
long token = long.Parse(match.Groups[1].Value);
|
||||||
|
await _clipboard.SetTextAsync(token.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[GeneratedRegex("haslo: (\\d{8})")]
|
||||||
|
private static partial Regex _mBankRegex();
|
||||||
|
}
|
18
src/AutoMFA.Server/Controllers/ServiceController.cs
Normal file
18
src/AutoMFA.Server/Controllers/ServiceController.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace AutoMFA.Server.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("/")]
|
||||||
|
public class ServiceController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet("ping")]
|
||||||
|
public IActionResult Ping()
|
||||||
|
{
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
12
src/AutoMFA.Server/Models/MessageModel.cs
Normal file
12
src/AutoMFA.Server/Models/MessageModel.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutoMFA.Server.Models;
|
||||||
|
|
||||||
|
public class MessageModel
|
||||||
|
{
|
||||||
|
public long Timestamp { get; set; }
|
||||||
|
public string MessageRaw { get; set; } = null!;
|
||||||
|
}
|
16
src/AutoMFA.Server/Program.cs
Normal file
16
src/AutoMFA.Server/Program.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using TextCopy;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
builder.Services.InjectClipboard();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
41
src/AutoMFA.Server/Properties/launchSettings.json
Normal file
41
src/AutoMFA.Server/Properties/launchSettings.json
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:49705",
|
||||||
|
"sslPort": 44307
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://0.0.0.0:8080",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7241;http://localhost:5107",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
src/AutoMFA.Server/appsettings.Development.json
Normal file
8
src/AutoMFA.Server/appsettings.Development.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/AutoMFA.Server/appsettings.json
Normal file
9
src/AutoMFA.Server/appsettings.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
24
test/AutoMFA.Test/AutoMFA.Test.csproj
Normal file
24
test/AutoMFA.Test/AutoMFA.Test.csproj
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
19
test/AutoMFA.Test/RegexTest.cs
Normal file
19
test/AutoMFA.Test/RegexTest.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace AutoMFA.Test;
|
||||||
|
|
||||||
|
public partial class RegexTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void MBankRegex()
|
||||||
|
{
|
||||||
|
var msg = "58 PLN haslo: 21372137 mBank";
|
||||||
|
var match = mBank().Match(msg);
|
||||||
|
|
||||||
|
Assert.True(match.Success);
|
||||||
|
Assert.Equal("21372137", match.Groups[1].Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[GeneratedRegex("haslo: (\\d{8})")]
|
||||||
|
private static partial Regex mBank();
|
||||||
|
}
|
1
test/AutoMFA.Test/Usings.cs
Normal file
1
test/AutoMFA.Test/Usings.cs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
global using Xunit;
|
Loading…
Reference in a new issue