Web

Customizing Keycloak with Aspire - Part 3

October 04, 2024  6 minute read  

This is the last article in a trio of articles about incorporating Keycloak into .NET Aspire applications. Thus far, I’ve covered the basics and some common customizations. This part covers what you need to do if you want to store the identity information within a PostgreSQL database. I’ve chosen PostgreSQL for this because it seems to be the database of choice for Aspire when you want to run things locally and in the cloud and also because the PostgreSQL database driver is included by def...

Customizing Keycloak with Aspire - Part 2

September 30, 2024  4 minute read  

In my last article, I introduced the Keycloak identity service and showed how the development version can be easily integrated into a project. Development services get you started quickly and allow you to defer the details until later on. At some point, however, you need to take control of your service and start working towards production. There are a number of things that the development version of the Keycloak identity service doesn’t do that you need in production. These include SSL/TL...

Integrating Keycloak with Aspire - Part 1

September 26, 2024  8 minute read  

In my series on ASP.NET Identity, I mentioned (several times) that you should be using Keycloak, Auth0, Corbado, or another identity service instead of rolling your own. That’s all good, but I left it up to you to figure out exactly how to do that. I thought it would be a good idea to configure an Aspire project from the beginning and show how authentication and authorization with a service works. This article will be more of a “make the code work” type of article, with follow-on articles ...

ASP.NET Identity deep dive - Part 6 (Social logins)

September 20, 2024  11 minute read  

This article is one of a number of articles I will write over the coming month and will go into depth about the ASP.NET Identity system. My outline thus far: Project setup Account registration Signing in and out with a username and password Password reset Email confirmations Social logins Now that I have the basic flows sorted out (which includes username/password with registration, self-service password reset, and account lockout support), it’s time to turn my attention to o...

ASP.NET Identity deep dive - Part 5 (Sending email)

September 18, 2024  12 minute read  

This article is one of a number of articles I will write over the coming month and will go into depth about the ASP.NET Identity system. My outline thus far: Project setup Account registration Signing in and out with a username and password Password reset Email confirmations Social logins Today is the final spot for the basic flows. Up to this point, I’ve been logging links in places where I should be sending emails. Sending emails in development is scary. First, things co...

ASP.NET Identity deep dive - Part 4 (Password reset)

September 16, 2024  7 minute read  

This article is one of a number of articles I will write over the coming month and will go into depth about the ASP.NET Identity system. My outline thus far: Project setup Account registration Signing in and out with a username and password Password reset Email confirmations Social logins I’ve already implemented the registration and login/logout functionality. I’ve also done some updates since the last check in. Most notably, I’ve automatically signed the user in after regis...

ASP.NET Identity deep dive - Part 3 (Authentication)

September 14, 2024  6 minute read  

This article is one of a number of articles I will write over the coming month and will go into depth about the ASP.NET Identity system. My outline thus far: Project setup Account registration Signing in and out with a username and password Password reset Email confirmations Social logins Today, I’m tackling authentication - that is, signing in and out of an account using the web UI. You may remember from my last article that I set up the initial web UI to include a link to ...

ASP.NET Identity deep dive - Part 2 (Registration)

September 13, 2024  13 minute read  

This article is one of a number of articles I will write over the coming month and will go into depth about the ASP.NET Identity system. My outline thus far: Project setup Account registration Signing in and out with a username and password Password reset Email confirmations Social logins As you may remember from the last article, the first user journey I am going to implement is the registration journey. This is actually one of the more complex journeys with several parts t...

ASP.NET Identity deep dive - Part 1 (Project setup)

September 11, 2024  8 minute read  

You may have noticed that I included ASP.NET Identity in a project a couple of posts ago. I’m currently doing a deep dive into ASP.NET Identity with an eye towards an OIDC identity service based on OpenIddict. Identity is a complex topic and I still recommend that developers integrate another service rather than write their own: Keycloak is a good option if you have to store your own data, Auth0 is a good option when you just want a bunch of social providers, Corbado has support for...

Making ASP.NET Core applications readable - the options patterns

September 03, 2024  6 minute read  

Applications are read more often than they are written. The normal situation when a developer comes onto a project is that anything from a couple of weeks to several months is requried to come “up to speed” on the code base. Making the efforts required for readability of the code is important, and I spend a ton of time up front to ensure my applications are understandable without needing an in-depth lesson from me on how it works. Let’s take an application I am starting (today actually). I...

Building Bootstrap apps from SASS with ASP.NET Core

August 08, 2024  6 minute read  

I’m building a new web application with ASP.NET Core, and I’m using Visual Studio Code with the C# Dev Kit so that I can really dive deep into the benefits and problems of using VS Code as a Visual Studio replacement. A frontend project is a good one to start with since I can check out the ways that the solution is presented while still having all the goodness of the VS Code development experience for JavaScript and TypeScript. As part of the application, I wanted to build a lean Bootstrap C...

Organizing service injection in ASP.NET Core Minimal APIs

August 07, 2024  4 minute read  

For the longest time, the Controller was the only way to introduce an API into your application. With the latest versions of ASP.NET Core, Minimal APIs became available. These offered the potential to write less code and be more efficient since they didn’t carry the baggage of the controller with them. That does come with some drawbacks, however. For me, one of the main ones is that it is so much easier to write unreadable code. WIth some basic practices, however, you can use minimal APIs ...

Converting a TypeScript project from CommonJS to ESM

July 06, 2024  6 minute read  

I haven’t made much progress on my own projects recently because of a project at work. Specifically, I am currently maintaining a CLI tool written in TypeScript about five years ago. It hasn’t really been looked after on a consistent basis, but some of the libraries that it uses (specifically, update-notifier and wait-on) have some security issues. Now, this is a development CLI tool, so the actual vulnerabilities don’t affect production code. Still, many people don’t like to use tools th...

The State of React UI libraries in 2024

June 27, 2024  7 minute read  

As I mentioned in my last post, I’ve been away from React development for a while, and I’m intending on writing a web application. I’m comparing the various libraries that I can use for my application. In this post, I’m going to be comparing UI component libraries. Thus far, my tech stack is: Base web framework: React Frontend tooling: Vite Hosting: Azure Static Web Apps State management: Redux Toolkit React UI component libraries are collections of ready-to-use UI elements that...

The State of React state management in 2024

June 25, 2024  13 minute read  

I’ve been away from React development for a while. I stupidly asked what the best way to create a React app was in 2024 on the React subreddit, and found that reddit is not a friendly or welcoming community. For those wondering, there are three ways of creating a React app - Vite, Remix, and NextJS - but the community suggests Vite. Given the somewhat frosty reception I got on the React subreddit, I decided to do my own research across a number of topics for a new project - a social media c...

Azure Active Directory Authentication for Blazor WASM (Part 4: SignalR)

September 23, 2022  3 minute read  

I really thought I was through with Azure Active Directory! Honest! However, another key piece came up. My CloudMud is a real-time pub/sub application that uses SignalR. How do I authenticate to the SignalR connection? Well, like most things, there is a recipe. So let’s get to it. The Server side of things Let’s take a look at the unauthenticated version first. I need to integrate SignalR into my app. Fortunately, there is a tutorial for that. I just followed it. This involved: ...

Azure Active Directory Authentication for Blazor WASM (Part 3: Production)

September 03, 2022  12 minute read  

Recently, I’ve been working on integrating authentication with Azure Active Directory into my Blazor app. I’ve covered the server side and the client side, so what’s left? Well, firstly, I left “secrets” in my client app in the form of an appsettings.json file. They aren’t exactly secret values, but having specific values in there means I can’t have different values for different environments. Similarly, I can’t change those values over time - I have to re-build the app in order to change...

Azure Active Directory Authentication for Blazor WASM (Part 2: The Client)

September 02, 2022  7 minute read  

I’m in the middle of adding authentication to my Blazor WASM app. In the last article, I introduced the service side of things to consider when integrating Azure Active Directory authentication. It’s now time to complete the work by considering the Blazor WASM client. As there was last time, this is [well documented], but comes with some wrinkles when you consider bringing authentication into an app later. I’ve got a Sign-in button called AuthButton.razor that looks like this: <button...

Azure Active Directory Authentication for Blazor WASM (Part 1: The Server)

September 01, 2022  8 minute read  

Continuing my foray into Blazor WASM, I decided to tackle authentication. The Microsoft documentation has an excellent article on how to do this using the built-in tooling to create an AAD-enabled Blazor WASM application. However, I’m beyond the tooling at this point. My Blazor app is created. I need to augment the solution with the right code to enable authentication. I also want to make sure that I am not leaking secrets and the same code will work from development, through staging, to...

Building Stylesheets for Blazor with SASS

August 26, 2022  8 minute read  

As I mentioned in my last article, I’m building a cloud-based MUD using all the modern techniques that I have available to me. One of the things I decided was that I was going to use an ASP.NET Core application hosting a single-page web application written in Blazor and I’m going to be running that inside a Docker image so I can deploy it onto Azure Container Apps. Scaffolding the app out is easy: $ mkdir cloudmud $ cd cloudmud $ dotnet new blazorwasm $ .\cloudmud.sln This opens up Visual...

Add unit testing to your React app

April 02, 2020  9 minute read  

Thus far, in my journey to produce a customized toolchain for my React development, I’ve covered a lot of ground. See part 1 and part 2 for that coverage. I’ve come to the point where I need to discuss testing, which is a complex area. First, there are at least four types of testing you need to do: Unit testing is something you should be running on a regular basis - a series of tests that test each component to ensure that the functionality is correct from the outside. Integration te...

Add visual testing to your React app with Storybook

March 31, 2020  7 minute read  

In my last article, I started a React app from scratch, then integrated Parcel as the bundler, TypeScript for language support, SASS, ESLint for linting the code, and Stylelint for linting the style sheets. I didn’t include any testing capabilities, so that is next on my agenda. Let’s write a simple component to get started with testing. The component takes an “isBusy” flag. If it is true, then one icon is displayed. If false, a different icon is displayed. I’ll use text nodes in this v...

Building a React app with Parcel, Typescript, SASS, and ESLint

March 29, 2020  9 minute read  

create-react-app (CRA) is great for getting started super-fast. It has just about everything you need for building all but the most demanding apps. It is, however, opinionated in how things get set up, and I’ve been chafing at the limitations for a while. You can’t alter the tsconfig.json except in some non-important ways. It uses webpack underneath, and that is unchangeable. It uses jest and testing-library. Changing this is a pain. There are even packages that rewire the CRA so...

Integrating Microsoft Login and MSAL with React and Redux

March 06, 2020  9 minute read  

I have a new app I am working on. It’s sort of a 1990’s style text MUD, but I’m bringing it “up to this century” with a host of new features. I’m writing the first front-end in React. So, what does a modern MUD app look like? Well, I’m not into storing usernames and password any more, so I’m going to use a Microsoft OAuth service instead of a user database. My front end application handles state through Redux. Configuring Redux I’ve got a store set up as follows: import { applyMiddlew...

Run TypeScript Mocha Tests in Visual Studio Code

July 04, 2018  7 minute read  

I’m spending my July 4th getting back to basics and learning some data structures and algorithms. I’ve decided to do my stuff in TypeScript since it’s been a while since I’ve played with TypeScript and I wanted to see what has changed at the same time. This is not a blog post about how to do data structures and algorithms in TypeScript, JavaScript or any other language. If you are studying for an interview or classes, there are plenty of places on the Internet you can go to do that. Personal...

The React Toolbox - 2018 Edition

March 23, 2018  5 minute read  

It’s been a while since I’ve been in web development. I’ve mostly been concentrating on mobile development instead. But this week I had cause to delve again. It’s amazing how much change there has been in the web world in just 2 years. React has become the force in web frameworks (Sorry Angular — I never liked you anyway) and developers are starting to coalesce around libraries and tools that make their life easier. I thought I’d put down my thoughts on the libraries that are making it into m...