From da5fbf28254335a0dfa3566379193bc1a3201336 Mon Sep 17 00:00:00 2001 From: Ninja Date: Fri, 22 Nov 2024 23:53:20 +0000 Subject: [PATCH 01/10] - Fix project assets --- .github/workflows/CI-Build.yml | 4 +- GitVersion.yml | 2 +- README.md | 6 +-- src/Secure.SAML/Secure.SAML.csproj | 54 ++++++++----------- .../SHA1SigningAlgorithmTests.cs | 4 +- .../SHA256SigningAlgorithmTests.cs | 4 +- .../SHA512SigningAlgorithmTests.cs | 4 +- .../SamlSignerFactoryTests.cs | 2 +- .../Secure.SAML.Tests.csproj | 12 ++--- 9 files changed, 41 insertions(+), 51 deletions(-) diff --git a/.github/workflows/CI-Build.yml b/.github/workflows/CI-Build.yml index bc11968..f890b99 100644 --- a/.github/workflows/CI-Build.yml +++ b/.github/workflows/CI-Build.yml @@ -53,7 +53,7 @@ jobs: - name: Step-04 Install .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 9.0.x - name: Step-05 Restore dependencies run: dotnet restore @@ -102,7 +102,7 @@ jobs: - name: Step-04 Install .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 9.0.x - name: Step-05 Restore dependencies run: dotnet restore diff --git a/GitVersion.yml b/GitVersion.yml index 2f85197..2ac57c8 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,4 @@ -next-version: 3.0.0 +next-version: 4.0.0 tag-prefix: '[vV]' mode: ContinuousDeployment branches: diff --git a/README.md b/README.md index 0a60884..c2d0b93 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# ninja Secure.SAML v3.0.0 -[![NuGet version](https://badge.fury.io/nu/Secure.SAML.svg)](https://badge.fury.io/nu/Secure.SAML) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/NinjaRocks/Secure.SAML/blob/master/License.md) [![CI](https://github.com/NinjaRocks/Secure.SAML/actions/workflows/CI-Build.yml/badge.svg)](https://github.com/NinjaRocks/Secure.SAML/actions/workflows/CI-Build.yml) [![GitHub Release](https://img.shields.io/github/v/release/ninjarocks/Secure.SAML?logo=github&sort=semver)](https://github.com/ninjarocks/Secure.SAML/releases/latest) -[![CodeQL](https://github.com/NinjaRocks/Secure.SAML/actions/workflows/codeql.yml/badge.svg)](https://github.com/NinjaRocks/Secure.SAML/actions/workflows/codeql.yml) [![.Net](https://img.shields.io/badge/.Net-8.0-blue)](https://dotnet.microsoft.com/en-us/download/dotnet/8) +# ninja Secure.SAML v4.0.0 +[![NuGet version](https://badge.fury.io/nu/Secure.SAML.svg)](https://badge.fury.io/nu/Secure.SAML) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CodeShayk/Secure.SAML/blob/master/License.md) [![CI](https://github.com/CodeShayk/Secure.SAML/actions/workflows/CI-Build.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/CI-Build.yml) [![GitHub Release](https://img.shields.io/github/v/release/CodeShayk/Secure.SAML?logo=github&sort=semver)](https://github.com/CodeShayk/Secure.SAML/releases/latest) +[![CodeQL](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml) [![.Net](https://img.shields.io/badge/.Net-8.0-blue)](https://dotnet.microsoft.com/en-us/download/dotnet/8) .Net library to generate signed SAML 2.0 Response for parameters below- diff --git a/src/Secure.SAML/Secure.SAML.csproj b/src/Secure.SAML/Secure.SAML.csproj index 143e151..6bcd20d 100644 --- a/src/Secure.SAML/Secure.SAML.csproj +++ b/src/Secure.SAML/Secure.SAML.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 Library disable disable @@ -11,56 +11,46 @@ true true Secure.SAML - https://github.com/techninjalabs/Secure.SAML Secure.SAML - © Copyright 2024 Tech Ninja Labs. - Tech Ninja Labs - Tech Ninja Labs - https://github.com/techninjalabs/Secure.SAML + © Copyright 2024 Code Shayk. + Code Shayk + Code Shayk + https://github.com/codeshayk/Secure.SAML Secure.SAML - + https://github.com/CodeShayk/Secure.SAML/wiki .Net library to generate signed SAML 2.0 Response. SAML; SAML Response; SHA1 SAML; SHA256 SAML; SHA512 SAML; SAML Assertion; - 3.0.0 - 3.0.0 + 4.0.0 + 4.0.0 ninja-icon-16.png README.md GIT - v3.0.0 Release Notes: .net 8.0 + v4.0.0 Release Notes: Targets .net 9.0 .Net utility to create Signed SAML 2.0 Response * Supported Signing Algorithms - SHA1, SHA256, SHA512 * Signs Assertion or Response. * Outputs Base64 string or XMLDocument. LICENSE - 3.0.0 + 4.0.0 False + Secure.SAML + True + True - - - True - \ - - - True - \ - - + + True + - + - - True - \ - - - True - \ - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs b/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs index 43a315d..f0023cc 100644 --- a/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs +++ b/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs @@ -19,8 +19,8 @@ public void TestSigningAlgorithmForCorrectSettings() var reference = new Reference(); encryptionMethod.AddTransforms(reference); - Assert.IsTrue(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform); - Assert.IsTrue(reference.TransformChain[1] is XmlDsigExcC14NTransform); + Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); + Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); diff --git a/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs b/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs index 513fe27..c7de5ee 100644 --- a/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs +++ b/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs @@ -19,8 +19,8 @@ public void TestSigningAlgorithmForCorrectSettings() var reference = new Reference(); encryptionMethod.AddTransforms(reference); - Assert.IsTrue(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform); - Assert.IsTrue(reference.TransformChain[1] is XmlDsigExcC14NTransform); + Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); + Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); diff --git a/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs b/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs index 30c11ea..476ebde 100644 --- a/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs +++ b/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs @@ -19,8 +19,8 @@ public void TestSigningAlgorithmForCorrectSettings() var reference = new Reference(); encryptionMethod.AddTransforms(reference); - Assert.IsTrue(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform); - Assert.IsTrue(reference.TransformChain[1] is XmlDsigExcC14NTransform); + Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); + Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); diff --git a/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs b/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs index ac7275b..9ef9fa1 100644 --- a/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs +++ b/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs @@ -14,7 +14,7 @@ public void TestFactoryForReturningCorrectSignerType(SigningAlgorithm encryption { var signerFactory = new SamlSignerFactory(Helper.GetCertificate); var signer = (SamlSigner)signerFactory.Create(encryptionMethod); - Assert.IsAssignableFrom(type, signer.SigningAlgorithm); + Assert.That(type, Is.AssignableFrom(signer.SigningAlgorithm.GetType())); } } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj b/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj index 68f6829..776c119 100644 --- a/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj +++ b/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 disable disable false @@ -17,11 +17,11 @@ - - - - - + + + + + From a6c38d2c7979d704a502df51f6979ec030809c92 Mon Sep 17 00:00:00 2001 From: Ninja Date: Fri, 22 Nov 2024 23:58:19 +0000 Subject: [PATCH 02/10] - fix .net version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2d0b93..83e0cfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ninja Secure.SAML v4.0.0 [![NuGet version](https://badge.fury.io/nu/Secure.SAML.svg)](https://badge.fury.io/nu/Secure.SAML) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CodeShayk/Secure.SAML/blob/master/License.md) [![CI](https://github.com/CodeShayk/Secure.SAML/actions/workflows/CI-Build.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/CI-Build.yml) [![GitHub Release](https://img.shields.io/github/v/release/CodeShayk/Secure.SAML?logo=github&sort=semver)](https://github.com/CodeShayk/Secure.SAML/releases/latest) -[![CodeQL](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml) [![.Net](https://img.shields.io/badge/.Net-8.0-blue)](https://dotnet.microsoft.com/en-us/download/dotnet/8) +[![CodeQL](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml) [![.Net](https://img.shields.io/badge/.Net-9.0-blue)](https://dotnet.microsoft.com/en-us/download/dotnet/9) .Net library to generate signed SAML 2.0 Response for parameters below- From 1393c6714b1fd3c802a6ddb06ca5cb1664373827 Mon Sep 17 00:00:00 2001 From: Ninja Date: Sat, 23 Nov 2024 00:19:22 +0000 Subject: [PATCH 03/10] - fix test --- tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs b/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs index 9ef9fa1..a42767d 100644 --- a/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs +++ b/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs @@ -14,7 +14,7 @@ public void TestFactoryForReturningCorrectSignerType(SigningAlgorithm encryption { var signerFactory = new SamlSignerFactory(Helper.GetCertificate); var signer = (SamlSigner)signerFactory.Create(encryptionMethod); - Assert.That(type, Is.AssignableFrom(signer.SigningAlgorithm.GetType())); + Assert.That(type.IsAssignableFrom(signer.SigningAlgorithm.GetType())); } } } \ No newline at end of file From da220ffdb3c6330ecece2407389c2190d6c3fe65 Mon Sep 17 00:00:00 2001 From: Ninja Date: Sat, 23 Nov 2024 00:27:34 +0000 Subject: [PATCH 04/10] - Fix --- LICENSE | 2 +- src/Secure.SAML/AssemblyInfo.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index 03938ba..daf3b65 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Tech Ninja Labs +Copyright (c) 2024 Code Shayk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Secure.SAML/AssemblyInfo.cs b/src/Secure.SAML/AssemblyInfo.cs index 187c326..7d1863c 100644 --- a/src/Secure.SAML/AssemblyInfo.cs +++ b/src/Secure.SAML/AssemblyInfo.cs @@ -11,15 +11,15 @@ using System; using System.Reflection; -[assembly: System.Reflection.AssemblyCompanyAttribute("Tech Ninja Labs")] +[assembly: System.Reflection.AssemblyCompanyAttribute("Code Shayk")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] [assembly: System.Reflection.AssemblyCopyrightAttribute("2024")] [assembly: System.Reflection.AssemblyDescriptionAttribute(".Net library to generate signed SAML 2.0 Response.")] -[assembly: System.Reflection.AssemblyFileVersionAttribute("3.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("3.0.0")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("4.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("4.0.0")] [assembly: System.Reflection.AssemblyProductAttribute("Secure.SAML")] [assembly: System.Reflection.AssemblyTitleAttribute("Secure.SAML")] -[assembly: System.Reflection.AssemblyVersionAttribute("3.0.0")] -[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/TechNinjaLabs/Secure.SAML")] +[assembly: System.Reflection.AssemblyVersionAttribute("4.0.0")] +[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/Codeshayk/Secure.SAML")] // Generated by the MSBuild WriteCodeFragment class. From 698e5fbd7cb53803ba8711095bdd3736405bc82c Mon Sep 17 00:00:00 2001 From: Ninja Date: Sat, 23 Nov 2024 00:36:53 +0000 Subject: [PATCH 05/10] - fix pipeine --- tests/Secure.SAML.Tests/Helper.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Secure.SAML.Tests/Helper.cs b/tests/Secure.SAML.Tests/Helper.cs index c1faf45..90099f3 100644 --- a/tests/Secure.SAML.Tests/Helper.cs +++ b/tests/Secure.SAML.Tests/Helper.cs @@ -6,6 +6,10 @@ namespace Secure.SAML.Tests { public static class Helper { + /// + /// Get certificate + /// + /// public static X509Certificate2 GetCertificate() { var signedStream = typeof(Helper) From 84848efbe0973d2a9eb32d7233055c3102790e09 Mon Sep 17 00:00:00 2001 From: Ninja Date: Sat, 23 Nov 2024 01:13:16 +0000 Subject: [PATCH 06/10] - cleanup --- .github/workflows/CI-Build.yml | 22 +- GitVersion.yml | 2 +- README.md | 4 +- nuget.config | 4 +- src/Secure.SAML/NameIdFormat.cs | 17 +- src/Secure.SAML/Parameters.cs | 226 ++++--- src/Secure.SAML/Secure.SAML.csproj | 13 +- src/Secure.SAML/SignType.cs | 11 +- src/Secure.SAML/Signing/ISamlSigner.cs | 23 +- src/Secure.SAML/Signing/ISamlSignerFactory.cs | 9 +- src/Secure.SAML/Signing/ISigningAlgorithm.cs | 15 +- src/Secure.SAML/Signing/SamlSignedXml.cs | 27 +- src/Secure.SAML/Signing/SamlSigner.cs | 105 ++-- src/Secure.SAML/Signing/SamlSignerFactory.cs | 43 +- .../Signing/Sha1SigningAlgorithm.cs | 25 +- .../Signing/Sha256SigningAlgorithm.cs | 25 +- .../Signing/Sha512SigningAlgorithm.cs | 25 +- src/Secure.SAML/SigningAlgorithm.cs | 13 +- src/Secure.SAML/v2/ISAML.cs | 11 +- src/Secure.SAML/v2/SAML.cs | 247 ++++---- src/Secure.SAML/v2/SamlExtensions.cs | 67 +- .../v2/Xsds/saml-schema-assertion-2.0.xsd | 266 ++++---- .../v2/Xsds/saml-schema-protocol-2.0.xsd | 278 ++++----- src/Secure.SAML/v2/Xsds/xenc-core-schema.xsd | 240 +++---- .../v2/Xsds/xmldsig-core-schema.xsd | 586 +++++++++--------- tests/Secure.SAML.Tests/Helper.cs | 58 +- tests/Secure.SAML.Tests/SAMLTests.cs | 55 +- .../SHA1SigningAlgorithmTests.cs | 46 +- .../SHA256SigningAlgorithmTests.cs | 46 +- .../SHA512SigningAlgorithmTests.cs | 46 +- tests/Secure.SAML.Tests/SamlExtensionTests.cs | 53 +- .../SamlSignerFactoryTests.cs | 23 +- tests/Secure.SAML.Tests/SamlSignerTests.cs | 23 +- .../Secure.SAML.Tests.csproj | 20 +- 34 files changed, 1300 insertions(+), 1374 deletions(-) diff --git a/.github/workflows/CI-Build.yml b/.github/workflows/CI-Build.yml index f890b99..8f86a3d 100644 --- a/.github/workflows/CI-Build.yml +++ b/.github/workflows/CI-Build.yml @@ -1,11 +1,11 @@ name: CI 'on': pull_request: - types: [opened, reopened, edited, synchronize] + types: [ opened, reopened, edited, synchronize ] paths-ignore: - - "**/*.md" - - "**/*.gitignore" - - "**/*.gitattributes" + - "**/*.md" + - "**/*.gitignore" + - "**/*.gitattributes" jobs: Run-Lint: runs-on: ubuntu-latest @@ -21,7 +21,7 @@ jobs: env: VALIDATE_ALL_CODEBASE: false FILTER_REGEX_INCLUDE: .*src/.* - FILTER_REGEX_EXCLUDE: .*xsds/.* + FILTER_REGEX_EXCLUDE: .*xsds/.* DEFAULT_BRANCH: master GITHUB_TOKEN: '${{ env.github-token }}' Build-Beta: @@ -62,7 +62,7 @@ jobs: - name: Step-06 Build Beta Version run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }} working-directory: '${{ env.working-directory }}' - + - name: Step-07 Test Solution run: dotnet test --configuration Release --no-build --no-restore --verbosity normal working-directory: '${{ env.working-directory }}' @@ -109,7 +109,7 @@ jobs: working-directory: '${{ env.working-directory }}' - name: Step-06 Build Release Version - if: ('startsWith(github.ref, ''refs/heads/release'')') + if: ('startsWith(github.ref, ''refs/heads/release'')') run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.gitversion.outputs.MajorMinorPatch }} working-directory: '${{ env.working-directory }}' @@ -124,9 +124,9 @@ jobs: path: ${{env.working-directory}} retention-days: 1 Package-Artifacts: - needs: [Build-Beta, Build-Release] + needs: [ Build-Beta, Build-Release ] if: | - always() && + always() && (needs.Build-Beta.result == 'success' || needs.Build-Release.result == 'success') runs-on: ubuntu-latest outputs: @@ -140,14 +140,14 @@ jobs: with: name: build-artifact path: ${{env.working-directory}} - + - name: Step-02 Install Github Packages run: dotnet tool install gpr --global - name: Step-03 Publish to Github Packages run: find -name "*.nupkg" -print -exec gpr push -k ${{env.github-token}} {} \; Release: - needs: [Package-Artifacts] + needs: [ Package-Artifacts ] if: | success('Package-Artifacts') && ${{ startsWith(github.head_ref, 'release/') }} diff --git a/GitVersion.yml b/GitVersion.yml index 2ac57c8..be7d083 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -12,4 +12,4 @@ branches: pull-request: tag: beta ignore: - sha: [] \ No newline at end of file + sha: [ ] \ No newline at end of file diff --git a/README.md b/README.md index 83e0cfb..4ee56f8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # ninja Secure.SAML v4.0.0 + [![NuGet version](https://badge.fury.io/nu/Secure.SAML.svg)](https://badge.fury.io/nu/Secure.SAML) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CodeShayk/Secure.SAML/blob/master/License.md) [![CI](https://github.com/CodeShayk/Secure.SAML/actions/workflows/CI-Build.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/CI-Build.yml) [![GitHub Release](https://img.shields.io/github/v/release/CodeShayk/Secure.SAML?logo=github&sort=semver)](https://github.com/CodeShayk/Secure.SAML/releases/latest) [![CodeQL](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml/badge.svg)](https://github.com/CodeShayk/Secure.SAML/actions/workflows/codeql.yml) [![.Net](https://img.shields.io/badge/.Net-9.0-blue)](https://dotnet.microsoft.com/en-us/download/dotnet/9) @@ -34,10 +35,11 @@ var parameters = new Parameters Timestamp = DateTime.Parse("2018-02-27T09:36:44.0665619Z") // Optional, defaults to DateTime.UtcNow }; -var xmlDocument = saml.Create(parameters); // Returns XMLDocument with Signed SAML. +var xmlDocument = saml.Create(parameters); // Returns XMLDocument with Signed SAML. var base64EncodedString = saml.CreateEncoded(parameters); // Returns Base64 encoded string for Signed SAML. ``` + Example IoC Registration ``` diff --git a/nuget.config b/nuget.config index d8ba163..6300cd5 100644 --- a/nuget.config +++ b/nuget.config @@ -1,7 +1,7 @@ - - + + \ No newline at end of file diff --git a/src/Secure.SAML/NameIdFormat.cs b/src/Secure.SAML/NameIdFormat.cs index 13e7f8a..2cd259a 100644 --- a/src/Secure.SAML/NameIdFormat.cs +++ b/src/Secure.SAML/NameIdFormat.cs @@ -1,11 +1,10 @@ -namespace Secure.SAML +namespace Secure.SAML; + +public enum NameIdFormat { - public enum NameIdFormat - { - None, - Unspecified, - Transient, - EmailAddress, - Persistent - } + None, + Unspecified, + Transient, + EmailAddress, + Persistent } \ No newline at end of file diff --git a/src/Secure.SAML/Parameters.cs b/src/Secure.SAML/Parameters.cs index d97fded..a1869ff 100644 --- a/src/Secure.SAML/Parameters.cs +++ b/src/Secure.SAML/Parameters.cs @@ -1,122 +1,118 @@ using System; using System.Collections.Generic; -namespace Secure.SAML +namespace Secure.SAML; + +public class Parameters { - public class Parameters + internal Parameters(string issuer + , string recipient + , string[] audienceRestrictions + , string namedId + , NameIdFormat nameIdFormat + , Dictionary attributes + , SignType signatureType + , int notOnOrAfterInMins + , SigningAlgorithm signingAlgorithm + , Guid samlId = default + , Guid assertionId = default + , DateTime timestamp = default) + { + Issuer = issuer; + Recipient = recipient; + AudienceRestrictions = audienceRestrictions; + NamedId = namedId; + NameIdFormat = nameIdFormat; + Attributes = attributes; + SignatureType = signatureType; + NotOnOrAfterInMinutes = notOnOrAfterInMins; + SignatureType = signatureType; + SamlId = samlId; + AssertionId = assertionId; + Timestamp = timestamp; + SigningAlgorithm = signingAlgorithm; + } + + public Parameters() + { + AssertionId = Guid.NewGuid(); + SamlId = Guid.NewGuid(); + NotOnOrAfterInMinutes = 10; + SignatureType = SignType.Response; + NameIdFormat = NameIdFormat.Unspecified; + Timestamp = DateTime.UtcNow; + SigningAlgorithm = SigningAlgorithm.SHA512; + } + + /// + /// Issuers name + /// + public string Issuer { get; set; } + + /// + /// Recipient name (ConsumerServiceUrl) + /// + public string Recipient { get; set; } + + /// + /// Audience Restrictions + /// + public string[] AudienceRestrictions { get; set; } + + /// + /// Name Identity or subject + /// + public string NamedId { get; set; } + + /// + /// Name Identity Format + /// + public NameIdFormat NameIdFormat { get; set; } + + /// + /// Custom attributes + /// + public Dictionary Attributes { get; set; } + + /// + /// Signature type wether sign response or assertion. + /// + public SignType SignatureType { get; set; } + + /// + /// NotOnOrAfter value in minutes (default is timestamp not added when not supplied) + /// + public int NotOnOrAfterInMinutes { get; } + + /// + /// date time stamp for the message + /// + public DateTime Timestamp { get; } + + /// + /// Signing Algorithm (SHA512, SHA256, SHA1). Default is SHA512. + /// + public SigningAlgorithm SigningAlgorithm { get; set; } + + /// + /// Saml Id + /// + internal Guid SamlId { get; set; } + + /// + /// Assertion Id + /// + internal Guid AssertionId { get; set; } + + public bool IsSignedResponse => SignatureType == SignType.Response; + + public void Validate() { - internal Parameters(string issuer - , string recipient - , string[] audienceRestrictions - , string namedId - , NameIdFormat nameIdFormat - , Dictionary attributes - , SignType signatureType - , int notOnOrAfterInMins - , SigningAlgorithm signingAlgorithm - , Guid samlId = default(Guid) - , Guid assertionId = default(Guid) - , DateTime timestamp = default(DateTime)) - { - Issuer = issuer; - Recipient = recipient; - AudienceRestrictions = audienceRestrictions; - NamedId = namedId; - NameIdFormat = nameIdFormat; - Attributes = attributes; - SignatureType = signatureType; - NotOnOrAfterInMinutes = notOnOrAfterInMins; - SignatureType = signatureType; - SamlId = samlId; - AssertionId = assertionId; - Timestamp = timestamp; - SigningAlgorithm = signingAlgorithm; - } - - public Parameters() - { - AssertionId = Guid.NewGuid(); - SamlId = Guid.NewGuid(); - NotOnOrAfterInMinutes = 10; - SignatureType = SignType.Response; - NameIdFormat = NameIdFormat.Unspecified; - Timestamp = DateTime.UtcNow; - SigningAlgorithm = SigningAlgorithm.SHA512; - } - - /// - /// Issuers name - /// - public string Issuer { get; set; } - - /// - /// Recipient name (ConsumerServiceUrl) - /// - public string Recipient { get; set; } - - /// - /// Audience Restrictions - /// - public string[] AudienceRestrictions { get; set; } - - /// - /// Name Identity or subject - /// - public string NamedId { get; set; } - - /// - /// Name Identity Format - /// - public NameIdFormat NameIdFormat { get; set; } - - /// - /// Custom attributes - /// - public Dictionary Attributes { get; set; } - - /// - /// Signature type wether sign response or assertion. - /// - public SignType SignatureType { get; set; } - - /// - /// NotOnOrAfter value in minutes (default is timestamp not added when not supplied) - /// - public int NotOnOrAfterInMinutes { get; } - - /// - /// date time stamp for the message - /// - public DateTime Timestamp { get; } - - /// - /// Signing Algorithm (SHA512, SHA256, SHA1). Default is SHA512. - /// - public SigningAlgorithm SigningAlgorithm { get; set; } - - /// - /// Saml Id - /// - internal Guid SamlId { get; set; } - - /// - /// Assertion Id - /// - internal Guid AssertionId { get; set; } - - public void Validate() - { - if (string.IsNullOrWhiteSpace(Issuer)) - throw new ArgumentNullException($"{nameof(Issuer)} is null"); - if (string.IsNullOrWhiteSpace(Recipient)) - throw new ArgumentNullException($"{nameof(Recipient)} is null"); - if (string.IsNullOrWhiteSpace(NamedId)) - throw new ArgumentNullException($"{nameof(NamedId)} is null"); - } - - public bool IsSignedResponse - { - get { return SignatureType == SignType.Response; } - } + if (string.IsNullOrWhiteSpace(Issuer)) + throw new ArgumentNullException($"{nameof(Issuer)} is null"); + if (string.IsNullOrWhiteSpace(Recipient)) + throw new ArgumentNullException($"{nameof(Recipient)} is null"); + if (string.IsNullOrWhiteSpace(NamedId)) + throw new ArgumentNullException($"{nameof(NamedId)} is null"); } } \ No newline at end of file diff --git a/src/Secure.SAML/Secure.SAML.csproj b/src/Secure.SAML/Secure.SAML.csproj index 6bcd20d..f75ff1e 100644 --- a/src/Secure.SAML/Secure.SAML.csproj +++ b/src/Secure.SAML/Secure.SAML.csproj @@ -26,10 +26,11 @@ README.md GIT v4.0.0 Release Notes: Targets .net 9.0 - .Net utility to create Signed SAML 2.0 Response + .Net utility to create Signed SAML 2.0 Response * Supported Signing Algorithms - SHA1, SHA256, SHA512 * Signs Assertion or Response. - * Outputs Base64 string or XMLDocument. + * Outputs Base64 string or XMLDocument. + LICENSE 4.0.0 False @@ -42,11 +43,11 @@ True - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Secure.SAML/SignType.cs b/src/Secure.SAML/SignType.cs index efc215a..7d44d0a 100644 --- a/src/Secure.SAML/SignType.cs +++ b/src/Secure.SAML/SignType.cs @@ -1,8 +1,7 @@ -namespace Secure.SAML +namespace Secure.SAML; + +public enum SignType { - public enum SignType - { - Response, - Assertion - }; + Response, + Assertion } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/ISamlSigner.cs b/src/Secure.SAML/Signing/ISamlSigner.cs index 4abe682..6c5d8c0 100644 --- a/src/Secure.SAML/Signing/ISamlSigner.cs +++ b/src/Secure.SAML/Signing/ISamlSigner.cs @@ -1,16 +1,15 @@ using System.Xml; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal interface ISamlSigner { - internal interface ISamlSigner - { - /// - /// Signs an XML Document for a Saml Response - /// - /// - /// - /// - /// - XmlElement Sign(XmlDocument xmlDoc, string referenceId, string referenceValue); - } + /// + /// Signs an XML Document for a Saml Response + /// + /// + /// + /// + /// + public XmlElement Sign(XmlDocument xmlDoc, string referenceId, string referenceValue); } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/ISamlSignerFactory.cs b/src/Secure.SAML/Signing/ISamlSignerFactory.cs index 6fbf5e8..bc39509 100644 --- a/src/Secure.SAML/Signing/ISamlSignerFactory.cs +++ b/src/Secure.SAML/Signing/ISamlSignerFactory.cs @@ -1,7 +1,6 @@ -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal interface ISamlSignerFactory { - internal interface ISamlSignerFactory - { - ISamlSigner Create(SigningAlgorithm encryptionMethod); - } + public ISamlSigner Create(SigningAlgorithm encryptionMethod); } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/ISigningAlgorithm.cs b/src/Secure.SAML/Signing/ISigningAlgorithm.cs index 6b50a6a..e044871 100644 --- a/src/Secure.SAML/Signing/ISigningAlgorithm.cs +++ b/src/Secure.SAML/Signing/ISigningAlgorithm.cs @@ -1,13 +1,12 @@ using System.Security.Cryptography.Xml; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal interface ISigningAlgorithm { - internal interface ISigningAlgorithm - { - string CanonicalizationMethod { get; } - string SignatureMethod { get; } - string DigestMethod { get; } + public string CanonicalizationMethod { get; } + public string SignatureMethod { get; } + public string DigestMethod { get; } - void AddTransforms(Reference reference); - } + public void AddTransforms(Reference reference); } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/SamlSignedXml.cs b/src/Secure.SAML/Signing/SamlSignedXml.cs index 8b6903f..a822ced 100644 --- a/src/Secure.SAML/Signing/SamlSignedXml.cs +++ b/src/Secure.SAML/Signing/SamlSignedXml.cs @@ -1,24 +1,17 @@ using System.Security.Cryptography.Xml; using System.Xml; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +/// +/// SamlSignedXml - Class is used to sign xml, basically the when the ID is retreived the correct ID is used. +/// without this, the id reference would not be valid. +/// +internal class SamlSignedXml : SignedXml { - /// - /// SamlSignedXml - Class is used to sign xml, basically the when the ID is retreived the correct ID is used. - /// without this, the id reference would not be valid. - /// - internal class SamlSignedXml : SignedXml - { - private string _referenceAttributeId = ""; + private readonly string _referenceAttributeId = ""; - public SamlSignedXml(XmlDocument document, string referenceAttributeId) : base(document) - { - _referenceAttributeId = referenceAttributeId; - } + public SamlSignedXml(XmlDocument document, string referenceAttributeId) : base(document) => _referenceAttributeId = referenceAttributeId; - public override XmlElement GetIdElement(XmlDocument document, string idValue) - { - return (XmlElement)document.SelectSingleNode(string.Format("//*[@{0}='{1}']", _referenceAttributeId, idValue)); - } - } + public override XmlElement GetIdElement(XmlDocument document, string idValue) => (XmlElement)document.SelectSingleNode(string.Format("//*[@{0}='{1}']", _referenceAttributeId, idValue)); } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/SamlSigner.cs b/src/Secure.SAML/Signing/SamlSigner.cs index cc8a371..e2298a8 100644 --- a/src/Secure.SAML/Signing/SamlSigner.cs +++ b/src/Secure.SAML/Signing/SamlSigner.cs @@ -2,80 +2,79 @@ using System.Security.Cryptography.Xml; using System.Xml; -namespace Secure.SAML.Signing -{ - internal class SamlSigner : ISamlSigner - { - internal readonly ISigningAlgorithm SigningAlgorithm; - private readonly X509Certificate2 certificate; +namespace Secure.SAML.Signing; - public SamlSigner(ISigningAlgorithm signingAlgorithm, X509Certificate2 certificate) - { - SigningAlgorithm = signingAlgorithm; - this.certificate = certificate; - } +internal class SamlSigner : ISamlSigner +{ + private readonly X509Certificate2 certificate; + internal readonly ISigningAlgorithm SigningAlgorithm; - public XmlElement Sign(XmlDocument xmlDoc, string referenceId, string referenceValue) - { - var signingkey = certificate.GetRSAPrivateKey(); + public SamlSigner(ISigningAlgorithm signingAlgorithm, X509Certificate2 certificate) + { + SigningAlgorithm = signingAlgorithm; + this.certificate = certificate; + } - var signedXml = new SamlSignedXml(xmlDoc, referenceId) { SigningKey = signingkey }; + public XmlElement Sign(XmlDocument xmlDoc, string referenceId, string referenceValue) + { + var signingkey = certificate.GetRSAPrivateKey(); - // Set canonical method to Exclusive Canonical XML. - signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl; + var signedXml = new SamlSignedXml(xmlDoc, referenceId) { SigningKey = signingkey }; - // Set signature method to signed XML. - signedXml.SignedInfo.SignatureMethod = SigningAlgorithm.SignatureMethod; + // Set canonical method to Exclusive Canonical XML. + signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl; - // Create a reference to be signed. - var reference = new Reference { Uri = "#" + referenceValue }; + // Set signature method to signed XML. + signedXml.SignedInfo.SignatureMethod = SigningAlgorithm.SignatureMethod; - // Add an enveloped transformation to the reference. - SigningAlgorithm.AddTransforms(reference); + // Create a reference to be signed. + var reference = new Reference { Uri = "#" + referenceValue }; - // Set digest method of reference to be signed. - reference.DigestMethod = SigningAlgorithm.DigestMethod; + // Add an enveloped transformation to the reference. + SigningAlgorithm.AddTransforms(reference); - // Add the reference to the SignedXml object. - signedXml.AddReference(reference); + // Set digest method of reference to be signed. + reference.DigestMethod = SigningAlgorithm.DigestMethod; - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - var keyInfo = new KeyInfo(); - var keyData = new KeyInfoX509Data(certificate); + // Add the reference to the SignedXml object. + signedXml.AddReference(reference); - keyInfo.AddClause(keyData); + // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). + var keyInfo = new KeyInfo(); + var keyData = new KeyInfoX509Data(certificate); - signedXml.KeyInfo = keyInfo; + keyInfo.AddClause(keyData); - // Compute the signature. - signedXml.ComputeSignature(); + signedXml.KeyInfo = keyInfo; - // Get the XML representation of the signature and save it to an XmlElement object. - var xmlDigitalSignature = signedXml.GetXml(); + // Compute the signature. + signedXml.ComputeSignature(); - return xmlDigitalSignature; - } + // Get the XML representation of the signature and save it to an XmlElement object. + var xmlDigitalSignature = signedXml.GetXml(); - internal static bool VerifySignature(string xml, X509Certificate2 certificate) - { - var xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(xml); + return xmlDigitalSignature; + } - var key = certificate.PublicKey.Key; + internal static bool VerifySignature(string xml, X509Certificate2 certificate) + { + var xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(xml); - var result = true; + var key = certificate.PublicKey.Key; - foreach (XmlElement node in xmlDoc.SelectNodes("//*[local-name()='Signature']")) - { - var doc = new XmlDocument(); - doc.LoadXml(node.ParentNode.OuterXml); + var result = true; - var signedXml = new SignedXml(node.ParentNode as XmlElement); - signedXml.LoadXml(node); - result &= signedXml.CheckSignature(key); - } + foreach (XmlElement node in xmlDoc.SelectNodes("//*[local-name()='Signature']")) + { + var doc = new XmlDocument(); + doc.LoadXml(node.ParentNode.OuterXml); - return result; + var signedXml = new SignedXml(node.ParentNode as XmlElement); + signedXml.LoadXml(node); + result &= signedXml.CheckSignature(key); } + + return result; } } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/SamlSignerFactory.cs b/src/Secure.SAML/Signing/SamlSignerFactory.cs index 5c02d8d..b577556 100644 --- a/src/Secure.SAML/Signing/SamlSignerFactory.cs +++ b/src/Secure.SAML/Signing/SamlSignerFactory.cs @@ -2,33 +2,28 @@ using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal class SamlSignerFactory : ISamlSignerFactory { - internal class SamlSignerFactory : ISamlSignerFactory - { - private readonly IDictionary encrytionMethods; - private readonly Func certificateFactory; + private readonly Func certificateFactory; + private readonly IDictionary encrytionMethods; - public SamlSignerFactory(Func certificateFactory) - { - this.certificateFactory = certificateFactory; - encrytionMethods = GetEncryptionMethods(); - } + public SamlSignerFactory(Func certificateFactory) + { + this.certificateFactory = certificateFactory; + encrytionMethods = GetEncryptionMethods(); + } - private IDictionary GetEncryptionMethods() - { - return new Dictionary - { - {SigningAlgorithm.SHA1, new Sha1SigningAlgorithm()}, - {SigningAlgorithm.SHA256, new Sha256SigningAlgorithm()}, - {SigningAlgorithm.SHA512, new Sha512SigningAlgorithm()}, - }; - } + public ISamlSigner Create(SigningAlgorithm encryptionMethod) + { + var certificate = certificateFactory(); + return new SamlSigner(encrytionMethods[encryptionMethod], certificate); + } - public ISamlSigner Create(SigningAlgorithm encryptionMethod) + private IDictionary GetEncryptionMethods() => + new Dictionary { - var certificate = certificateFactory(); - return new SamlSigner(encrytionMethods[encryptionMethod], certificate); - } - } + { SigningAlgorithm.SHA1, new Sha1SigningAlgorithm() }, { SigningAlgorithm.SHA256, new Sha256SigningAlgorithm() }, { SigningAlgorithm.SHA512, new Sha512SigningAlgorithm() } + }; } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/Sha1SigningAlgorithm.cs b/src/Secure.SAML/Signing/Sha1SigningAlgorithm.cs index 25ca946..193bab6 100644 --- a/src/Secure.SAML/Signing/Sha1SigningAlgorithm.cs +++ b/src/Secure.SAML/Signing/Sha1SigningAlgorithm.cs @@ -1,21 +1,20 @@ using System; using System.Security.Cryptography.Xml; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal class Sha1SigningAlgorithm : ISigningAlgorithm { - internal class Sha1SigningAlgorithm : ISigningAlgorithm - { - public string CanonicalizationMethod { get; } = "http://www.w3.org/2001/10/xml-exc-c14n#"; - public string SignatureMethod { get; } = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; - public string DigestMethod { get; } = "http://www.w3.org/2000/09/xmldsig#sha1"; + public string CanonicalizationMethod { get; } = "http://www.w3.org/2001/10/xml-exc-c14n#"; + public string SignatureMethod { get; } = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; + public string DigestMethod { get; } = "http://www.w3.org/2000/09/xmldsig#sha1"; - public void AddTransforms(Reference reference) - { - if (reference == null) - throw new ArgumentException("reference parameter is null"); + public void AddTransforms(Reference reference) + { + if (reference == null) + throw new ArgumentException("reference parameter is null"); - reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); - reference.AddTransform(new XmlDsigExcC14NTransform("#default saml ds xs xsi")); - } + reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); + reference.AddTransform(new XmlDsigExcC14NTransform("#default saml ds xs xsi")); } } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/Sha256SigningAlgorithm.cs b/src/Secure.SAML/Signing/Sha256SigningAlgorithm.cs index c83f8ac..f0d53a8 100644 --- a/src/Secure.SAML/Signing/Sha256SigningAlgorithm.cs +++ b/src/Secure.SAML/Signing/Sha256SigningAlgorithm.cs @@ -1,21 +1,20 @@ using System; using System.Security.Cryptography.Xml; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal class Sha256SigningAlgorithm : ISigningAlgorithm { - internal class Sha256SigningAlgorithm : ISigningAlgorithm - { - public string CanonicalizationMethod { get; } = SignedXml.XmlDsigExcC14NTransformUrl; - public string SignatureMethod { get; } = SignedXml.XmlDsigRSASHA256Url; - public string DigestMethod { get; } = SignedXml.XmlDsigSHA256Url; + public string CanonicalizationMethod { get; } = SignedXml.XmlDsigExcC14NTransformUrl; + public string SignatureMethod { get; } = SignedXml.XmlDsigRSASHA256Url; + public string DigestMethod { get; } = SignedXml.XmlDsigSHA256Url; - public void AddTransforms(Reference reference) - { - if (reference == null) - throw new ArgumentException("reference parameter is null"); + public void AddTransforms(Reference reference) + { + if (reference == null) + throw new ArgumentException("reference parameter is null"); - reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); - reference.AddTransform(new XmlDsigExcC14NTransform("#default saml ds xs xsi")); - } + reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); + reference.AddTransform(new XmlDsigExcC14NTransform("#default saml ds xs xsi")); } } \ No newline at end of file diff --git a/src/Secure.SAML/Signing/Sha512SigningAlgorithm.cs b/src/Secure.SAML/Signing/Sha512SigningAlgorithm.cs index 9383180..07ed04a 100644 --- a/src/Secure.SAML/Signing/Sha512SigningAlgorithm.cs +++ b/src/Secure.SAML/Signing/Sha512SigningAlgorithm.cs @@ -1,21 +1,20 @@ using System; using System.Security.Cryptography.Xml; -namespace Secure.SAML.Signing +namespace Secure.SAML.Signing; + +internal class Sha512SigningAlgorithm : ISigningAlgorithm { - internal class Sha512SigningAlgorithm : ISigningAlgorithm - { - public string CanonicalizationMethod { get; } = SignedXml.XmlDsigExcC14NTransformUrl; - public string SignatureMethod { get; } = SignedXml.XmlDsigRSASHA512Url; - public string DigestMethod { get; } = SignedXml.XmlDsigSHA512Url; + public string CanonicalizationMethod { get; } = SignedXml.XmlDsigExcC14NTransformUrl; + public string SignatureMethod { get; } = SignedXml.XmlDsigRSASHA512Url; + public string DigestMethod { get; } = SignedXml.XmlDsigSHA512Url; - public void AddTransforms(Reference reference) - { - if (reference == null) - throw new ArgumentException("reference parameter is null"); + public void AddTransforms(Reference reference) + { + if (reference == null) + throw new ArgumentException("reference parameter is null"); - reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); - reference.AddTransform(new XmlDsigExcC14NTransform("#default saml ds xs xsi")); - } + reference.AddTransform(new XmlDsigEnvelopedSignatureTransform()); + reference.AddTransform(new XmlDsigExcC14NTransform("#default saml ds xs xsi")); } } \ No newline at end of file diff --git a/src/Secure.SAML/SigningAlgorithm.cs b/src/Secure.SAML/SigningAlgorithm.cs index 22b8171..e5c79e7 100644 --- a/src/Secure.SAML/SigningAlgorithm.cs +++ b/src/Secure.SAML/SigningAlgorithm.cs @@ -1,9 +1,8 @@ -namespace Secure.SAML +namespace Secure.SAML; + +public enum SigningAlgorithm { - public enum SigningAlgorithm - { - SHA512, - SHA256, - SHA1 - } + SHA512, + SHA256, + SHA1 } \ No newline at end of file diff --git a/src/Secure.SAML/v2/ISAML.cs b/src/Secure.SAML/v2/ISAML.cs index a979b05..f23d809 100644 --- a/src/Secure.SAML/v2/ISAML.cs +++ b/src/Secure.SAML/v2/ISAML.cs @@ -1,11 +1,10 @@ using System.Xml; -namespace Secure.SAML.v2 +namespace Secure.SAML.v2; + +public interface ISAML { - public interface ISAML - { - XmlDocument Create(Parameters parameters); + public XmlDocument Create(Parameters parameters); - string CreateEncoded(Parameters parameters); - } + public string CreateEncoded(Parameters parameters); } \ No newline at end of file diff --git a/src/Secure.SAML/v2/SAML.cs b/src/Secure.SAML/v2/SAML.cs index 3fa95cb..02f39f7 100644 --- a/src/Secure.SAML/v2/SAML.cs +++ b/src/Secure.SAML/v2/SAML.cs @@ -6,180 +6,145 @@ using System.Xml; using Secure.SAML.Signing; -namespace Secure.SAML.v2 +namespace Secure.SAML.v2; + +public class SAML : ISAML { - public class SAML : ISAML - { - private readonly ISamlSignerFactory samlSignerFactory; + private readonly ISamlSignerFactory samlSignerFactory; - public SAML(Func certificateFactory) + public SAML(Func certificateFactory) : this(new SamlSignerFactory(certificateFactory)) - { - } + { + } - internal SAML(ISamlSignerFactory samlSignerFactory) - { - this.samlSignerFactory = samlSignerFactory; - } + internal SAML(ISamlSignerFactory samlSignerFactory) => this.samlSignerFactory = samlSignerFactory; - /// - /// Creates Base64 encoded SAML Response. - /// - /// Saml parameters - /// Base64String - public string CreateEncoded(Parameters parameters) - { - var document = Create(parameters); - var base64EncodedBytes = Encoding.UTF8.GetBytes(document.OuterXml); - var encoded = Convert.ToBase64String(base64EncodedBytes); - return encoded; - } + /// + /// Creates Base64 encoded SAML Response. + /// + /// Saml parameters + /// Base64String + public string CreateEncoded(Parameters parameters) + { + var document = Create(parameters); + var base64EncodedBytes = Encoding.UTF8.GetBytes(document.OuterXml); + var encoded = Convert.ToBase64String(base64EncodedBytes); + return encoded; + } + + /// + /// Creates a SAML Response. + /// + /// Saml parameters + /// XmlDocument + public XmlDocument Create(Parameters parameters) + { + parameters.Validate(); - /// - /// Creates a SAML Response. - /// - /// Saml parameters - /// XmlDocument - public XmlDocument Create(Parameters parameters) + var response = new ResponseType { - parameters.Validate(); + ID = "_" + parameters.SamlId.ToString("N"), + Destination = parameters.Recipient, + Version = "2.0", + IssueInstant = parameters.Timestamp.ToSamlFormat(), + Issuer = new NameIDType { Value = parameters.Issuer.Trim() }, + Status = new StatusType { StatusCode = new StatusCodeType { Value = "urn:oasis:names:tc:SAML:2.0:status:Success" } } + }; - var response = new ResponseType - { - ID = "_" + parameters.SamlId.ToString("N"), - Destination = parameters.Recipient, - Version = "2.0", - IssueInstant = parameters.Timestamp.ToSamlFormat(), - Issuer = new NameIDType { Value = parameters.Issuer.Trim() }, - Status = new StatusType - { - StatusCode = new StatusCodeType { Value = "urn:oasis:names:tc:SAML:2.0:status:Success" } - } - }; + var assertionType = CreateSamlAssertion(parameters); - var assertionType = CreateSamlAssertion(parameters); + response.Items = new[] { assertionType }; - response.Items = new AssertionType[] { assertionType }; + var samlString = response.ToSamlXML(); - var samlString = response.ToSamlXML(); + samlString = AppendSubjectConfirmationData(parameters, samlString); - samlString = AppendSubjectConfirmationData(parameters, samlString); + var doc = new XmlDocument(); + doc.LoadXml(samlString); - var doc = new XmlDocument(); - doc.LoadXml(samlString); + var samlSigner = samlSignerFactory.Create(parameters.SigningAlgorithm); + var signature = samlSigner.Sign(doc, "ID", parameters.IsSignedResponse ? response.ID : assertionType.ID); - var samlSigner = samlSignerFactory.Create(parameters.SigningAlgorithm); - var signature = samlSigner.Sign(doc, "ID", parameters.IsSignedResponse ? response.ID : assertionType.ID); + if (parameters.IsSignedResponse) + { + doc.DocumentElement.InsertBefore(signature, doc.DocumentElement.ChildNodes[1]); + return doc; + } - if (parameters.IsSignedResponse) - { - doc.DocumentElement.InsertBefore(signature, doc.DocumentElement.ChildNodes[1]); - return doc; - } + var assertionNode = doc.DocumentElement.GetElementsByTagName("saml:Assertion")[0]; + assertionNode.InsertBefore(signature, assertionNode.ChildNodes[1]); - var assertionNode = doc.DocumentElement.GetElementsByTagName("saml:Assertion")[0]; - assertionNode.InsertBefore(signature, assertionNode.ChildNodes[1]); + return doc; + } - return doc; - } + private static string AppendSubjectConfirmationData(Parameters config, string samlString) + { + samlString = config.NotOnOrAfterInMinutes > 0 + ? samlString.Replace("SubjectConfirmationData", + $"SubjectConfirmationData NotOnOrAfter=\"{config.Timestamp.AddMinutes(config.NotOnOrAfterInMinutes).ToSamlFormat()}\" Recipient=\"{config.Recipient}\"") + : samlString.Replace("SubjectConfirmationData", $"SubjectConfirmationData Recipient=\"{config.Recipient}\""); + return samlString; + } - private static string AppendSubjectConfirmationData(Parameters config, string samlString) - { - samlString = config.NotOnOrAfterInMinutes > 0 - ? samlString.Replace("SubjectConfirmationData", - $"SubjectConfirmationData NotOnOrAfter=\"{config.Timestamp.AddMinutes(config.NotOnOrAfterInMinutes).ToSamlFormat()}\" Recipient=\"{config.Recipient}\"") - : samlString.Replace("SubjectConfirmationData", $"SubjectConfirmationData Recipient=\"{config.Recipient}\""); - return samlString; - } + private AssertionType CreateSamlAssertion(Parameters config) + { + var attributes = config.Attributes ?? new Dictionary(); - private AssertionType CreateSamlAssertion(Parameters config) + var assertion = new AssertionType { - var attributes = config.Attributes ?? new Dictionary(); + ID = "_" + config.AssertionId.ToString("N"), Issuer = new NameIDType { Value = config.Issuer.Trim() }, IssueInstant = config.Timestamp.ToSamlFormat(), Version = "2.0" + }; - var assertion = new AssertionType - { - ID = "_" + config.AssertionId.ToString("N"), - Issuer = new NameIDType { Value = config.Issuer.Trim() }, - IssueInstant = config.Timestamp.ToSamlFormat(), - Version = "2.0" - }; + if (config.AudienceRestrictions != null && config.AudienceRestrictions.Any()) + { + var conditions = new ConditionsType { Items = new ConditionAbstractType[] { new AudienceRestrictionType { Audience = config.AudienceRestrictions } } }; - if (config.AudienceRestrictions != null && config.AudienceRestrictions.Any()) + if (config.NotOnOrAfterInMinutes > 0) { - var conditions = new ConditionsType - { - Items = new ConditionAbstractType[] - { - new AudienceRestrictionType - { - Audience = config.AudienceRestrictions - } - } - }; - - if (config.NotOnOrAfterInMinutes > 0) - { - conditions.NotBefore = config.Timestamp.AddMinutes(-1.0).ToSamlFormat(); - conditions.NotBeforeSpecified = true; - conditions.NotOnOrAfter = config.Timestamp.AddMinutes(config.NotOnOrAfterInMinutes).ToSamlFormat(); - conditions.NotOnOrAfterSpecified = true; - } - - assertion.Conditions = conditions; + conditions.NotBefore = config.Timestamp.AddMinutes(-1.0).ToSamlFormat(); + conditions.NotBeforeSpecified = true; + conditions.NotOnOrAfter = config.Timestamp.AddMinutes(config.NotOnOrAfterInMinutes).ToSamlFormat(); + conditions.NotOnOrAfterSpecified = true; } - var nameIdentifier = new NameIDType - { - Value = config.NamedId.Trim() - }; + assertion.Conditions = conditions; + } - if (config.NameIdFormat != NameIdFormat.None) - nameIdentifier.Format = config.NameIdFormat.ToSamlString(); + var nameIdentifier = new NameIDType { Value = config.NamedId.Trim() }; - var subjectConfirmation = new SubjectConfirmationType - { - Method = "urn:oasis:names:tc:SAML:2.0:cm:bearer", - SubjectConfirmationData = new SubjectConfirmationDataType() - }; + if (config.NameIdFormat != NameIdFormat.None) + nameIdentifier.Format = config.NameIdFormat.ToSamlString(); - var samlSubject = new SubjectType { Items = new object[] { nameIdentifier, subjectConfirmation } }; + var subjectConfirmation = new SubjectConfirmationType { Method = "urn:oasis:names:tc:SAML:2.0:cm:bearer", SubjectConfirmationData = new SubjectConfirmationDataType() }; - assertion.Subject = samlSubject; + var samlSubject = new SubjectType { Items = new object[] { nameIdentifier, subjectConfirmation } }; - var authStatement = new AuthnStatementType - { - AuthnInstant = config.Timestamp.ToSamlFormat(), - AuthnContext = new AuthnContextType - { - ItemsElementName = new[] { ItemsChoiceType5.AuthnContextClassRef }, - Items = new object[] { "urn:oasis:names:tc:SAML:2.0:ac:classes:Password" } - } - }; - - AttributeStatementType attrStatement = null; - if (attributes.Any()) + assertion.Subject = samlSubject; + + var authStatement = new AuthnStatementType + { + AuthnInstant = config.Timestamp.ToSamlFormat(), + AuthnContext = new AuthnContextType { ItemsElementName = new[] { ItemsChoiceType5.AuthnContextClassRef }, Items = new object[] { "urn:oasis:names:tc:SAML:2.0:ac:classes:Password" } } + }; + + AttributeStatementType attrStatement = null; + if (attributes.Any()) + { + attrStatement = new AttributeStatementType { Items = new AttributeType[attributes.Count] }; + var i = 0; + + foreach (var attribute in attributes) { - attrStatement = new AttributeStatementType { Items = new AttributeType[attributes.Count] }; - var i = 0; - - foreach (var attribute in attributes) - { - var attr = new AttributeType - { - Name = attribute.Key, - NameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic", - AttributeValue = new[] { attribute.Value } - }; - attrStatement.Items[i] = attr; - i++; - } + var attr = new AttributeType { Name = attribute.Key, NameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic", AttributeValue = new[] { attribute.Value } }; + attrStatement.Items[i] = attr; + i++; } + } - assertion.Items = attrStatement != null - ? new StatementAbstractType[] { authStatement, attrStatement } - : new StatementAbstractType[] { authStatement }; + assertion.Items = attrStatement != null + ? new StatementAbstractType[] { authStatement, attrStatement } + : new StatementAbstractType[] { authStatement }; - return assertion; - } + return assertion; } } \ No newline at end of file diff --git a/src/Secure.SAML/v2/SamlExtensions.cs b/src/Secure.SAML/v2/SamlExtensions.cs index 4cca22c..715939f 100644 --- a/src/Secure.SAML/v2/SamlExtensions.cs +++ b/src/Secure.SAML/v2/SamlExtensions.cs @@ -4,57 +4,48 @@ using System.Xml; using System.Xml.Serialization; -namespace Secure.SAML.v2 +namespace Secure.SAML.v2; + +internal static class SamlExtensions { - internal static class SamlExtensions - { - internal static string ToSamlFormat(this DateTime date) - { - return date.ToString("s") + "Z"; - } + internal static string ToSamlFormat(this DateTime date) => date.ToString("s") + "Z"; - internal static string ToSamlString(this NameIdFormat nameIdFormat) + internal static string ToSamlString(this NameIdFormat nameIdFormat) + { + switch (nameIdFormat) { - switch (nameIdFormat) - { - case NameIdFormat.EmailAddress: - return "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"; + case NameIdFormat.EmailAddress: + return "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"; - case NameIdFormat.Transient: - return "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"; + case NameIdFormat.Transient: + return "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"; - case NameIdFormat.Persistent: - return "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"; + case NameIdFormat.Persistent: + return "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"; - default: - return "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified"; - } + default: + return "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified"; } + } - internal static string ToSamlXML(this ResponseType response) - { - var responseSerializer = new XmlSerializer(response.GetType()); + internal static string ToSamlXML(this ResponseType response) + { + var responseSerializer = new XmlSerializer(response.GetType()); - using (var stringWriter = new StringWriter()) - { - var settings = new XmlWriterSettings - { - OmitXmlDeclaration = true, - Indent = true, - Encoding = Encoding.UTF8 - }; + using (var stringWriter = new StringWriter()) + { + var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true, Encoding = Encoding.UTF8 }; - var namespaceMgr = new XmlSerializerNamespaces(); - namespaceMgr.Add("samlp", "urn:oasis:names:tc:SAML:2.0:protocol"); - namespaceMgr.Add("saml", "urn:oasis:names:tc:SAML:2.0:assertion"); + var namespaceMgr = new XmlSerializerNamespaces(); + namespaceMgr.Add("samlp", "urn:oasis:names:tc:SAML:2.0:protocol"); + namespaceMgr.Add("saml", "urn:oasis:names:tc:SAML:2.0:assertion"); - var responseWriter = XmlWriter.Create(stringWriter, settings); - responseSerializer.Serialize(responseWriter, response, namespaceMgr); + var responseWriter = XmlWriter.Create(stringWriter, settings); + responseSerializer.Serialize(responseWriter, response, namespaceMgr); - var samlString = stringWriter.ToString(); + var samlString = stringWriter.ToString(); - return samlString; - } + return samlString; } } } \ No newline at end of file diff --git a/src/Secure.SAML/v2/Xsds/saml-schema-assertion-2.0.xsd b/src/Secure.SAML/v2/Xsds/saml-schema-assertion-2.0.xsd index b94a693..b1889b3 100644 --- a/src/Secure.SAML/v2/Xsds/saml-schema-assertion-2.0.xsd +++ b/src/Secure.SAML/v2/Xsds/saml-schema-assertion-2.0.xsd @@ -1,117 +1,117 @@ + schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/> + schemaLocation="http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd"/> Document identifier: saml-schema-assertion-2.0 Location: http://docs.oasis-open.org/security/saml/v2.0/ Revision history: V1.0 (November, 2002): - Initial Standard Schema. + Initial Standard Schema. V1.1 (September, 2003): - Updates within the same V1.0 namespace. + Updates within the same V1.0 namespace. V2.0 (March, 2005): - New assertion schema for SAML V2.0 namespace. + New assertion schema for SAML V2.0 namespace. - - + + - + - + - + - - - + + + - - + + - - - - - + + + + + - - - - - + + + + + - - - - + + + + - - - + + + - + - - - + + + - + - + - + - - - + + + - + - + - + - + - - - - - - + + + + + + @@ -119,165 +119,165 @@ - + - + - - - - + + + + - - + + - - - + + + - + - - + + - + - + - - - - - - - - + + + + + + + + - + - - - - - + + + + + - - - - + + + + - - + + - - - + + + - + - - + + - + - + - - + + - - + + - + - - - - - + + + + + - - + + - - + + - - - + + + - + - + - + - - - - + + + + - + - - + + - + - + - - - - + + + + - - + + \ No newline at end of file diff --git a/src/Secure.SAML/v2/Xsds/saml-schema-protocol-2.0.xsd b/src/Secure.SAML/v2/Xsds/saml-schema-protocol-2.0.xsd index bef8ddc..1d1dcb3 100644 --- a/src/Secure.SAML/v2/Xsds/saml-schema-protocol-2.0.xsd +++ b/src/Secure.SAML/v2/Xsds/saml-schema-protocol-2.0.xsd @@ -1,300 +1,300 @@ + schemaLocation="saml-schema-assertion-2.0.xsd"/> + schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/> Document identifier: saml-schema-protocol-2.0 Location: http://docs.oasis-open.org/security/saml/v2.0/ Revision history: V1.0 (November, 2002): - Initial Standard Schema. + Initial Standard Schema. V1.1 (September, 2003): - Updates within the same V1.0 namespace. + Updates within the same V1.0 namespace. V2.0 (March, 2005): - New protocol schema based in a SAML V2.0 namespace. - + New protocol schema based in a SAML V2.0 namespace. + - - - + + + - - - - - + + + + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - + + + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - - - + + + + - + - + - + - - + + - + - + - - - - - + + + + + - - - - - - - + + + + + + + - + - - - + + + - + - - + + - + - - + + - - + + - + - - - + + + - - + + - + - - + + - + - + - + - + - + - - + + - + - + - + - + - + - - + + - - - + + + - + - - - - - - + + + + + + - - - + + + - + - - + + - - - + + + - - - + + + - + - + - - + + diff --git a/src/Secure.SAML/v2/Xsds/xenc-core-schema.xsd b/src/Secure.SAML/v2/Xsds/xenc-core-schema.xsd index 39d0e2a..55030ac 100644 --- a/src/Secure.SAML/v2/Xsds/xenc-core-schema.xsd +++ b/src/Secure.SAML/v2/Xsds/xenc-core-schema.xsd @@ -1,142 +1,142 @@ - - - - ]> - - + + + + ]> + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - - + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - + + - - - - - - + + + + + + \ No newline at end of file diff --git a/src/Secure.SAML/v2/Xsds/xmldsig-core-schema.xsd b/src/Secure.SAML/v2/Xsds/xmldsig-core-schema.xsd index 1ebd78d..5b6f2de 100644 --- a/src/Secure.SAML/v2/Xsds/xmldsig-core-schema.xsd +++ b/src/Secure.SAML/v2/Xsds/xmldsig-core-schema.xsd @@ -1,13 +1,13 @@ - - - - ]> + PUBLIC "-//W3C//DTD XMLSchema 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd" + [ + + + + + ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/Helper.cs b/tests/Secure.SAML.Tests/Helper.cs index 90099f3..25291d4 100644 --- a/tests/Secure.SAML.Tests/Helper.cs +++ b/tests/Secure.SAML.Tests/Helper.cs @@ -2,37 +2,35 @@ using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +public static class Helper { - public static class Helper + /// + /// Get certificate + /// + /// + public static X509Certificate2 GetCertificate() { - /// - /// Get certificate - /// - /// - public static X509Certificate2 GetCertificate() - { - var signedStream = typeof(Helper) - .Assembly.GetManifestResourceStream("Secure.SAML.Tests.SelfSignedKey.pfx"); - var signingCertRawData = new byte[signedStream.Length]; - signedStream.Read(signingCertRawData, 0, (int)signedStream.Length); - return new X509Certificate2(signingCertRawData, "password", X509KeyStorageFlags.Exportable); - } - - public static Parameters GetParameters(SigningAlgorithm algorithm) => new Parameters - ( - issuer: "http://ninjacorp.com", - recipient: "https://xyz.target-link.co.uk:443/saml/api", - audienceRestrictions: new[] { "xyz.target-link.co.uk" }, - namedId: "NIN0123456", - nameIdFormat: NameIdFormat.Unspecified, - attributes: new Dictionary { { "Custom_key", "value" } }, - signatureType: SignType.Response, - notOnOrAfterInMins: 10, - signingAlgorithm: algorithm, - samlId: Guid.Parse("95AD6A84-95C1-4B39-AE5E-FE1E700C406C"), - assertionId: Guid.Parse("B3CA912A-4A6B-4F31-9FD8-FC5E55837656"), - timestamp: DateTime.Parse("2018-02-27T09:36:44.0665619Z") - ); + var signedStream = typeof(Helper) + .Assembly.GetManifestResourceStream("Secure.SAML.Tests.SelfSignedKey.pfx"); + var signingCertRawData = new byte[signedStream.Length]; + signedStream.Read(signingCertRawData, 0, (int)signedStream.Length); + return new X509Certificate2(signingCertRawData, "password", X509KeyStorageFlags.Exportable); } + + public static Parameters GetParameters(SigningAlgorithm algorithm) => new( + "http://ninjacorp.com", + "https://xyz.target-link.co.uk:443/saml/api", + new[] { "xyz.target-link.co.uk" }, + "NIN0123456", + NameIdFormat.Unspecified, + new Dictionary { { "Custom_key", "value" } }, + SignType.Response, + 10, + algorithm, + Guid.Parse("95AD6A84-95C1-4B39-AE5E-FE1E700C406C"), + Guid.Parse("B3CA912A-4A6B-4F31-9FD8-FC5E55837656"), + DateTime.Parse("2018-02-27T09:36:44.0665619Z") + ); } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SAMLTests.cs b/tests/Secure.SAML.Tests/SAMLTests.cs index 34b1f19..da1b42e 100644 --- a/tests/Secure.SAML.Tests/SAMLTests.cs +++ b/tests/Secure.SAML.Tests/SAMLTests.cs @@ -3,38 +3,37 @@ using VerifyNUnit; using VerifyTests; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SAMLTests { - [TestFixture] - public class SAMLTests + [SetUp] + public void Setup() { - private v2.SAML saml; - private VerifySettings settings; + saml = new v2.SAML(Helper.GetCertificate); + settings = new VerifySettings(); + settings.UseDirectory("Approvals"); + } - [SetUp] - public void Setup() - { - saml = new v2.SAML(Helper.GetCertificate); - settings = new VerifySettings(); - settings.UseDirectory("Approvals"); - } + private v2.SAML saml; + private VerifySettings settings; - [TestCase(SigningAlgorithm.SHA1)] - [TestCase(SigningAlgorithm.SHA256)] - [TestCase(SigningAlgorithm.SHA512)] - public async Task TestCreateUsingGivenAlgorithm(SigningAlgorithm signingAlgorithm) - { - var response = saml.Create(Helper.GetParameters(signingAlgorithm)); - await Verifier.Verify(response.OuterXml, settings); - } + [TestCase(SigningAlgorithm.SHA1)] + [TestCase(SigningAlgorithm.SHA256)] + [TestCase(SigningAlgorithm.SHA512)] + public async Task TestCreateUsingGivenAlgorithm(SigningAlgorithm signingAlgorithm) + { + var response = saml.Create(Helper.GetParameters(signingAlgorithm)); + await Verifier.Verify(response.OuterXml, settings); + } - [TestCase(SigningAlgorithm.SHA1)] - [TestCase(SigningAlgorithm.SHA256)] - [TestCase(SigningAlgorithm.SHA512)] - public async Task TestCreateEncodedUsingGivenAlgorithm(SigningAlgorithm signingAlgorithm) - { - var response = saml.CreateEncoded(Helper.GetParameters(signingAlgorithm)); - await Verifier.Verify(response, settings); - } + [TestCase(SigningAlgorithm.SHA1)] + [TestCase(SigningAlgorithm.SHA256)] + [TestCase(SigningAlgorithm.SHA512)] + public async Task TestCreateEncodedUsingGivenAlgorithm(SigningAlgorithm signingAlgorithm) + { + var response = saml.CreateEncoded(Helper.GetParameters(signingAlgorithm)); + await Verifier.Verify(response, settings); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs b/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs index f0023cc..31f623d 100644 --- a/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs +++ b/tests/Secure.SAML.Tests/SHA1SigningAlgorithmTests.cs @@ -1,36 +1,36 @@ using System; using System.Security.Cryptography.Xml; using NUnit.Framework; +using Secure.SAML.Signing; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SHA1SigningAlgorithmTests { - [TestFixture] - public class SHA1SigningAlgorithmTests + [Test] + public void TestSigningAlgorithmForCorrectSettings() { - [Test] - public void TestSigningAlgorithmForCorrectSettings() - { - var encryptionMethod = new Signing.Sha1SigningAlgorithm(); + var encryptionMethod = new Sha1SigningAlgorithm(); - Assert.That(encryptionMethod.SignatureMethod, Is.EqualTo("http://www.w3.org/2000/09/xmldsig#rsa-sha1")); - Assert.That(encryptionMethod.CanonicalizationMethod, Is.EqualTo("http://www.w3.org/2001/10/xml-exc-c14n#")); - Assert.That(encryptionMethod.DigestMethod, Is.EqualTo("http://www.w3.org/2000/09/xmldsig#sha1")); + Assert.That(encryptionMethod.SignatureMethod, Is.EqualTo("http://www.w3.org/2000/09/xmldsig#rsa-sha1")); + Assert.That(encryptionMethod.CanonicalizationMethod, Is.EqualTo("http://www.w3.org/2001/10/xml-exc-c14n#")); + Assert.That(encryptionMethod.DigestMethod, Is.EqualTo("http://www.w3.org/2000/09/xmldsig#sha1")); - var reference = new Reference(); - encryptionMethod.AddTransforms(reference); + var reference = new Reference(); + encryptionMethod.AddTransforms(reference); - Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); - Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); + Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); + Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); - var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; - Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); - } + var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; + Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); + } - [Test] - public void TestAddTransformsForNullArgumentToThrowException() - { - var encryptionMethod = new Signing.Sha1SigningAlgorithm(); - Assert.Throws(() => encryptionMethod.AddTransforms(null)); - } + [Test] + public void TestAddTransformsForNullArgumentToThrowException() + { + var encryptionMethod = new Sha1SigningAlgorithm(); + Assert.Throws(() => encryptionMethod.AddTransforms(null)); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs b/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs index c7de5ee..5ec0413 100644 --- a/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs +++ b/tests/Secure.SAML.Tests/SHA256SigningAlgorithmTests.cs @@ -1,36 +1,36 @@ using System; using System.Security.Cryptography.Xml; using NUnit.Framework; +using Secure.SAML.Signing; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SHA256SigningAlgorithmTests { - [TestFixture] - public class SHA256SigningAlgorithmTests + [Test] + public void TestSigningAlgorithmForCorrectSettings() { - [Test] - public void TestSigningAlgorithmForCorrectSettings() - { - var encryptionMethod = new Signing.Sha256SigningAlgorithm(); + var encryptionMethod = new Sha256SigningAlgorithm(); - Assert.That(encryptionMethod.SignatureMethod, Is.EqualTo("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")); - Assert.That(encryptionMethod.CanonicalizationMethod, Is.EqualTo("http://www.w3.org/2001/10/xml-exc-c14n#")); - Assert.That(encryptionMethod.DigestMethod, Is.EqualTo("http://www.w3.org/2001/04/xmlenc#sha256")); + Assert.That(encryptionMethod.SignatureMethod, Is.EqualTo("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")); + Assert.That(encryptionMethod.CanonicalizationMethod, Is.EqualTo("http://www.w3.org/2001/10/xml-exc-c14n#")); + Assert.That(encryptionMethod.DigestMethod, Is.EqualTo("http://www.w3.org/2001/04/xmlenc#sha256")); - var reference = new Reference(); - encryptionMethod.AddTransforms(reference); + var reference = new Reference(); + encryptionMethod.AddTransforms(reference); - Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); - Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); + Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); + Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); - var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; - Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); - } + var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; + Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); + } - [Test] - public void TestAddTransformsForNullArgumentToThrowException() - { - var encryptionMethod = new Signing.Sha256SigningAlgorithm(); - Assert.Throws(() => encryptionMethod.AddTransforms(null)); - } + [Test] + public void TestAddTransformsForNullArgumentToThrowException() + { + var encryptionMethod = new Sha256SigningAlgorithm(); + Assert.Throws(() => encryptionMethod.AddTransforms(null)); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs b/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs index 476ebde..c9e6b77 100644 --- a/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs +++ b/tests/Secure.SAML.Tests/SHA512SigningAlgorithmTests.cs @@ -1,36 +1,36 @@ using System; using System.Security.Cryptography.Xml; using NUnit.Framework; +using Secure.SAML.Signing; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SHA512SigningAlgorithmTests { - [TestFixture] - public class SHA512SigningAlgorithmTests + [Test] + public void TestSigningAlgorithmForCorrectSettings() { - [Test] - public void TestSigningAlgorithmForCorrectSettings() - { - var encryptionMethod = new Signing.Sha512SigningAlgorithm(); + var encryptionMethod = new Sha512SigningAlgorithm(); - Assert.That(encryptionMethod.SignatureMethod, Is.EqualTo("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512")); - Assert.That(encryptionMethod.CanonicalizationMethod, Is.EqualTo("http://www.w3.org/2001/10/xml-exc-c14n#")); - Assert.That(encryptionMethod.DigestMethod, Is.EqualTo("http://www.w3.org/2001/04/xmlenc#sha512")); + Assert.That(encryptionMethod.SignatureMethod, Is.EqualTo("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512")); + Assert.That(encryptionMethod.CanonicalizationMethod, Is.EqualTo("http://www.w3.org/2001/10/xml-exc-c14n#")); + Assert.That(encryptionMethod.DigestMethod, Is.EqualTo("http://www.w3.org/2001/04/xmlenc#sha512")); - var reference = new Reference(); - encryptionMethod.AddTransforms(reference); + var reference = new Reference(); + encryptionMethod.AddTransforms(reference); - Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); - Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); + Assert.That(reference.TransformChain[0] is XmlDsigEnvelopedSignatureTransform, Is.True); + Assert.That(reference.TransformChain[1] is XmlDsigExcC14NTransform, Is.True); - var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; - Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); - } + var xmlDsigExcC14NTransform = (XmlDsigExcC14NTransform)reference.TransformChain[1]; + Assert.That(xmlDsigExcC14NTransform.InclusiveNamespacesPrefixList, Is.EqualTo("#default saml ds xs xsi")); + } - [Test] - public void TestAddTransformsForNullArgumentToThrowException() - { - var encryptionMethod = new Signing.Sha512SigningAlgorithm(); - Assert.Throws(() => encryptionMethod.AddTransforms(null)); - } + [Test] + public void TestAddTransformsForNullArgumentToThrowException() + { + var encryptionMethod = new Sha512SigningAlgorithm(); + Assert.Throws(() => encryptionMethod.AddTransforms(null)); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SamlExtensionTests.cs b/tests/Secure.SAML.Tests/SamlExtensionTests.cs index 66a3d14..6b0c4f7 100644 --- a/tests/Secure.SAML.Tests/SamlExtensionTests.cs +++ b/tests/Secure.SAML.Tests/SamlExtensionTests.cs @@ -2,37 +2,36 @@ using NUnit.Framework; using Secure.SAML.v2; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SamlExtensionTests { - [TestFixture] - public class SamlExtensionTests + [Test] + public void TestToSamlDateFormatForCorrectUTCCharacters() { - [Test] - public void TestToSamlDateFormatForCorrectUTCCharacters() - { - var date = DateTime.Parse("2018-02-27T09:36:44.0665619Z"); - var dateTime = date.ToSamlFormat(); - Assert.That(dateTime, Is.EqualTo("2018-02-27T09:36:44Z")); - } + var date = DateTime.Parse("2018-02-27T09:36:44.0665619Z"); + var dateTime = date.ToSamlFormat(); + Assert.That(dateTime, Is.EqualTo("2018-02-27T09:36:44Z")); + } - [TestCase(NameIdFormat.EmailAddress, "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress")] - [TestCase(NameIdFormat.Transient, "urn:oasis:names:tc:SAML:2.0:nameid-format:transient")] - [TestCase(NameIdFormat.Persistent, "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent")] - [TestCase(NameIdFormat.Unspecified, "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified")] - public void TestToSamlStringFormatForCorrectNameIdFormat(NameIdFormat nameIdFormat, string urn) - { - var samlUrn = nameIdFormat.ToSamlString(); - Assert.That(samlUrn, Is.EqualTo(urn)); - } + [TestCase(NameIdFormat.EmailAddress, "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress")] + [TestCase(NameIdFormat.Transient, "urn:oasis:names:tc:SAML:2.0:nameid-format:transient")] + [TestCase(NameIdFormat.Persistent, "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent")] + [TestCase(NameIdFormat.Unspecified, "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified")] + public void TestToSamlStringFormatForCorrectNameIdFormat(NameIdFormat nameIdFormat, string urn) + { + var samlUrn = nameIdFormat.ToSamlString(); + Assert.That(samlUrn, Is.EqualTo(urn)); + } - [Test] - public void TestToSamlXMLExtensionForCorrectNamespaces() - { - var samlResponse = new ResponseType(); - var samlXml = samlResponse.ToSamlXML(); + [Test] + public void TestToSamlXMLExtensionForCorrectNamespaces() + { + var samlResponse = new ResponseType(); + var samlXml = samlResponse.ToSamlXML(); - Assert.That(samlXml.Contains(@"xmlns:saml=""urn:oasis:names:tc:SAML:2.0:assertion""")); - Assert.That(samlXml.Contains(@"xmlns:samlp=""urn:oasis:names:tc:SAML:2.0:protocol""")); - } + Assert.That(samlXml.Contains(@"xmlns:saml=""urn:oasis:names:tc:SAML:2.0:assertion""")); + Assert.That(samlXml.Contains(@"xmlns:samlp=""urn:oasis:names:tc:SAML:2.0:protocol""")); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs b/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs index a42767d..bc46795 100644 --- a/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs +++ b/tests/Secure.SAML.Tests/SamlSignerFactoryTests.cs @@ -2,19 +2,18 @@ using NUnit.Framework; using Secure.SAML.Signing; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SamlSignerFactoryTests { - [TestFixture] - public class SamlSignerFactoryTests + [TestCase(SigningAlgorithm.SHA1, typeof(Sha1SigningAlgorithm))] + [TestCase(SigningAlgorithm.SHA256, typeof(Sha256SigningAlgorithm))] + [TestCase(SigningAlgorithm.SHA512, typeof(Sha512SigningAlgorithm))] + public void TestFactoryForReturningCorrectSignerType(SigningAlgorithm encryptionMethod, Type type) { - [TestCase(SigningAlgorithm.SHA1, typeof(Sha1SigningAlgorithm))] - [TestCase(SigningAlgorithm.SHA256, typeof(Sha256SigningAlgorithm))] - [TestCase(SigningAlgorithm.SHA512, typeof(Sha512SigningAlgorithm))] - public void TestFactoryForReturningCorrectSignerType(SigningAlgorithm encryptionMethod, Type type) - { - var signerFactory = new SamlSignerFactory(Helper.GetCertificate); - var signer = (SamlSigner)signerFactory.Create(encryptionMethod); - Assert.That(type.IsAssignableFrom(signer.SigningAlgorithm.GetType())); - } + var signerFactory = new SamlSignerFactory(Helper.GetCertificate); + var signer = (SamlSigner)signerFactory.Create(encryptionMethod); + Assert.That(type.IsAssignableFrom(signer.SigningAlgorithm.GetType())); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/SamlSignerTests.cs b/tests/Secure.SAML.Tests/SamlSignerTests.cs index 9a7ce86..bed44f7 100644 --- a/tests/Secure.SAML.Tests/SamlSignerTests.cs +++ b/tests/Secure.SAML.Tests/SamlSignerTests.cs @@ -1,19 +1,18 @@ using NUnit.Framework; using Secure.SAML.Signing; -namespace Secure.SAML.Tests +namespace Secure.SAML.Tests; + +[TestFixture] +public class SamlSignerTests { - [TestFixture] - public class SamlSignerTests - { - [TestCase(SigningAlgorithm.SHA1)] - [TestCase(SigningAlgorithm.SHA256)] - [TestCase(SigningAlgorithm.SHA512)] - public void TestSamlSignerWithGivenAlgorithm(SigningAlgorithm signingAlgorithm) + [TestCase(SigningAlgorithm.SHA1)] + [TestCase(SigningAlgorithm.SHA256)] + [TestCase(SigningAlgorithm.SHA512)] + public void TestSamlSignerWithGivenAlgorithm(SigningAlgorithm signingAlgorithm) - { - var response = new v2.SAML(Helper.GetCertificate).Create(Helper.GetParameters(signingAlgorithm)); - Assert.That(SamlSigner.VerifySignature(response.OuterXml, Helper.GetCertificate())); - } + { + var response = new v2.SAML(Helper.GetCertificate).Create(Helper.GetParameters(signingAlgorithm)); + Assert.That(SamlSigner.VerifySignature(response.OuterXml, Helper.GetCertificate())); } } \ No newline at end of file diff --git a/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj b/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj index 776c119..4490483 100644 --- a/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj +++ b/tests/Secure.SAML.Tests/Secure.SAML.Tests.csproj @@ -6,30 +6,30 @@ disable false - + - + - + - - - - - + + + + + - + - + From c619996912a3ec4b396c4f56798049c0b1f74a3e Mon Sep 17 00:00:00 2001 From: Ninja Date: Sat, 23 Nov 2024 01:14:22 +0000 Subject: [PATCH 07/10] - r --- .github/workflows/codeql.yml | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 078a395..17195cc 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,11 +13,11 @@ name: "CodeQL" on: pull_request: - types: [opened, reopened, edited, synchronize] + types: [ opened, reopened, edited, synchronize ] paths-ignore: - - "**/*.md" - - "**/*.gitignore" - - "**/*.gitattributes" + - "**/*.md" + - "**/*.gitignore" + - "**/*.gitattributes" schedule: - cron: '35 15 * * 2' @@ -38,38 +38,38 @@ jobs: # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From c50c94ec4bba629cdebfe2fc0d8350816e363cf9 Mon Sep 17 00:00:00 2001 From: Ninja Date: Sat, 23 Nov 2024 22:33:05 +0000 Subject: [PATCH 08/10] - update --- src/Secure.SAML/Secure.SAML.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Secure.SAML/Secure.SAML.csproj b/src/Secure.SAML/Secure.SAML.csproj index f75ff1e..00a271a 100644 --- a/src/Secure.SAML/Secure.SAML.csproj +++ b/src/Secure.SAML/Secure.SAML.csproj @@ -17,9 +17,9 @@ Code Shayk https://github.com/codeshayk/Secure.SAML Secure.SAML - https://github.com/CodeShayk/Secure.SAML/wiki + https://github.com/codeshayk/Secure.SAML/wiki .Net library to generate signed SAML 2.0 Response. - SAML; SAML Response; SHA1 SAML; SHA256 SAML; SHA512 SAML; SAML Assertion; + SAML; SAML Response; SHA1 SAML; SHA256 SAML; SHA512 SAML; SAML Assertion; SAML Library 4.0.0 4.0.0 ninja-icon-16.png From 663bd5efb0ff28bcdfff0e7e14a9b255394244ac Mon Sep 17 00:00:00 2001 From: Ninja Date: Sun, 24 Nov 2024 00:53:36 +0000 Subject: [PATCH 09/10] - Update --- src/Secure.SAML/Secure.SAML.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Secure.SAML/Secure.SAML.csproj b/src/Secure.SAML/Secure.SAML.csproj index 00a271a..f47c1b1 100644 --- a/src/Secure.SAML/Secure.SAML.csproj +++ b/src/Secure.SAML/Secure.SAML.csproj @@ -37,6 +37,7 @@ Secure.SAML True True + symbols.nupkg @@ -47,7 +48,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From e1ca6b6549edd3eff499990adbe66a0dfd169b41 Mon Sep 17 00:00:00 2001 From: Ninja Date: Sun, 24 Nov 2024 01:19:14 +0000 Subject: [PATCH 10/10] - update project url --- src/Secure.SAML/Secure.SAML.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Secure.SAML/Secure.SAML.csproj b/src/Secure.SAML/Secure.SAML.csproj index f47c1b1..ec44247 100644 --- a/src/Secure.SAML/Secure.SAML.csproj +++ b/src/Secure.SAML/Secure.SAML.csproj @@ -15,7 +15,6 @@ © Copyright 2024 Code Shayk. Code Shayk Code Shayk - https://github.com/codeshayk/Secure.SAML Secure.SAML https://github.com/codeshayk/Secure.SAML/wiki .Net library to generate signed SAML 2.0 Response. @@ -38,6 +37,7 @@ True True symbols.nupkg + https://github.com/codeshayk/Secure.SAML