Skip to content

Instantly share code, notes, and snippets.

View merken's full-sized avatar

Maarten Merken merken

View GitHub Profile
@merken
merken / OnModelCreating.cs
Created September 18, 2018 20:02
OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>()
.ToTable("DimCustomer");
modelBuilder.Entity<Customer>()
.HasKey("CustomerKey");
modelBuilder
.Entity<Customer>()
@merken
merken / DataController.1.cs
Created September 24, 2018 19:37
DataController.1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using auth.api.Extensions;
using auth.api.Security;
using auth.api.Security.MyDb;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@merken
merken / UsersController.1.cs
Created September 24, 2018 19:37
UsersController.1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using auth.api.Extensions;
using auth.api.Security;
using auth.api.Security.AzureAd;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@merken
merken / Create_auth_table.sql
Created September 25, 2018 05:15
Create_auth_table.sql
/****** Object: Table [dbo].[Authentication] Script Date: 24/09/2018 21:05:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Authentication](
[Id] [int] IDENTITY(1,1) NOT NULL,
@merken
merken / UsersController.2.cs
Last active September 25, 2018 20:06
UsersController.2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using auth.api.Security;
using auth.api.Security.AzureAd;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace auth.api.Controllers
@merken
merken / AzureAdExtensions.2.cs
Created September 25, 2018 20:34
AzureAdExtensions.2.cs
using System;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace auth.api.Security.AzureAd
{
public static class AzureAdExtensions
@merken
merken / UsersController.3.cs
Created September 25, 2018 20:34
UsersController.3.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using auth.api.Security;
using auth.api.Security.AzureAd;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace auth.api.Controllers
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
namespace auth.api.Security.AzureAd
{
public class AzureAdAuthFilterAttribute : TypeFilterAttribute
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using auth.api.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace auth.api.Controllers
{
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Extensions.DependencyInjection;
namespace auth.api.Security
{
public static class AuthenticationExtensions
{
public static MvcOptions AddGlobalAzureAuthentication(this MvcOptions mvcOptions)