Skip to content

New SAML 2.0 implementation for GAM #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
25 changes: 25 additions & 0 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GxSoapHandler", "src\extens
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Functions", "Functions", "{E59B3248-4C26-4DB0-96CB-67437319E22B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gam", "gam", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7E90DCDF-7BE4-4265-9695-FF4D68038267}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotNet", "DotNet", "{B0F8A9AA-0084-49B1-AD4A-238F7035F391}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GamSaml20Net", "src\extensions\gam\src\DotNet\GamSaml20Net\GamSaml20Net.csproj", "{2C35D410-5985-447E-BE75-910AE376B37F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotNetFramework", "DotNetFramework", "{06047D25-57F4-48E0-A519-D38828C33D20}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GamSaml20", "src\extensions\gam\src\DotNetFramework\GamSaml20\GamSaml20.csproj", "{7053921A-6F79-444C-8BCF-5738B9E3D4E3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneXus.Deploy.AzureFunctionsLibraries", "src\extensions\Azure\Libraries\GeneXus.Deploy.AzureFunctionsLibraries.csproj", "{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "kafka", "kafka", "{7CABA1C5-F531-4DC7-AEFC-A33900D15E9D}"
EndProject
Expand Down Expand Up @@ -666,6 +677,14 @@ Global
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}.Release|Any CPU.Build.0 = Release|Any CPU
{2C35D410-5985-447E-BE75-910AE376B37F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C35D410-5985-447E-BE75-910AE376B37F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C35D410-5985-447E-BE75-910AE376B37F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C35D410-5985-447E-BE75-910AE376B37F}.Release|Any CPU.Build.0 = Release|Any CPU
{7053921A-6F79-444C-8BCF-5738B9E3D4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7053921A-6F79-444C-8BCF-5738B9E3D4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7053921A-6F79-444C-8BCF-5738B9E3D4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7053921A-6F79-444C-8BCF-5738B9E3D4E3}.Release|Any CPU.Build.0 = Release|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -812,6 +831,12 @@ Global
{F8959289-4ED7-430C-97B7-FAAA29829708} = {B5C28D81-BCD9-4B29-9B68-EDD81D1018D5}
{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32} = {F8959289-4ED7-430C-97B7-FAAA29829708}
{E59B3248-4C26-4DB0-96CB-67437319E22B} = {41E1D031-799F-484F-85DE-7A30AF1A6FBA}
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {C6AFB6A3-FF0B-4970-B1F1-10BCD3D932B2}
{7E90DCDF-7BE4-4265-9695-FF4D68038267} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{B0F8A9AA-0084-49B1-AD4A-238F7035F391} = {7E90DCDF-7BE4-4265-9695-FF4D68038267}
{2C35D410-5985-447E-BE75-910AE376B37F} = {B0F8A9AA-0084-49B1-AD4A-238F7035F391}
{06047D25-57F4-48E0-A519-D38828C33D20} = {7E90DCDF-7BE4-4265-9695-FF4D68038267}
{7053921A-6F79-444C-8BCF-5738B9E3D4E3} = {06047D25-57F4-48E0-A519-D38828C33D20}
{B3DC39F8-39F0-4200-A971-77E26FFDB2CA} = {41E1D031-799F-484F-85DE-7A30AF1A6FBA}
{7CABA1C5-F531-4DC7-AEFC-A33900D15E9D} = {C6AFB6A3-FF0B-4970-B1F1-10BCD3D932B2}
{26132DE8-B551-4A79-9363-696277DDB803} = {7CABA1C5-F531-4DC7-AEFC-A33900D15E9D}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>GamSaml20NetImpl</AssemblyName>
<Version>17.4.0</Version>
<NoWarn>CA1031, CA1801, SYSLIB0027</NoWarn>
<PackageId>Gam.Saml20.Net</PackageId>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>NETCORE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\Xml\XmlTypes.cs" Link="Utils\Xml\XmlTypes.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\Xml\Element.cs" Link="Utils\Xml\Element.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\Xml\Attribute.cs" Link="Utils\Xml\Attribute.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\DSig.cs" Link="Utils\DSig.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\Encoding.cs" Link="Utils\Encoding.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\Hash.cs" Link="Utils\Hash.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\Keys.cs" Link="Utils\Keys.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\Utils\SamlAssertionUtils.cs" Link="Utils\SamlAssertionUtils.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\IBinding.cs" Link="IBinding.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\PostBinding.cs" Link="PostBinding.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\RedirectBinding.cs" Link="RedirectBinding.cs" />
<Compile Include="..\..\DotNetFramework\GamSaml20\SamlParms.cs" Link="SamlParms.cs" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\dotnetcore\GxClasses\GxClasses.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Utils\Xml\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RootNamespace>GamSaml20</RootNamespace>
<AssemblyName>GamSaml20Impl</AssemblyName>
<NoWarn>CA1031, CA1801, CA1724</NoWarn>
<PackageId>Gam.Saml20</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="StrongNamer" Version="0.2.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\dotnetframework\GxClasses\GxClasses.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Security" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

using System.Security;

namespace GamSaml20
{
[SecuritySafeCritical]
public interface IBinding
{

[SecuritySafeCritical]
void Init(string input);

#if NETCORE

abstract static string Login(SamlParms parms, string relayState);

abstract static string Logout(SamlParms parms, string relayState);
#endif

[SecuritySafeCritical]
bool VerifySignatures(SamlParms parms);
[SecuritySafeCritical]
string GetLoginAssertions();
[SecuritySafeCritical]
string GetLoginAttribute(string name);

[SecuritySafeCritical]
string GetRoles(string name);
[SecuritySafeCritical]
string GetLogoutAssertions();

[SecuritySafeCritical]
bool IsLogout();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System.Security;
using System.Xml;
using GamSaml20.Utils;
using GeneXus;
using log4net;

namespace GamSaml20
{
[SecuritySafeCritical]
public class PostBinding : IBinding
{
private static readonly ILog logger = LogManager.GetLogger(typeof(PostBinding));

private XmlDocument xmlDoc;


/********EXTERNAL OBJECT PUBLIC METHODS - BEGIN ********/

[SecuritySafeCritical]
public PostBinding()
{
logger.Trace("PostBinding constructor");
xmlDoc = null;
}

[SecuritySafeCritical]
public void Init(string xml)
{
logger.Trace("init");
this.xmlDoc = GamSaml20.Utils.SamlAssertionUtils.CanonicalizeXml(xml);
logger.Debug($"Init - XML IdP response: {this.xmlDoc.OuterXml}");
}

[SecuritySafeCritical]
public static string Login(SamlParms parms, string relayState)
{
//not implemented yet
logger.Error("Login - NOT IMPLEMENTED");
return string.Empty;
}

[SecuritySafeCritical]
public static string Logout(SamlParms parms, string relayState)
{
//not implemented yet
logger.Error("Logout - NOT IMPLEMENTED");
return string.Empty;
}


[SecuritySafeCritical]
public bool VerifySignatures(SamlParms parms)
{
return DSig.ValidateSignatures(this.xmlDoc, parms.TrustedCertPath);
}

[SecuritySafeCritical]
public string GetLoginAssertions()
{
logger.Trace("GetLoginAssertions");
return GamSaml20.Utils.SamlAssertionUtils.GetLoginInfo(this.xmlDoc);
}

[SecuritySafeCritical]
public string GetLogoutAssertions()
{
logger.Trace("GetLogoutAssertions");
return GamSaml20.Utils.SamlAssertionUtils.GetLogoutInfo(this.xmlDoc);
}

[SecuritySafeCritical]
public string GetLoginAttribute(string name)
{
logger.Trace("GerLoginAttribute");
return GamSaml20.Utils.SamlAssertionUtils.GetLoginAttribute(this.xmlDoc, name);
}

[SecuritySafeCritical]
public string GetRoles(string name)
{
logger.Trace("GetRoles");
return GamSaml20.Utils.SamlAssertionUtils.GetRoles(this.xmlDoc, name);
}

[SecuritySafeCritical]
public bool IsLogout()
{
return GamSaml20.Utils.SamlAssertionUtils.IsLogout(this.xmlDoc);
}

/********EXTERNAL OBJECT PUBLIC METHODS - END ********/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AllowPartiallyTrustedCallers]
Loading
Loading