Skip to content

Instantly share code, notes, and snippets.

View EdCharbeneau's full-sized avatar
🏠
Working from home

Ed Charbeneau EdCharbeneau

🏠
Working from home
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.RegularExpressions;
@EdCharbeneau
EdCharbeneau / app.css
Created February 17, 2023 16:54
REPL Example
.banner {
font-size: 32px;
background-color: red;
color: white;
}
@EdCharbeneau
EdCharbeneau / ConfigurationExtensions.cs
Created August 10, 2022 13:38
Adds a JSON configuration source to builder for MAUI using appsettings.json
public static class ConfigurationExtensions
{
/// <summary>
/// Adds a JSON configuration source to builder
/// </summary>
/// <param name="config"></param>
/// <param name="configResourceName"></param>
/// <returns>The IConfigurationBuilder</returns>
public static IConfigurationBuilder AddJsonResource(this IConfigurationBuilder config, string configResourceName)
{
@EdCharbeneau
EdCharbeneau / StringBuilderExtensions.cs
Created March 22, 2022 16:48
String Builder cleanup
public static class StringBuilderExtensions {
public static StringBuilder AppendWhen(this StringBuilder sb, string value, bool predicate) {
if(predicate) {
sb.Append(value);
}
return sb;
}
}
@EdCharbeneau
EdCharbeneau / all.scss
Last active February 3, 2022 21:23
Minimal Gulp for Telerik Themes
@import "~@progress/kendo-theme-bootstrap/dist/all";
/*highlight the small rows*/
.main-layout > div:nth-child(4n-1), .main-layout > div:nth-child(4n) {
background: #777
}
.main-layout > div {
display: flex;
align-items: center;
justify-content: center;
border-radius: 5px;
@EdCharbeneau
EdCharbeneau / index.razor
Created February 25, 2021 15:13
Custom Events in Telerik Form component
@page "/"
@using System.ComponentModel.DataAnnotations
@inject NavigationManager NavigationManager
<div class="demo-section auto">
@if (ValidSubmit)
{
<div class="demo-alert demo-alert-success" role="alert">
The form was submitted successfully.
</div>
@EdCharbeneau
EdCharbeneau / BearerScheme.cs
Created June 4, 2020 17:08
Swagger Authorization
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description =
"JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});
@EdCharbeneau
EdCharbeneau / RemoteAuthenticatorView.razor
Created June 4, 2020 15:41
All the RemoteAuthenticatorView templates
<RemoteAuthenticatorView Action="@Action">
<LoggingIn>
<span>Logging you in...</span>
</LoggingIn>
<CompletingLoggingIn>
<span>Checking permissions...</span>
</CompletingLoggingIn>
<LogInFailed>
<span>Sorry, your login failed. Please try again or contact support.</span>
</LogInFailed>
@EdCharbeneau
EdCharbeneau / How to use Razor Components with Auth.md
Last active August 13, 2021 14:05
Blazor powered auth pages

A tip sent to me by Brian Douglass...

The way it works is:

  • Create a new Server project with Identity activated, but no scaffolding
  • Modify Startup.cs to add the AF token as a header
  • Create a custom SignIn.razor
    • Collects credentials in a form
    • OnValidSubmit() after checking validity of credentials
      • Make Http call to Login.OnGet() and get the form, with the AF token attached
  • Build new request with Credentials + AF token in the Form data + AF token in the header.