Skip to content

Instantly share code, notes, and snippets.

@SteveSandersonMS
SteveSandersonMS / blazor-auth.md
Created June 11, 2019 10:49
Blazor authentication and authorization

Authentication and Authorization

Authentication means determining who a particular user is. Authorization means applying rules about what they can do. Blazor contains features for handling both aspects of this.

It worth remembering how the overall goals differ between server-side Blazor and client-side Blazor:

  • Server-side Blazor applications run on the server. As such, correctly-implemented authorization checks are both how you determine which UI options to show (e.g., which menu entries are available to a certain user) and where you actually enforce access rules.
  • Client-side Blazor applications run on the client. As such, authorization is only used as a way of determining what UI options to show (e.g., which menu entries). The actual enforcement of authorization rules must be implemented on whatever backend server your application operates on, since any client-side checks can be modified or bypassed.

Authentication-enabled templates for Server-Side Blazor

const path = require('path');
const webpack = require('webpack');
const apiUrl = 'http://localhost:3000';
module.exports = {
outputDir: './dist/public',
chainWebpack: config => {
config.plugin('html').tap(([options]) => [
Object.assign(options, {
@atiensivu
atiensivu / GnomeShellExtensions
Created September 11, 2017 20:13
Gnome Tweak Tool - enable user themes - No such schema “org.gnome.shell.extensions.user-theme”
sudo cp $HOME/.local/share/gnome-shell/extensions/user-theme@gnome-shell-extensions.gcampax.github.com/schemas/org.gnome.shell.extensions.user-theme.gschema.xml /usr/share/glib-2.0/schemas && sudo glib-compile-schemas /usr/share/glib-2.0/schemas
# One liner fix that shouldn't be necessary
@davidfowl
davidfowl / dotnetlayout.md
Last active May 5, 2024 11:47
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
static App()
{
var lang = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement), new FrameworkPropertyMetadata(lang)
);
var ceTypes = new Type[] {
typeof(System.Windows.Controls.DefinitionBase),
internal class MassTransitDispatcher : IObserver<ICommit>
{
private readonly IServiceBus _bus;
public MassTransitDispatcher(IServiceBus bus)
{
_bus = bus;
}
public void Dispose()
public class AreaFallowed
{
public AreaFallowed(string gardenID, NodaTime.LocalDate date, int x, int y, int width, int length)
{
GardenId = gardenID;
Date = date;
X = x;
Y = y;
Width = width;
Length = length;
@yreynhout
yreynhout / MemoryProjectionBuilder.cs
Last active August 29, 2015 14:01
Parking it here
using System;
using System.Linq;
namespace FiveMinuteProject
{
public class ProjectionBuilder<TState>
{
private readonly ProjectionHandler<TState>[] _handlers;
public ProjectionBuilder()
@yreynhout
yreynhout / ESInTheBrowser.html
Last active December 27, 2015 02:29
Parking
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.js"></script>
<script>
var AggregateRootEntity =
function AggregateRootEntityConstructor(options, my) {
var that = {},
handlers = options.handlers || {},
changes = [];
Say you are in a world where you want to use progressive enhancement (sometimes for accessibility)
with ASP.NET MVC 3+.
Progressive Enhancement means the site WORKS WITHOUT JAVASCRIPT FOLKS.
Now say you have something like comments that will be on multiple pages.
You want the site to be maintainable so you want to use a partial with
form submission.