Skip to content

Instantly share code, notes, and snippets.

@nzpcmad
nzpcmad / Startup.cs
Created July 21, 2016 02:40
.NET Core MVC application to ADFS on Windows Server 2016
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
@nzpcmad
nzpcmad / Contact.cshmtl
Last active December 7, 2017 14:41
Displaying claims in an .NET Core MVC application to Azure AD
@{
ViewBag.Title = "User Claims";
}
<h2>Welcome: @ViewBag.Name</h2>
<h3>Values from Identity</h3>
<table>
<tr>
<th>
IsAuthenticated -
@nzpcmad
nzpcmad / PasswordReset.xml
Last active August 31, 2017 22:28
Azure AD B2C custom policies with Azure AD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TrustFrameworkPolicy
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06"
PolicySchemaVersion="0.3.0.0"
TenantId="my-b2c.onmicrosoft.com"
PolicyId="B2C_1A_PasswordReset"
PublicPolicyUri="http://my-b2c.onmicrosoft.com/B2C_1A_PasswordReset">
@nzpcmad
nzpcmad / gist:2f274f5ca2d93a6f37e06ef610259db2
Created November 8, 2016 19:12
Postman : Authorisation Code Grant on Server 2016 - ADFS 4.0 - with template web API
{
"variables": [],
"info": {
"name": "ADFS My IIS",
"_postman_id": "f2145f47-b93d-b35a-5707-c115e866bf2b",
"description": "Auth code flow.",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
@nzpcmad
nzpcmad / AssignOAuth2SecurityRequirements.cs
Last active June 27, 2017 12:54
Using Swagger for Implicit Grant on Azure AD
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Swashbuckle;
using Swashbuckle.Swagger;
using System.Web.Http.Description;
namespace TodoListService
@nzpcmad
nzpcmad / Form.cs
Created April 5, 2017 19:37
C# code to send email
private void button1_Click(object sender, EventArgs e)
{
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
try
{
mailMessage.From = new System.Net.Mail.MailAddress("me@help.com", "me@Sender.com");
mailMessage.To.Add("my-email");
mailMessage.Subject = "Hullo";
mailMessage.Body = "This is a test";
mailMessage.IsBodyHtml = true;
{
"variables": [],
"info": {
"name": "Maths WebAPI",
"_postman_id": "47568f67-6685-f39a-8d7f-2cd76a9b281a",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
@nzpcmad
nzpcmad / AssignOAuth2SecurityRequirements.cs
Last active December 11, 2016 20:13
Using Swagger for Implicit Grant on ADFS 4.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Swashbuckle;
using Swashbuckle.Swagger;
using System.Web.Http.Description;
namespace TodoListService
@nzpcmad
nzpcmad / ADFS%20Public%20-%20Implicit%20-%20ADFS%204.0%20Release.postman_collection.json
Created November 27, 2016 20:06
Postman : Using Postman for Implicit Grant on ADFS 4.0
{
"variables": [],
"info": {
"name": "ADFS Public - Implicit - ADFS 4.0 Release",
"_postman_id": "44d70984-95c6-375e-af63-ff5bd98e8238",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
@nzpcmad
nzpcmad / Config - HttpDocumentRetriever.cs
Created June 8, 2016 04:32
Azure B2C with IdentityServer (sign-in only)
using Microsoft.IdentityModel.Protocols;
using System;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Per https://azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-devquickstarts-web-dotnet/
namespace Host.Configuration