Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Experimental/newSaml2
  • Fix/xxxx-migrateLogin
  • Hotfix/1234-handlingMergeToken
  • Hotfix/1354-workingFHLogin
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/1545-emptyUserGraphs
  • Hotfix/2087-efNet6
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameDev
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameUiv2
  • Hotfix/2169-ignoreAuthContext
  • Hotfix/2576-certificatePatch
  • Hotfix/2592-sameProvider
  • Hotfix/2775-dfnCertRollover
  • Hotfix/64-releaseUDE
  • Issue/1833-newLogin
  • Issue/1910-MigrationtoNET6.0
  • Issue/1964-tokenExpiryUIv2
  • Issue/1974-shibbolethLogout
  • Issue/2078-renamingEntitlementAcceptStaff
  • Issue/2078-renamingEntitlementAcceptStaffUiv2
  • Issue/2115-extendParsingPairwiseId
  • Issue/2147-exchangingCoscineCertificate
  • Issue/2147-exchangingCoscineCertificate-step2
  • Issue/2147-exchangingCoscineCertificate-step3
  • Issue/2309-docs
  • Issue/2325-fixApiTokenMerging
  • Issue/3003-stsInstitute
  • Issue/40-rdsQuotaForUKA
  • Product/1149-dfnaai
  • Product/1287-dotnet5Sharepoint
  • Product/1290-dfnaai
  • Product/1414-fhPrivileges
  • Product/1629-onboardingOtherUniversities
  • Product/797-overhaul
  • Product/917-maintenanceFunctionality
  • Sprint/2020-20
  • Sprint/2020-21
  • Sprint/2020-22
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-06
  • Sprint/2021-08
  • Sprint/2021-10
  • Sprint/2021-11
  • Sprint/2021-19
  • Sprint/2021-20
  • Sprint/2021-23
  • Sprint/2022-01
  • Topic/1224-overhaul
  • Topic/1276-DFN-AAIFrontend
  • Topic/1278-dfnAAI
  • Topic/1297-maintenanceBanner
  • Topic/1335-dotnet5Apis
  • Topic/1425-fhPrivileges
  • Topic/1711-extendResourceTypeConfiguration
  • dev
  • gitkeep
  • master
  • top
  • uiv2
  • v1.0.0
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.11.1
  • v1.11.2
  • v1.11.3
  • v1.12.0
  • v1.13.0
  • v1.14.0
  • v1.14.1
  • v1.15.0
  • v1.16.0
  • v1.16.1
  • v1.16.2
  • v1.17.0
  • v1.18.0
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.8.0
  • v1.8.1
  • v1.9.0
  • v1.9.1
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.2.3
  • v2.2.4
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.3.3
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v3.0.0
  • v3.1.0
  • v3.1.1
  • v3.1.2
  • v3.1.3
  • v3.1.4
  • v4.0.0
  • v4.0.1
  • v4.0.2
  • v4.0.3
  • v4.0.4
  • v4.0.5
  • v4.0.6
  • v4.0.7
  • v4.0.8
  • v4.0.9
  • v4.1.0
  • v4.1.1
129 results

Target

Select target project
  • coscine/backend/apis/sts
1 result
Select Git revision
  • Experimental/newSaml2
  • Fix/xxxx-migrateLogin
  • Hotfix/1234-handlingMergeToken
  • Hotfix/1354-workingFHLogin
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/1545-emptyUserGraphs
  • Hotfix/2087-efNet6
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameDev
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameUiv2
  • Hotfix/2169-ignoreAuthContext
  • Hotfix/2576-certificatePatch
  • Hotfix/2592-sameProvider
  • Hotfix/2775-dfnCertRollover
  • Hotfix/64-releaseUDE
  • Issue/1833-newLogin
  • Issue/1910-MigrationtoNET6.0
  • Issue/1964-tokenExpiryUIv2
  • Issue/1974-shibbolethLogout
  • Issue/2078-renamingEntitlementAcceptStaff
  • Issue/2078-renamingEntitlementAcceptStaffUiv2
  • Issue/2115-extendParsingPairwiseId
  • Issue/2147-exchangingCoscineCertificate
  • Issue/2147-exchangingCoscineCertificate-step2
  • Issue/2147-exchangingCoscineCertificate-step3
  • Issue/2309-docs
  • Issue/2325-fixApiTokenMerging
  • Issue/3003-stsInstitute
  • Issue/40-rdsQuotaForUKA
  • Product/1149-dfnaai
  • Product/1287-dotnet5Sharepoint
  • Product/1290-dfnaai
  • Product/1414-fhPrivileges
  • Product/1629-onboardingOtherUniversities
  • Product/797-overhaul
  • Product/917-maintenanceFunctionality
  • Sprint/2020-20
  • Sprint/2020-21
  • Sprint/2020-22
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-06
  • Sprint/2021-08
  • Sprint/2021-10
  • Sprint/2021-11
  • Sprint/2021-19
  • Sprint/2021-20
  • Sprint/2021-23
  • Sprint/2022-01
  • Topic/1224-overhaul
  • Topic/1276-DFN-AAIFrontend
  • Topic/1278-dfnAAI
  • Topic/1297-maintenanceBanner
  • Topic/1335-dotnet5Apis
  • Topic/1425-fhPrivileges
  • Topic/1711-extendResourceTypeConfiguration
  • dev
  • gitkeep
  • master
  • top
  • uiv2
  • v1.0.0
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.11.1
  • v1.11.2
  • v1.11.3
  • v1.12.0
  • v1.13.0
  • v1.14.0
  • v1.14.1
  • v1.15.0
  • v1.16.0
  • v1.16.1
  • v1.16.2
  • v1.17.0
  • v1.18.0
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.8.0
  • v1.8.1
  • v1.9.0
  • v1.9.1
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.2.3
  • v2.2.4
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.3.3
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v3.0.0
  • v3.1.0
  • v3.1.1
  • v3.1.2
  • v3.1.3
  • v3.1.4
  • v4.0.0
  • v4.0.1
  • v4.0.2
  • v4.0.3
  • v4.0.4
  • v4.0.5
  • v4.0.6
  • v4.0.7
  • v4.0.8
  • v4.0.9
  • v4.1.0
  • v4.1.1
129 results
Show changes
Commits on Source (3)
......@@ -43,6 +43,11 @@ namespace Coscine.Api.STS.Controllers
var externalIdModel = new ExternalIdModel();
var entity = info.Principal.FindFirstValue(ShibbolethAttributeMapping.Identifier);
if (string.IsNullOrWhiteSpace(entity))
{
entity = info.Principal.FindFirstValue(ShibbolethAttributeMapping.PairwiseID);
}
var identifier = entity[(entity.IndexOf(">") + 1)..];
identifier = identifier.Substring(0, identifier.IndexOf("<"));
......
......@@ -6,7 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Version>2.2.2</Version></PropertyGroup>
<Version>2.2.3</Version></PropertyGroup>
<PropertyGroup>
<Authors>RWTH Aachen University</Authors>
<Company>IT Center, RWTH Aachen University</Company>
......@@ -36,5 +36,8 @@
<Reference Include="Sustainsys.Saml2">
<HintPath>..\lib\Sustainsys.Saml2.dll</HintPath>
</Reference>
<Reference Include="Sustainsys.Saml2.Metadata">
<HintPath>..\lib\Sustainsys.Saml2.Metadata.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
......@@ -10,6 +10,8 @@ using Sustainsys.Saml2.Metadata;
using System;
using Sustainsys.Saml2.AspNetCore2;
using System.Security.Cryptography.X509Certificates;
using Sustainsys.Saml2.Metadata.Services;
using System.Security.Cryptography;
namespace Coscine.Api.STS
{
......@@ -30,6 +32,8 @@ namespace Coscine.Api.STS
{
base.ConfigureServicesExtensionLate(services);
CryptoConfig.AddAlgorithm(typeof(AesGcmAlgorithm), AesGcmAlgorithm.AesGcm128Identifier);
services.AddDbContext<CoscineDbContext>(
options =>
options.UseInMemoryDatabase("CoscineDbContext")
......
using System;
using System.Security.Cryptography;
namespace Coscine.Api.STS.Utils
{
/// <summary>
/// SymmetricAlgorithm decrypting implementation for http://www.w3.org/2009/xmlenc11#aes128-gcm.
/// This is class is not a general implementation and can only do decryption.
/// </summary>
public class AesGcmAlgorithm : SymmetricAlgorithm
{
public const string AesGcm128Identifier = "http://www.w3.org/2009/xmlenc11#aes128-gcm";
// "For the purposes of this specification, AES-GCM shall be used with a 96 bit Initialization Vector (IV) and a 128 bit Authentication Tag (T)."
// Source: https://www.w3.org/TR/xmlenc-core1/#sec-AES-GCM
public const int NonceSizeInBits = 96;
private const int AuthenticationTagSizeInBits = 128;
public AesGcmAlgorithm()
{
//not sure about 128 keysize?
LegalKeySizesValue = new[] { new KeySizes(128, 128, 0) };
//iv setter checks that iv is the size of a block. Not sure if there should be other block sizes
LegalBlockSizesValue = new[] { new KeySizes(NonceSizeInBits, NonceSizeInBits, 0) };
BlockSizeValue = NonceSizeInBits;
//dummy iv value since it is accessed first in EncryptedXml.DecryptData
IV = new byte[NonceSizeInBits / 8];
}
public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
{
return new AesGcmDecryptor(rgbKey, rgbIV, AuthenticationTagSizeInBits);
}
public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV)
{
throw new NotImplementedException();
}
public override void GenerateIV()
{
throw new NotImplementedException();
}
public override void GenerateKey()
{
throw new NotImplementedException();
}
}
}
using System;
using System.Security.Cryptography;
namespace Coscine.Api.STS.Utils
{
internal class AesGcmDecryptor : ICryptoTransform
{
private readonly byte[] key;
private readonly byte[] nonce;
private readonly int authenticationTagSizeInBits;
public AesGcmDecryptor(byte[] key, byte[] nonce, int authenticationTagSizeInBits)
{
this.key = key;
this.nonce = nonce;
this.authenticationTagSizeInBits = authenticationTagSizeInBits;
}
public bool CanReuseTransform => throw new NotImplementedException();
public bool CanTransformMultipleBlocks => throw new NotImplementedException();
public int InputBlockSize => throw new NotImplementedException();
public int OutputBlockSize => throw new NotImplementedException();
public void Dispose()
{
throw new NotImplementedException();
}
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
{
throw new NotImplementedException();
}
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{
//inspired by https://stackoverflow.com/a/60891115
var tagSize = authenticationTagSizeInBits / 8;
var cipherSize = inputCount - tagSize;
// "The cipher text contains the IV first, followed by the encrypted octets and finally the Authentication tag."
// https://www.w3.org/TR/xmlenc-core1/#sec-AES-GCM
var encryptedData = inputBuffer.AsSpan().Slice(inputOffset, inputCount);
var tag = encryptedData.Slice(encryptedData.Length - tagSize);
var cipherBytes = encryptedData.Slice(0, cipherSize);
var plainBytes = cipherSize < 1024
? stackalloc byte[cipherSize]
: new byte[cipherSize];
using var aes = new AesGcm(key);
aes.Decrypt(nonce, cipherBytes, tag, plainBytes);
return plainBytes.ToArray();
}
}
}
......@@ -7,9 +7,12 @@ namespace Coscine.Api.STS.Utils
public class ShibbolethAttributeMapping
{
public static string Identifier { get; private set; } = "urn:oid:1.3.6.1.4.1.5923.1.1.1.10";
public static string PairwiseID { get; private set; } = "urn:oasis:names:tc:SAML:attribute:pairwise-id";
public static Dictionary<string, string> LabelMapping { get; private set; } = new Dictionary<string, string>()
{
{ "urn:oid:1.3.6.1.4.1.5923.1.1.1.10", "eduPersonTargetedId" },
{ "urn:oasis:names:tc:SAML:attribute:pairwise-id", "pairwise-id" },
{ "urn:oid:2.16.840.1.113730.3.1.241", "DisplayName" },
{ "urn:oid:2.5.4.4", "Surname" },
{ "urn:oid:1.3.6.1.4.1.5540.2.1.96", "Givenname" },
......
No preview for this file type
File added
No preview for this file type