From 66c793c4198580b4e1b8c5810ef2a5f024ace5f7 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Tue, 24 Feb 2026 21:23:36 +0000 Subject: [PATCH] Add runtime UI configuration --- ARCHITECTURE.md | 5 +- CHANGELOG.md | 4 + .../docs/configuration.md | 3 +- DevOidcToolkit.Documentation/docs/index.md | 1 + .../docs/runtime-management.md | 61 ++++++++ DevOidcToolkit/Pages/Clients.cshtml | 53 +++++-- DevOidcToolkit/Pages/Clients.cshtml.cs | 138 ++++++++++++++++++ DevOidcToolkit/Pages/Users.cshtml | 41 +++++- DevOidcToolkit/Pages/Users.cshtml.cs | 138 ++++++++++++++++++ README.md | 6 +- 10 files changed, 435 insertions(+), 15 deletions(-) create mode 100644 DevOidcToolkit.Documentation/docs/runtime-management.md create mode 100644 DevOidcToolkit/Pages/Clients.cshtml.cs create mode 100644 DevOidcToolkit/Pages/Users.cshtml.cs diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 1daec23..5694956 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -13,8 +13,9 @@ MkDocs](https://squidfunk.github.io/mkdocs-material/). This documentation is bot in to the application itself. The application reads the configuration on start up and then populates an in-memory database with users and OpenID -connect clients. This means there is no persistence between application restarts, as the in-memory database is -wiped and a new one is used. +connect clients. Additionally, users and clients can be created at runtime through the web interface at `/users` and +`/clients` respectively. Note that there is no persistence between application restarts, as the in-memory database is +wiped and a new one is used - any users or clients created at runtime will be lost upon restart. The frontend is styled using basic styling, using the [Sakura CSS library](https://github.com/oxalorg/sakura). diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f346b3..5833b95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Add configurable user roles through `DevOidcToolkit__Users__INDEX__Roles__INDEX` +- Add runtime user registration at `/users` page +- Add runtime OIDC client creation at `/clients` page + ## [0.4.0] - Add configurable `Issuer` field to override the `iss` claim in tokens and the OIDC discovery document diff --git a/DevOidcToolkit.Documentation/docs/configuration.md b/DevOidcToolkit.Documentation/docs/configuration.md index 6a8d625..d996995 100644 --- a/DevOidcToolkit.Documentation/docs/configuration.md +++ b/DevOidcToolkit.Documentation/docs/configuration.md @@ -1,7 +1,8 @@ # Configuration Dev OIDC Toolkit can be configured in two ways, either through environment variables, or through a JSON configuration -file. +file. Additionally, users and clients can be created and managed at runtime through the web interface - see +[Runtime Management](runtime-management.md) for details. ## Environment variable configuration diff --git a/DevOidcToolkit.Documentation/docs/index.md b/DevOidcToolkit.Documentation/docs/index.md index a136c0f..5a7f7e4 100644 --- a/DevOidcToolkit.Documentation/docs/index.md +++ b/DevOidcToolkit.Documentation/docs/index.md @@ -5,3 +5,4 @@ OpenID Connect identity provider for development and testing. - [Tutorial](tutorial.md) - [Configuration](configuration.md) +- [Runtime Management](runtime-management.md) diff --git a/DevOidcToolkit.Documentation/docs/runtime-management.md b/DevOidcToolkit.Documentation/docs/runtime-management.md new file mode 100644 index 0000000..0a297f7 --- /dev/null +++ b/DevOidcToolkit.Documentation/docs/runtime-management.md @@ -0,0 +1,61 @@ +# Runtime Management + +In addition to configuring users and clients through configuration files or environment variables, you can also create and manage them at runtime through the web interface. + +## Managing Users + +Navigate to `/users` to access the user management interface. + +### Creating Users + +1. Fill in the following fields: + - **Email**: The email address of the user + - **First Name**: The user's first name + - **Last Name**: The user's last name + - **Roles** (Optional): Comma-separated list of roles to assign to the user + +2. Click "Create User" + +Users created at runtime are immediately available for login. You can select them from the login dropdown to authenticate. + +### Assigning Roles + +You can assign one or more roles to a user: + +- **Select existing roles**: Enter role names that already exist in the system +- **Create new roles**: Enter new role names that will be created automatically if they don't exist +- **Multiple roles**: Separate multiple role names with commas, e.g., `admin, moderator, viewer` + +Roles are included in the OIDC tokens issued for users, allowing applications to check user permissions. + +## Managing Clients + +Navigate to `/clients` to access the client (OIDC application) management interface. + +### Creating Clients + +1. Fill in the following fields: + - **Client ID**: A unique identifier for the client + - **Client Secret**: A secret string shared between the client and the identity provider + - **Redirect URIs** (Optional): Comma-separated list of URIs where the user will be redirected after authentication + - **Post-Logout Redirect URIs** (Optional): Comma-separated list of URIs where the user will be redirected after logout + +2. Click "Create Client" + +Newly created clients are immediately available and can be used for OpenID Connect flows. + +### Configuring Redirect URIs + +Both redirect URIs and post-logout redirect URIs should be valid, complete URLs: + +``` +http://localhost:3000/callback, https://example.com/oauth/callback +``` + +URIs are validated on submission to ensure they are properly formatted. + +## Important Notes + +- **No Persistence**: Users and clients created at runtime exist only in the in-memory database. They will be lost when the application restarts. +- **Configuration + Runtime**: You can use both configuration-based users/clients and runtime-created ones simultaneously. +- **Role Management**: Roles created at runtime persist for the lifetime of the application and can be assigned to multiple users. diff --git a/DevOidcToolkit/Pages/Clients.cshtml b/DevOidcToolkit/Pages/Clients.cshtml index f741c0b..7397a3a 100644 --- a/DevOidcToolkit/Pages/Clients.cshtml +++ b/DevOidcToolkit/Pages/Clients.cshtml @@ -1,27 +1,62 @@ @page "/clients" -@using OpenIddict.Abstractions -@using OpenIddict.Core -@using System.Linq -@using Microsoft.EntityFrameworkCore -@using OpenIddict.EntityFrameworkCore.Models @using System.Text.Json -@inject DevOidcToolkitContext DbContext +@model DevOidcToolkit.Pages.ClientsModel @{ Layout = "_Layout"; - ViewData["Title"] = "clients"; + ViewData["Title"] = "Clients"; } Return to homepage

Clients

+

Create New Client

+ +@if (!string.IsNullOrEmpty(Model.SuccessMessage)) +{ +
+ @Model.SuccessMessage +
+} + +@if (!string.IsNullOrEmpty(Model.ErrorMessage)) +{ +
+ @Model.ErrorMessage +
+} + +
+ + + + + + + + + + + + + + + + + +
+ +
+ +

Existing Clients

+ @{ - var clients = await DbContext.Set().ToListAsync(); + var clients = Model.Clients ?? []; } @if (clients?.Any() == true) { -