Skip to content

Instantly share code, notes, and snippets.

View beachside-project's full-sized avatar
😄

Atsushi YOKOHAMA beachside-project

😄
View GitHub Profile
@beachside-project
beachside-project / Program.cs
Created June 5, 2020 09:26
ASP.NET Core 3.x - remove server header sample
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
@beachside-project
beachside-project / AppRoles.cs
Created June 3, 2020 10:39
Azure AD - AppRoles AuthZ sample - AppRoles.cs
namespace AzureAdAppRolesWebSample
{
public static class AppRoles
{
public const string SettingsReader = "settings-reader";
public const string SettingsWriter = "settings-writer";
public const string Admin = "Admin";
}
}
@beachside-project
beachside-project / SampleController.cs
Created June 3, 2020 10:31
Azure AD - AppRoles AuthZ sample - SampleController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace AzureAdAppRolesWebSample.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class SampleController : ControllerBase
@beachside-project
beachside-project / Startup.cs
Last active November 24, 2020 15:20
Azure AD - AppRoles AuthZ sample - Startup.cs
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@beachside-project
beachside-project / Program.cs
Last active April 20, 2020 16:20
AAD B2C Custom Attribute Operation sample - full
using Microsoft.Graph;
using Microsoft.Graph.Auth;
using Microsoft.Identity.Client;
using System;
using System.Collections.Generic;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
using System.Threading.Tasks;
@beachside-project
beachside-project / Program.cs
Created April 19, 2020 14:39
AAD B2C Custom Attribute Operation sample - 2
private static GraphServiceClient CreateGraphServiceClient()
{
var confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(AppId)
.WithTenantId(TenantId)
.WithClientSecret(ClientSecret)
.Build();
var authProvider = new ClientCredentialProvider(confidentialClientApplication);
@beachside-project
beachside-project / Program.cs
Created April 17, 2020 13:26
AAD B2C Custom Attribute Operation sample - 1
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
private const string TenantId = "";
private const string AppId = "";
private const string ClientSecret = "";
@beachside-project
beachside-project / Program.cs
Created March 30, 2020 10:17
Global Query Filter: sample1 - Program.cs - IgnoreQueryFilters
using ConsoleApp1.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
internal class Program
{
private static async Task Main()
@beachside-project
beachside-project / Program.cs
Last active March 30, 2020 10:11
Global Query Filter: sample1 - Program.cs
using ConsoleApp1.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
internal class Program
{
private static async Task Main()
@beachside-project
beachside-project / ItemContext.cs
Created March 30, 2020 09:29
Global Query Filter: sample1 - ItemContext.cs
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace ConsoleApp1.Models
{
public class ItemContext : DbContext
{
public DbSet<Item> Items { get; set; }
public static readonly ILoggerFactory ItemContextLoggerFactory