Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Oct 29, 2023
1 parent 189930d commit f719903
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 0 deletions.
25 changes: 25 additions & 0 deletions EAVFW.Extensions.EasyAuth.MicrosoftEntraId.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EAVFW.Extensions.EasyAuth.MicrosoftEntraId", "src\EAVFW.Extensions.EasyAuth.MicrosoftEntraId\EAVFW.Extensions.EasyAuth.MicrosoftEntraId.csproj", "{421B39D9-314A-4B5E-8489-A526850EBFC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{421B39D9-314A-4B5E-8489-A526850EBFC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{421B39D9-314A-4B5E-8489-A526850EBFC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{421B39D9-314A-4B5E-8489-A526850EBFC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{421B39D9-314A-4B5E-8489-A526850EBFC0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {032BC2FD-02E8-4D8D-AC63-DA74495A5D01}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>

<Title>EAVFW.Extensions.EasyAuth.MicrosoftEntraId</Title>
<Authors>Poul Kjeldager</Authors>
<Description>EAVFW.Extensions.EasyAuth.MicrosoftEntraId</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/EAVFW/EAVFW.Extensions.EasyAuth.MicrosoftEntraId</RepositoryUrl>
<RemoteEAVFramework>$(UseEAVFromNuget)</RemoteEAVFramework>
</PropertyGroup>

<ItemGroup Condition="$(RemoteEAVFramework) != 'false'">
<ProjectReference Include="$(LocalEAVFrameworkPath)\src\EAVFramework.csproj" />
</ItemGroup>
<ItemGroup Condition="$(RemoteEAVFramework) == 'false'">
<PackageReference Include="EAVFramework" Version="$(EAVFrameworkVersion)" />
</ItemGroup>




<ItemGroup>
<PackageReference Include="IdentityModel" Version="6.2.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using EAVFramework.Authentication;
using IdentityModel.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using System.Linq;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
using static IdentityModel.OidcConstants;

namespace EAVFW.Extensions.EasyAuth.MicrosoftEntraId
{

public class MicrosoftEntraEasyAuthProvider : IEasyAuthProvider
{
private readonly IOptions<MicrosoftEntraIdEasyAuthOptions> _options;

public string AuthenticationName => "MicrosoftEntraId";

public HttpMethod CallbackHttpMethod => HttpMethod.Post;

public bool AutoGenerateRoutes { get; set; } = true;

public MicrosoftEntraEasyAuthProvider() { }

public MicrosoftEntraEasyAuthProvider(IOptions<MicrosoftEntraIdEasyAuthOptions> options)
{
_options = options ?? throw new System.ArgumentNullException(nameof(options));
}

public async Task OnAuthenticate(HttpContext httpcontext, string handleId, string redirectUrl)
{
var email = httpcontext.Request.Query["email"].FirstOrDefault();
var redirectUri = httpcontext.Request.Query["redirectUri"].FirstOrDefault();

// var url =$"{oauthEndpoint}"
var ru = new RequestUrl(_options.Value.AuthorizationUrl);

//var authUri = ru.CreateAuthorizeUrl(_options.Value.ClientI
// responseType: ResponseTypes.Code,
// redirectUri: _options.Value.RedirectUri,
// responseMode: ResponseModes.FormPost ,

// // extra: new Parameters { { "consentId", provider.ExternalId } },
// // codeChallenge: challenge,
// // nonce: nonce,
// // responseMode: ResponseModes.FormPost,
// //scope: "payments:inbound payments:outbound accounts offline_access",

// state: handleId);


}

public Task<(ClaimsPrincipal, string, string)> OnCallback(HttpContext httpcontext)
{
throw new System.NotImplementedException();
}

public RequestDelegate OnSignedOut()
{
throw new System.NotImplementedException();
}

public RequestDelegate OnSignout(string callbackUrl)
{
throw new System.NotImplementedException();
}

public RequestDelegate OnSingleSignOut(string callbackUrl)
{
throw new System.NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using EAVFramework.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace EAVFW.Extensions.EasyAuth.MicrosoftEntraId
{
public static class MicrosoftEntraIdEasyAuthExtensions
{
public static AuthenticatedEAVFrameworkBuilder AddMicrosoftEntraIdEasyAuth(this AuthenticatedEAVFrameworkBuilder builder)
{

builder.AddAuthenticationProvider<MicrosoftEntraEasyAuthProvider, MicrosoftEntraIdEasyAuthOptions,IConfiguration>((options, config) =>
{

});
return builder;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace EAVFW.Extensions.EasyAuth.MicrosoftEntraId
{
public class MicrosoftEntraIdEasyAuthOptions
{
public string AuthorizationUrl { get; set; }
public string ClientId { get; set; }
public string RedirectUri { get; set; }
}
}

0 comments on commit f719903

Please sign in to comment.