Skip to content

Instantly share code, notes, and snippets.

@nzpcmad
nzpcmad / ws-fed-auth0.js
Created February 17, 2016 01:12
Node.js with Express SSL, WS-Fed and ADFS
// http://collectivegarbage.azurewebsites.net/use-thinktecture-identity-server-v2-to-authenticate-your-node-application/
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
passport = require('passport'),
wsfedsaml2 = require('passport-wsfed-saml2').Strategy;
@nzpcmad
nzpcmad / List - Startup.Auth.cs
Created March 21, 2016 22:51
WebApp-WebAPI-OpenIDConnect-DotNet-TP4-Git - Sample for ADFS 4.0 - Server 2016
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
/*app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Audience = ConfigurationManager.AppSettings["ida:Audience"],
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
@nzpcmad
nzpcmad / Client - MainWindow.xaml.cs
Created March 30, 2016 20:59
NativeClient-WebAPI-DotNet-TP4-Git - Sample for ADFS 4.0 - Server 2016
// ADFS 4.0
/*private static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance"];
private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"];
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
Uri redirectUri = new Uri(ConfigurationManager.AppSettings["ida:RedirectUri"]);
private static string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenant);*/
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
Uri redirectUri = new Uri(ConfigurationManager.AppSettings["ida:RedirectUri"]);
@nzpcmad
nzpcmad / Contact.cshtml
Created April 21, 2016 01:54
Displaying claims in an ASP.NET MVC application
@*Replace existing code with ...*@
@{
ViewBag.Title = "User Claims";
}
<h2>Welcome: @ViewBag.ClaimsIdentity.Name</h2>
<h3>Values from Identity</h3>
<table>
<tr>
@nzpcmad
nzpcmad / Daemon - App.config
Created April 27, 2016 21:28
Daemon and Web API on Server 2016 TP4 ADFS 4.0
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<!--ADFS 4.0-->
<add key="ida:ClientId" value="bee24b9a-13ac-45fc-988c-8cce06160c07" />
<add key="ida:AppKey" value="wp...nE" />
<add key="todo:TodoListResourceId" value="https://localhost:44326/NativeTodoListService" />
@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
@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 / 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 / Azure%20AD.postman_collection - Public.json
Created August 24, 2016 01:52
Postman collection to get userinfo via Azure AD and OpenID Connect / OAuth 2.0
{
"variables": [],
"info": {
"name": "Azure AD Public",
"_postman_id": "d557d80b-e1a8-2922-ed57-bf7768032434",
"description": "Auth code flow.",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
@nzpcmad
nzpcmad / ADFS.postman_collection - Public.json
Last active June 27, 2022 23:03
Postman collection to get userinfo via ADFS 4.0 and OpenID Connect / OAuth 2.0
{
"variables": [],
"info": {
"name": "ADFS Public",
"_postman_id": "3d8a90ce-eb38-fedf-8bfe-b75578dd0810",
"description": "Auth code flow.",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{