Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rename all references to "IdentityStream" with "Sparebanken Vest" #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,5 @@ FodyWeavers.xsd
*.tlog

# End of https://www.toptal.com/developers/gitignore/api/windows,osx,visualstudio,rider

.idea
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Authors>IdentityStream AS</Authors>
<Authors>IdentityStream AS,Sparebanken Vest</Authors>
<LangVersion>9.0</LangVersion>
<Nullable>Enable</Nullable>
</PropertyGroup>
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# HttpMessageSigning [![NuGet Package](https://img.shields.io/nuget/v/IdentityStream.HttpMessageSigning.svg)](https://www.nuget.org/packages/IdentityStream.HttpMessageSigning)
# SparebankenVest.HttpMessageSigning

A .NET implementation of "[Signing HTTP Messages](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12)" (Cavage, draft 12) for WCF and HttpClient.

This project is a fork of [IdentityStream.HttpMessageSigning](https://github.com/IdentityStream/HttpMessageSigning).

## Usage

When hooking up HTTP message signing, there's a bunch of configuration options available:
Expand Down Expand Up @@ -36,7 +38,7 @@ client.UseHttpMessageSigning(config);

// Make calls using client :)
```
<sup><a href='/test/IdentityStream.HttpMessageSigning.Tests/Snippets.cs#L15-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-wcf_endpoint_usehttpmessagesigning' title='Start of snippet'>anchor</a></sup>
<sup><a href='/test/SparebankenVest.HttpMessageSigning.Tests/Snippets.cs#L15-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-wcf_endpoint_usehttpmessagesigning' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

### HttpClient
Expand All @@ -56,5 +58,5 @@ using var client = new HttpClient(handler);

// Make requests using client :)
```
<sup><a href='/test/IdentityStream.HttpMessageSigning.Tests/Snippets.cs#L29-L39' title='Snippet source file'>snippet source</a> | <a href='#snippet-httpclient_signinghttpmessagehandler' title='Start of snippet'>anchor</a></sup>
<sup><a href='/test/SparebankenVest.HttpMessageSigning.Tests/Snippets.cs#L29-L39' title='Snippet source file'>snippet source</a> | <a href='#snippet-httpclient_signinghttpmessagehandler' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityStream.HttpMessageSigning", "src\IdentityStream.HttpMessageSigning\IdentityStream.HttpMessageSigning.csproj", "{60C881D5-1DDB-4DE9-B44D-41FE3CE00E80}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SparebankenVest.HttpMessageSigning", "src\SparebankenVest.HttpMessageSigning\SparebankenVest.HttpMessageSigning.csproj", "{60C881D5-1DDB-4DE9-B44D-41FE3CE00E80}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityStream.HttpMessageSigning.Tests", "test\IdentityStream.HttpMessageSigning.Tests\IdentityStream.HttpMessageSigning.Tests.csproj", "{C7A49C51-D781-499A-9ED9-4FB792DE8F54}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SparebankenVest.HttpMessageSigning.Tests", "test\SparebankenVest.HttpMessageSigning.Tests\SparebankenVest.HttpMessageSigning.Tests.csproj", "{C7A49C51-D781-499A-9ED9-4FB792DE8F54}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D0F60E24-8C58-4CC4-ADEF-AD578ABF8CDB}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -21,7 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityStream.HttpMessageSigning.ServiceModel", "src\IdentityStream.HttpMessageSigning.ServiceModel\IdentityStream.HttpMessageSigning.ServiceModel.csproj", "{9B777139-3F10-43FE-8CA0-D5C1CCF11535}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparebankenVest.HttpMessageSigning.ServiceModel", "src\SparebankenVest.HttpMessageSigning.ServiceModel\SparebankenVest.HttpMessageSigning.ServiceModel.csproj", "{9B777139-3F10-43FE-8CA0-D5C1CCF11535}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..\'))" />

<PropertyGroup>
<PackageProjectUrl>https://github.com/IdentityStream-AS/HttpMessageSigning</PackageProjectUrl>
<RepositoryUrl>https://github.com/IdentityStream-AS/HttpMessageSigning</RepositoryUrl>
<PackageProjectUrl>https://github.com/SparebankenVest/HttpMessageSigning</PackageProjectUrl>
<RepositoryUrl>https://github.com/SparebankenVest/HttpMessageSigning</RepositoryUrl>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace IdentityStream.HttpMessageSigning.ServiceModel {
namespace SparebankenVest.HttpMessageSigning.ServiceModel {
/// <summary>
/// Behavior that adds a <see cref="HttpMessageSigningMessageInspector"/> to the client runtime.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Text;
using System.Xml;

namespace IdentityStream.HttpMessageSigning.ServiceModel {
namespace SparebankenVest.HttpMessageSigning.ServiceModel {
/// <summary>
/// A WCF message inspector that signs HTTP requests before they're sent.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ServiceModel.Description;
using IdentityStream.HttpMessageSigning;
using IdentityStream.HttpMessageSigning.ServiceModel;
using SparebankenVest.HttpMessageSigning;
using SparebankenVest.HttpMessageSigning.ServiceModel;

// ReSharper disable once CheckNamespace
namespace System.ServiceModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\IdentityStream.HttpMessageSigning\IdentityStream.HttpMessageSigning.csproj" />
<ProjectReference Include="..\SparebankenVest.HttpMessageSigning\SparebankenVest.HttpMessageSigning.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// HTTP signing constants.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Security.Cryptography;
using System.Threading.Tasks;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
internal static class HttpContentExtensions {
public static async Task<string> GetDigestHeaderValues(this HttpContent content, HashAlgorithmName digestAlgorithm) {
if (content is null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
internal static class HttpMessageExtensions {
public static bool HasHeader(this IHttpMessage message, string name) => message.TryGetHeaderValues(name, out _);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using IdentityStream.HttpMessageSigning;
using SparebankenVest.HttpMessageSigning;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
internal static class SignatureAlgorithmExtensions {
public static bool ShouldIncludeDateHeader(this ISignatureAlgorithm algorithm) =>
algorithm.Name.StartsWith("rsa", StringComparison.OrdinalIgnoreCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
#endif

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// Extensions to get a signature algorithm based on a X509 certificate.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// A collection of header names used for signing HTTP messages.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text;
using System.Threading.Tasks;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// Class to use for signing HTTP requests.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// Configuration for signing HTTP messages.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// Represents a HTTP message for signing.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Immutable;
using System.Security.Cryptography;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// An immutable per-request signing configuration.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Security.Cryptography;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// Convenience class for creating signature algorithms based on asymmetric algorithms.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Security.Cryptography;
using Hasher = System.Security.Cryptography.HashAlgorithm;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
// ReSharper disable once InconsistentNaming
internal class ECDsaSignatureAlgorithm : ISignatureAlgorithm {
public ECDsaSignatureAlgorithm(ECDsa ecdsa, HashAlgorithmName hashAlgorithm) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Security.Cryptography;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
// ReSharper disable once InconsistentNaming
internal class HMACSignatureAlgorithm : ISignatureAlgorithm {
public HMACSignatureAlgorithm(byte[] key, HashAlgorithmName hashAlgorithm) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Security.Cryptography;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// Represents an algorithm to use for signing HTTP messages.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Security.Cryptography;
using Hasher = System.Security.Cryptography.HashAlgorithm;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
// ReSharper disable once InconsistentNaming
internal class RSASignatureAlgorithm : ISignatureAlgorithm {
public RSASignatureAlgorithm(RSA rsa, HashAlgorithmName hashAlgorithm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System.Text;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
internal static class SignatureHeaderComposer {
public static string Compose(string signatureString, RequestHttpMessageSigningConfiguration config, DateTimeOffset timestamp) {
var builder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
/// <summary>
/// A delegating handler to be used with <see cref="HttpClient"/> for signing HTTP requests.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using System.Text;

namespace IdentityStream.HttpMessageSigning {
namespace SparebankenVest.HttpMessageSigning {
internal static class SigningStringComposer {
private static readonly char[] SplitValues = { '\n' };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
using VerifyXunit;
using Xunit;

namespace IdentityStream.HttpMessageSigning.Tests {
namespace SparebankenVest.HttpMessageSigning.Tests {
[UsesVerify]
public class HttpMessageSignerTests {
private const string KeyId = "d4db0d";

[Fact]
public async Task DefaultConfiguration_ProducesCorrectSignatureHeader() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

await SignAsync(message, config => {
config.AddRecommendedHeaders = true;
Expand All @@ -29,7 +29,7 @@ await SignAsync(message, config => {
public async Task HMacSigning_ProducesCorrectSignatureHeader() {
const string secret = "TopSecret";

var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

var hmacAlgo = SignatureAlgorithm.Create(Encoding.UTF8.GetBytes(secret), HashAlgorithmName.SHA256);

Expand All @@ -40,7 +40,7 @@ public async Task HMacSigning_ProducesCorrectSignatureHeader() {

[Fact]
public async Task AddRecommendedHeaders_False_DoesNotIncludeAnyHeaders() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

await SignAsync(message);

Expand All @@ -49,7 +49,7 @@ public async Task AddRecommendedHeaders_False_DoesNotIncludeAnyHeaders() {

[Fact]
public async Task CustomHeaders_AreIncludedInSignature() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello")) {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello")) {
Headers = {
{ "X-Custom-Header", new[] { "Hello" } }
}
Expand All @@ -67,7 +67,7 @@ await SignAsync(message, config => {

[Fact]
public async Task Digest_IsIncludedInSignature() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"), new StringContent("hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"), new StringContent("hello"));

await SignAsync(message, config => {
config.DigestAlgorithm = HashAlgorithmName.SHA512;
Expand All @@ -79,7 +79,7 @@ await SignAsync(message, config => {
[Theory]
[MemberData(nameof(HashAlgorithms))]
public async Task DigestHeader_IsAddedToRequest(HashAlgorithmName digestAlgorithm) {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"), new StringContent("hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"), new StringContent("hello"));

await SignAsync(message, config => {
config.DigestAlgorithm = digestAlgorithm;
Expand All @@ -99,7 +99,7 @@ public static IEnumerable<object[]> HashAlgorithms {

[Fact]
public async Task Expires_IsIncluded_WhenEnabled() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

await SignAsync(message, config => {
config.Expires = TimeSpan.FromMinutes(10);
Expand All @@ -110,7 +110,7 @@ await SignAsync(message, config => {

[Fact]
public async Task Created_IsIncluded_WhenEnabled() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

await SignAsync(message, config => {
config.HeadersToInclude.Add(HeaderNames.Created);
Expand All @@ -122,18 +122,18 @@ await SignAsync(message, config => {
[Fact]
public async Task HostHeader_IsAddedToRequest()
{
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

await SignAsync(message, config => {
config.HeadersToInclude.Add(HeaderNames.Host);
});

Assert.Equal("identitystream.com", message.Headers[HeaderNames.Host].Single());
Assert.Equal("www.spv.no", message.Headers[HeaderNames.Host].Single());
}

[Fact]
public async Task MissingHeader_Throws() {
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://identitystream.com/hello"));
var message = new TestHttpMessage(HttpMethod.Post, new Uri("https://www.spv.no/hello"));

await Assert.ThrowsAsync<InvalidOperationException>(() => SignAsync(message, config => {
config.HeadersToInclude.Add("X-Missing-Header");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using VerifyXunit;
using Xunit;

namespace IdentityStream.HttpMessageSigning.Tests {
namespace SparebankenVest.HttpMessageSigning.Tests {
[UsesVerify]
public class HttpMessageSigningHandlerTests {
private static readonly HttpRequestOptionsKey<string> SigningString = new(Constants.SigningString);
Expand All @@ -33,7 +33,7 @@ public async Task IncludedHeaders_AreAddedToRequest() {

using var client = new HttpClient(handler);

await client.PostAsync("https://identitystream.com/hello", new StringContent("hello"));
await client.PostAsync("https://www.spv.no/hello", new StringContent("hello"));

var request = recorder.Requests.Single();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using VerifyTests;

namespace IdentityStream.HttpMessageSigning.Tests
namespace SparebankenVest.HttpMessageSigning.Tests
{
public static class ModuleInitializer {
[ModuleInitializer]
Expand Down
Loading