Skip to content

Commit 36beab6

Browse files
authored
Add files via upload
v1.0
1 parent c9e1c25 commit 36beab6

22 files changed

+1933
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Authenticate users with only random password positions
2+
3+
It is possible that you need to authenticate users with the username and only specific chars that are requested randomly from the password, for example, only type the chars of three, five, and eight position and not the completed password. Next time, different positions could be requested because they are randoms in base of a fixed password length.
4+
5+
>[!NOTE]
6+
>Please, keep in mind that this is only a sketch. UI customization and javascript code could be necessary.
7+
8+
### REST API
9+
In RESTApi_Authentication you are going to find an Azure Function project (Visual Studio). This project expose two functions:
10+
* _positions_ returns three random password positions that the users should type.
11+
* _checking_ verifies the chars (code) that were typed by the user and the required positions.
12+
13+
>[!NOTE]
14+
>Explicit password verification is not implemented in _checking_ function because it is not in the scope of this test. Codes are forced to 2, 4, and 6 values.
15+
>You need to develop your specific function to check that codes.
16+
17+
### Policies
18+
SignUpOrSignIn.xml and SignUpOrSignInWithoutNoAuth.xml are saved in policies folder. The difference between them is that the first one requires a local authentication. The second one does not validate the user so password is not required to the user.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.Azure.Functions.Worker.Builder;
2+
using Microsoft.Extensions.Hosting;
3+
4+
var builder = FunctionsApplication.CreateBuilder(args);
5+
6+
builder.ConfigureFunctionsWebApplication();
7+
8+
// Application Insights isn't enabled by default. See https://aka.ms/AAt8mw4.
9+
// builder.Services
10+
// .AddApplicationInsightsTelemetryWorkerService()
11+
// .ConfigureFunctionsApplicationInsights();
12+
13+
builder.Build().Run();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"profiles": {
3+
"RESTApi_Authentication": {
4+
"commandName": "Project",
5+
"commandLineArgs": "--port 7016",
6+
"launchBrowser": false
7+
}
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"dependencies": {
3+
"appInsights1": {
4+
"type": "appInsights",
5+
"connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING"
6+
},
7+
"storage1": {
8+
"type": "storage",
9+
"connectionId": "AzureWebJobsStorage"
10+
}
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"appInsights1": {
4+
"type": "appInsights.sdk"
5+
}
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"dependencies": {
3+
"appInsights1": {
4+
"restored": true,
5+
"restoreTime": "2025-03-19T12:06:47.2463446Z"
6+
}
7+
},
8+
"parameters": {}
9+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
5+
<OutputType>Exe</OutputType>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
11+
<!-- Application Insights isn't enabled by default. See https://aka.ms/AAt8mw4. -->
12+
<!-- <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" /> -->
13+
<!-- <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.0.0" /> -->
14+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
15+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
16+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
17+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
18+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
19+
</ItemGroup>
20+
<ItemGroup>
21+
<None Update="host.json">
22+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
23+
</None>
24+
<None Update="local.settings.json">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
27+
</None>
28+
</ItemGroup>
29+
<ItemGroup>
30+
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
31+
</ItemGroup>
32+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<_LastSelectedProfileId>C:\GitHub\azureadb2c-only-three-password-characters\RESTApi_Authentication\Properties\PublishProfiles\api2b - Zip Deploy.pubxml</_LastSelectedProfileId>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35828.75 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RESTApi_Authentication", "RESTApi_Authentication.csproj", "{4117C1C9-2E8F-47C2-A742-7AE5CC6B0C66}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4117C1C9-2E8F-47C2-A742-7AE5CC6B0C66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4117C1C9-2E8F-47C2-A742-7AE5CC6B0C66}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4117C1C9-2E8F-47C2-A742-7AE5CC6B0C66}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4117C1C9-2E8F-47C2-A742-7AE5CC6B0C66}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {A736C287-8012-4877-8C6A-E5F4BF02EB18}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace RESTApi_Authentication
8+
{
9+
public class UserDataModel
10+
{
11+
public string position1 { get; set; }
12+
public string position2 { get; set; }
13+
public string position3 { get; set; }
14+
public string code1 { get; set; }
15+
public string code2 { get; set; }
16+
public string code3 { get; set; }
17+
}
18+
}

0 commit comments

Comments
 (0)