Skip to content

Instantly share code, notes, and snippets.

View rbrayb's full-sized avatar

rbrayb rbrayb

View GitHub Profile
using System;
using System.Security.Cryptography;
using System.Text;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Encodings;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using System;
using System.Security.Cryptography;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Crypto.Encodings;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
namespace BCMediumConsoleApp
// Headers e.g.
// string header2048 = "0602000000A40000525341310008000001000100";
private byte[] CreatePublicKey(byte[] publicKey)
{
byte[] publicKey = new byte[publicKey.Length];
byte[] header = null;
foreach (KeyValuePair<int, string> keyPair in headersList)
@rbrayb
rbrayb / Configure.cs
Last active August 13, 2018 01:52
idsrv4 SAML
app.UseIdentityServer();
// Use SAML middleware.
app.UseSaml();
// Specify the display name and return URL for logout.
app.Use(async (context, next) =>
{
if (context.Request.Path.Value.Equals("/Account/Logout", StringComparison.OrdinalIgnoreCase) &&
string.IsNullOrEmpty(context.Request.Query["logoutId"]))
{
@rbrayb
rbrayb / ExampleSP-appsettings.json
Created August 28, 2018 19:35
Connecting two instances of IdentityServer 4 using the ComponentSpace SAML v2.0 for .NET Core stack
{
"Name": "https://IdentityServer4",
"Description": "IdentityServer4",
"SignAuthnRequest": true,
"SingleSignOnServiceUrl": "http://localhost:6000/SAML/SingleSignOnService",
"SingleLogoutServiceUrl": "http://localhost:6000/SAML/SingleLogoutService",
"PartnerCertificates": [
{
"FileName": "certificates/idp.cer"
}
@rbrayb
rbrayb / idsrv4-5000-Config.cs
Created September 5, 2018 19:56
Connecting two instances of IdentityServer 4 using the ComponentSpace SAML v2.0 for .NET Core and the Rock Solid Knowledge SAML v2.0 for .NET Core stack
// SAML client
new Client
{
ClientId = "https://IdentityServer4",
ClientName = "idsrv4 CS",
ProtocolType = IdentityServerConstants.ProtocolTypes.Saml2p,
AllowedScopes = {"openid", "profile"}
}
...
@rbrayb
rbrayb / ContentDefinitions.xml
Created December 20, 2018 20:17
B2C ContentDefinitions with updated contracts
<ContentDefinitions>
<!-- This content definition is to render an error page that displays unhandled errors. -->
<ContentDefinition Id="api.error">
<LoadUri>~/tenant/default/exception.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<!-- <DataUri>urn:com:microsoft:aad:b2c:elements:globalexception:1.1.0</DataUri> -->
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:globalexception:1.1.0</DataUri>
<Metadata>
<Item Key="DisplayName">Error page</Item>
@rbrayb
rbrayb / TrustFrameworkExtensions.xml
Created January 17, 2019 20:03
Customising the message text in Azure AD B2C custom policies
// Part of the file
<ContentDefinition Id="api.localaccountsignup">
...
<Metadata>
<Item Key="DisplayName">Local account sign up page</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.localaccountsignup.en" />
</LocalizedResourcesReferences>
// Part of the file
<ContentDefinition Id="api.localaccountsignup">
...
<Metadata>
<Item Key="DisplayName">Local account sign up page</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.localaccountsignup.en" />
</LocalizedResourcesReferences>
@rbrayb
rbrayb / IDP Comparison.csv
Created January 31, 2019 18:26
Comparing the Identity Providers (IDP’s) that I use
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 5.
Functions,,Azure AD,Azure AD B2C,ADFS 3.0,ADFS 4.0,identityserver,Auth0
,,,,,,,
Authenticate against,,Azure AD,"Azure AD
(but different tenant type to AAD)",AD,"AD
LDAP v3.0",Anything,"AD
LDAP
SQL DB
Auth0 repository"
,,,,,,,
"WS-Federation