Solhigson.Admin 10.6.0

dotnet add package Solhigson.Admin --version 10.6.0
                    
NuGet\Install-Package Solhigson.Admin -Version 10.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Solhigson.Admin" Version="10.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Solhigson.Admin" Version="10.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Solhigson.Admin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Solhigson.Admin --version 10.6.0
                    
#r "nuget: Solhigson.Admin, 10.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Solhigson.Admin@10.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Solhigson.Admin&version=10.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Solhigson.Admin&version=10.6.0
                    
Install as a Cake Tool

Solhigson.Admin

Admin screens for Solhigson apps, built as Razor components and rendered on the server: static server rendering with enhanced navigation, no interactive mode. It builds on Solhigson.Framework.Core.

An app owns its routes. The package ships no page: every component here is placed by the app, on a page the app declares with its own @page route and its own permission.

The head

KitHead (Solhigson.Admin.Components) links the kit's stylesheets, kit.css first, through Assets[...], so a host that calls app.MapStaticAssets() serves each at its content-specific url. Place it in the app's <head>, before the app's own stylesheets:

<head>
    <KitHead Nonce="@nonce" />
    <link rel="stylesheet" href="@Assets["app.css"]" />
</head>

Nonce is optional. An app whose Content-Security-Policy allows styles or scripts by nonce passes the nonce it generated for this response's CSP header, fresh for each response, never a value read from the request; KitHead puts it on every link and script it emits.

After its stylesheets, KitHead loads the kit's scripts with defer: first kit.core.js, which hands Blazor what kit.notice.js and kit.nav.js run after each enhanced navigation (kit.forms.js, kit.theme.js and kit.menu.js hand their own); kit.forms.js, the busy mark under Buttons; kit.theme.js, the switch under Light and dark; kit.dialog.js, which opens and fills the dialogs under Dialogs and confirms; kit.menu.js, which places the row menus under Row menus; kit.notice.js, which tells a screen reader what a notice says under Notices; and kit.nav.js, which moves a page changed to in from the side it came from under The admin shell.

Tokens

kit.tokens.css states every colour, size, space, radius, shadow, duration and font the kit reads, as --kit-* custom properties on :root; no other kit stylesheet holds a value of its own. The kit's one colour is black: the ink is #000000 and every grey is untinted; the four states (success, warn, danger, info) are its only hues.

Each colour and shadow has a dark value, but a code to scan's ink and paper, which hold black and white in both themes (see Codes to scan). A page follows the reader's prefers-color-scheme unless it sets data-theme="light" or data-theme="dark" on its <html> element. Every text and state colour meets WCAG contrast 4.5 to 1 on the surfaces it sits on, and the control border and focus ring 3 to 1, in both themes.

The fonts are the reader's system faces; the package ships no font file and links no font host. An app that wants other faces sets --kit-font-sans, --kit-font-serif and --kit-font-mono.

Overriding the kit

kit.css, the first stylesheet KitHead links, names the cascade layers, lowest first: @layer reset, kit.tokens, kit.base, kit.components, app;. KitHead goes before the app's stylesheets, since layer order is set where a layer is first seen. A rule in a later layer beats one in an earlier layer whatever its specificity, so an override in app needs no !important; no kit rule uses !important or an id selector.

An app overrides the kit at three levels, each in its own @layer app:

  1. A global token, such as --kit-ink, set on :root. A token override gives its own dark value, in the two blocks the kit uses: under @media (prefers-color-scheme: dark) on :root:not([data-theme="light"]), and on :root[data-theme="dark"]. Without them your light value stays in dark mode, on the kit's dark surfaces: a layer beats the kit whatever its selector. An app overriding --kit-ink sets --kit-on-ink, the text on it, beside it in each theme, and --kit-ink-hover, a primary button's fill under the pointer; one overriding --kit-state-danger sets --kit-state-danger-hover likewise. The focus ring is black (white in dark) and stays so: an app re-inking the kit decides --kit-focus itself.
  2. A component token, such as --kit-mark-gap or --kit-btn-height, which a component reads before its global fallback (var(--kit-mark-gap, var(--kit-sp-1))). The kit sets no component token; an app sets it, on :root or on the component. The one exception is --kit-btn-busy-width, which kit.forms.js sets on a busy button to the width it had, and which an app does not set.
  3. A rule of the app's own that selects a kit class, such as .kit-mark-version.
@layer app {
    :root { --kit-ink: #143f2a; --kit-on-ink: #ffffff; --kit-mark-gap: var(--kit-sp-2); }
    @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --kit-ink: #7fc8a2; --kit-on-ink: #000000; } }
    :root[data-theme="dark"] { --kit-ink: #7fc8a2; --kit-on-ink: #000000; }
    .kit-mark-version { color: var(--kit-fg-muted); }
}

A kit component is a name kit.manifest.json declares in its components, with its classes. Its parts keep single hyphens (.kit-mark-name): a class belongs to the longest declared component it starts with, so .kit-mark-name is kit-mark's, and a component's tokens are named --<component>-*, so --kit-mark-gap is kit-mark's. A new component is declared by adding its name to the manifest's components, a name that is a kit class some kit rule selects (kit-mark for .kit-mark); the manifest's regeneration test then fills in its classes.

An app's reset goes in the reset layer, below the kit's, so the kit's rules still apply over it. An unlayered rule beats every layer, so a legacy unlayered stylesheet on the same page (Bootstrap) overrides the kit. Import it into a layer the kit names instead, after KitHead: @import url("bootstrap.css") layer(reset);. A layer name kit.css does not declare lands above app, so a legacy stylesheet in a layer of its own would still beat the app's overrides.

kit.manifest.json, served at _content/Solhigson.Admin/kit.manifest.json, names every global token, component token, component and class the kit offers. A name leaving the manifest is a breaking change: an app's override of it stops applying, with no error.

Motion

Every motion the kit makes reads a duration token, --kit-d-1 (a hover), --kit-d-2 (an opening) or --kit-d-3 (a larger move), or --kit-d-theme, the fade of a theme change, whose class --kit-d-theme-hold keeps on the page a little longer (see Light and dark), or --kit-d-enter, a page change coming in, or --kit-d-glide, the rail's marker gliding to the current item (both in The admin shell), or a busy button's --kit-d-dots, one pulse of a working dot, and --kit-d-dots-step, the step by which each dot follows the one before (see Buttons), or a button's answer, --kit-d-flash, its landed ring, and --kit-d-nudge, its failed nudge (also in Buttons), or a notice's --kit-d-notice, its rise, and --kit-d-notice-leave, its leave (see Notices). Every kit motion that takes time names its curve, a curve token, --kit-ease, --kit-ease-leave and --kit-ease-theme (something arriving or moving, something leaving, a theme's colours changing), or linear, a steady turn such as the busy ring's. Under prefers-reduced-motion: reduce every --kit-d-* token is 0ms and scroll-behavior is auto, so a viewer who asks for less motion sees none. A dwell token, named --kit-<component>-dwell or --kit-<component>-<name>-dwell, is a wait, not a motion: it keeps its time, so a notice still leaves after --kit-notice-dwell, and a busy button still frees its form after --kit-btn-busy-dwell.

A motion an app adds in @layer app reads a --kit-d-* token, so reduced motion stops it too; a component duration token of its own falls back to one (var(--app-panel-d, var(--kit-d-2))). An app that sets a duration token of its own repeats it as 0ms under prefers-reduced-motion too, since its value wins over the fallback. An app that overrides a --kit-d-* token repeats it as 0ms under prefers-reduced-motion, as a colour override gives its own dark value: the app's layer wins over the kit's reduced-motion block. An app that overrides --kit-d-theme keeps --kit-d-theme-hold at least as long, so the fade's class stays until its colours have landed, and repeats both as 0ms under prefers-reduced-motion. Each theme token is a time such as 320ms or 0.32s, or a var() to one: the script reads it as the browser hands it over, so a calc() is not read and the theme swaps at once.

@layer app {
    :root { --kit-d-2: 160ms; }

    @media (prefers-reduced-motion: reduce) {
        :root { --kit-d-2: 0ms; }
    }
}

Buttons

KitButton renders a <button>, type="button" unless Type says otherwise, so a button inside a form submits it only when asked to. Variant is Default, Primary (the screen's one solid black element), Danger (the danger fill, for an action that cannot be undone) or Ghost (no fill or edge until hovered, for a toolbar or a row).

<KitButton Variant="KitButtonVariant.Primary" Type="submit">Save</KitButton>
<KitButton Href="~/users" class="app-wide">Users</KitButton>
<KitButton Href="~/users" Disabled>Users</KitButton>

With Href, it is a link, <a class="kit-btn">, to the address KitHref.LocalOrHttps makes of it (see Links). A refused Href, or Disabled on a link, renders <span aria-disabled="true">, which goes nowhere. Every other attribute passes through, and a class joins the kit's; a url attribute (formaction, ping, src and the like) is refused with an exception, since it would reach the page past KitHref.

Every variant is one control height tall: --kit-btn-height, falling back to --kit-control-h.

kit.forms.js marks the kit button that submits a form aria-busy="true" until the answer is on the page: Blazor's enhancedload for an enhanced form, pageshow for a full load. A busy button keeps its width: its label turns transparent in place and a ring turns at its centre. A submit some script cancels marks nothing, unless the form is enhanced (data-enhance): Blazor cancels that submit to post the form itself. A dialog form, or one aimed at another window, marks nothing either.

A submit button given BusyText, the word it reads while its post is out, shows that word and three working dots in place of its label while it is busy, in its own text colour; the dots pulse in turn, and stand still under prefers-reduced-motion. The word is the app's to write, since a doing word cannot be made from every label in every language. The button lays its label over the word and the dots, which are hidden until it is busy, so the wider of the two sets its width at rest and busy alike, and nothing beside it moves when it is marked. The label turns transparent in place, so a screen reader still names the button by it; the word and the dots are hidden from a screen reader. kit.forms.js also sets --kit-btn-busy-width on the button as it marks it, the width it had, which the busy button holds; a property set in script, so no style attribute reaches the markup. A link takes no word.

<KitButton Variant="KitButtonVariant.Primary" Type="submit" BusyText="Saving">Save</KitButton>

While a form's button is busy, a second submit of that form is not sent: kit.forms.js cancels it in the capture phase, before Blazor's own submit listener, which sends nothing for a cancelled submit. Another form submits as usual, and so does a dialog's close or cancel (formmethod="dialog"), which opens no page. Each of the form's submit buttons, one outside it that names it with form among them, is marked data-kit-held while the form is held, and shows the progress cursor and neither lights nor moves; a dialog's or a disabled one keeps its own look. A script that cancels an enhanced kit form's submit and sends it again with requestSubmit is cancelled too, until the mark clears; form.submit(), which fires no submit event, or a form that is not enhanced, is its way out. This spares a second click and nothing more: a second tab, or a replay of the same post, still reaches the server, so the server's own answers stay the bar against a post sent twice.

The mark, its width, the guard and data-kit-held clear together: on enhancedload, on pageshow, and after --kit-btn-busy-dwell (20s) when neither came. A post whose fetch failed, or one answered by a file or by no page, brings neither event, so only the dwell frees its form; the label then returns and the user can send it again. The 20s is a wait the kit chose, longer than a form post should take and short enough that a failed one is soon free again; no host time limit sets it. A post slower than the dwell can be sent again by a second click after it, which the server's answers still judge. An app whose posts take longer sets a longer --kit-btn-busy-dwell on :root.

Answer (KitButtonAnswer) draws a post's answer on the button, on the render that answers it. Landed adds kit-btn-landed: a box-shadow ring in --kit-state-success spreads from the button's edge to --kit-flash-spread (10px) and fades over --kit-d-flash (700ms) on --kit-ease. Failed adds kit-btn-nudged: the button moves sideways (translateX) through --kit-nudge-1, --kit-nudge-2 and --kit-nudge-3 (-5px, 4px, -2px) and back to 0 over --kit-d-nudge (300ms) on --kit-ease. None, the default, draws nothing. Each plays once and leaves nothing behind, and neither changes the button's colour, text or size, so the answer is said in words, in an alert or a notice, and never by the ring or the nudge alone. Under prefers-reduced-motion neither moves. Any KitButton takes Answer, so a post made from a KitConfirm answers on a KitButton that opened it; a row menu's item takes no answer. The two ring shadows, --kit-flash-ring and --kit-flash-ring-end, read --kit-flash-spread on :root, so an app that changes the spread sets it there.

<form method="post" @formname="save-row" @onsubmit="SaveAsync">
    <AntiforgeryToken />
    @if (answer == KitButtonAnswer.Landed)
    {
        <KitAlert Tone="KitTone.Success"><p>The row is saved.</p></KitAlert>
    }
    else if (answer == KitButtonAnswer.Failed)
    {
        <KitAlert Tone="KitTone.Danger" Title="Not saved"><p>The row changed since you opened it. Reload it and save again.</p></KitAlert>
    }

    <KitButton Variant="KitButtonVariant.Primary" Type="submit" BusyText="Saving" Answer="@answer">Save</KitButton>
</form>

@code {
    private KitButtonAnswer answer;

    private async Task SaveAsync()
    {
        var saved = await SaveTheRowAsync();
        answer = saved ? KitButtonAnswer.Landed : KitButtonAnswer.Failed;
    }
}

Where a page draws KitNotice for a landed post, the button takes no Landed, so one answer is one motion: the ring is for a form that draws no KitNotice; the page still says the answer in a KitAlert or the shell's Messages. A static page sets Answer on the render that answers the post alone, as the field above does, None on every other request. A page that sets it on every render, from a stored outcome or a query value, rings or nudges the button on a plain reload too, and on any later visit to the page.

A post answered on the same path keeps the button element, so a class it still had would not play again: kit.forms.js, as it marks a post's submitter busy, takes kit-btn-landed and kit-btn-nudged off every element on the page, the submitter and a confirm's opener among them, and the next answer's class plays. As with a notice, an answer replays only after a post a kit button or a KitSettingField sends.

Status pills and alerts

KitStatusPill says a status in a word: Tone (Neutral, Success, Warn, Danger or Info) sets its colour, and Text, which it requires, says it, since a status is never colour alone.

KitAlert is a message about the page in the same tones, with an optional Title and its body as child content, its lines no wider than --kit-measure. A Neutral, Success or Info alert has role="status", which a screen reader reads when it is next idle; a Warn or Danger alert has role="alert", which it reads at once.

An attribute the caller adds, such as an id or a data- attribute, lands on the alert, and a class joins the kit's. The kit's class, role, tabindex and autofocus win over the caller's, and a url attribute throws. TakesFocus="true" makes the alert tabindex="-1" and autofocus, so the browser focuses it as the page loads with no script. Give it to one alert on a page at most, such as a form's refusal.

<KitStatusPill Tone="KitTone.Success" Text="Active" />
<KitAlert Tone="KitTone.Danger" Title="Not saved"><p>The email is taken.</p></KitAlert>

Codes to scan

KitQrCode draws Value as a QR code, such as the otpauth:// URI an authenticator app scans to add an account. It renders an inline <svg> of plain elements, one <rect> a dark module, with role="img" and Label as its aria-label, so a reader who cannot see the code hears what it is for. Both parameters are required, and an empty Value or Label throws.

The modules are the encoder's at error correction level M, which restores 15% of a damaged code: a code on a screen is whole, so a higher level only shrinks the modules of a long value. The encoder's matrix holds the quiet zone, four light modules on every side, and the component adds no margin of its own.

The code reads three tokens and nothing else. --kit-qr-ink (#000000) and --kit-qr-paper (#ffffff) hold the same values in both themes, since a scanner needs dark modules on a light ground whatever the page's scheme; no dark block sets them. --kit-qr-size (12rem) is the code's side. Under forced colours the code keeps its two colours.

A value too long for a code at level M draws no code: Label shows alone, as text, so write a label that also says what to do then, such as entering the key by hand. The component then writes one Warning, KitQrCodeTooLong, on the Solhigson.Admin.Components.KitQrCode category, which names the value's length and never the value, since in its real use the value carries an authenticator's secret. No other line names the value either.

The svg holds Value in the page source, and anyone who sees the code or the source can decode it. A page that draws a secret's code sends Cache-Control: no-cache, no-store and Pragma: no-cache, as the kit's account pages write in OnInitialized, before their first await, and refuses framing with X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none', which the app sends. The component sets no header.

The encoder is QRCoder (MIT), the package's one dependency beside Core (THIRD-PARTY.md). The package references QRCoder 1.6.0 or later: an app resolves 1.6.0 unless it, or another package it uses, asks for a later one. At 1.6.0 the package's own net10.0 closure holds no drawing or imaging library, which a test holds; 1.7.0 and later depend on System.Drawing.Common for net6.0, so raising the reference must first clear that test. An app that resolves QRCoder 1.7.0 or later, or targets a -windows framework (1.6.0's net6.0-windows7.0 build depends on System.Drawing.Common 6.0.0), takes System.Drawing.Common through QRCoder, which KitQrCode never calls.

<KitQrCode Value="@authenticatorUri" Label="Scan this code with your authenticator app, or enter the key by hand." />

Notices

KitNotice says a post's answer in one message at the foot of the screen, which rises in, stays long enough to read and leaves on its own. Its Message is a KitNoticeMessage: KitNoticeMessage.Landed(text) for a post that landed, or KitNoticeMessage.NotLanded(text, step) for one that did not, where step is one sentence saying what to do next, so a failure never says only that it failed. An empty or blank text or step throws ArgumentException. With no Message the notice renders nothing. The shell's Messages stay for what lasts on the page; a notice is the moment the answer arrives.

<KitNotice Message="@notice" />

@code {
    private KitNoticeMessage? notice = KitNoticeMessage.NotLanded("The invitation was not sent.", "Check the email address and send it again.");
}

A notice is the raised surface, --kit-surface-raised, in --kit-fg text, edged by --kit-line under --kit-shadow-menu. Its mark is a field error's in shape, a glyph in a filled disc: a landed notice shows a check on --kit-state-success in --kit-on-state-success; one that did not land shows a ! on --kit-state-danger in --kit-on-state-danger, and its step as a second, smaller line. Each mark has a text alternative, LandedText (Done:) and NotLandedText (Not done:). It is fixed above the viewport's foot, centred inside the page gutter, at most --kit-measure wide, at the floating layer --kit-z-float, above the skip link's --kit-z-skip. A word too long for its line, an address or a name, breaks anywhere, so a notice never passes a phone's screen.

It moves by CSS alone. It rises from --kit-notice-rise (12px) below over --kit-d-notice (280ms) on --kit-ease, stays --kit-notice-dwell (2800ms), or --kit-notice-long-dwell (4200ms) when the post did not land, then leaves over --kit-d-notice-leave (220ms) on --kit-ease-leave, ending hidden (visibility: hidden) with no pointer events. A pointer over it pauses its stay and its leave until the pointer goes; its rise plays on, so a pointer resting where the notice appears does not hold it half risen. Under prefers-reduced-motion both durations are 0ms and the dwells keep their time, so the notice shows at once, stays, and goes at once.

A post answered on the same path keeps every element whose tag matches, so a notice left in place would not play again: kit.forms.js removes every .kit-notice element as it marks a post's submitter busy (see Buttons), and the answer's notice, a new element, plays, even when it says the same words. A notice replays only after a post a kit button or a KitSettingField sends, since kit.forms.js marks no other submitter busy: the answer to a post any other control sends on the same path keeps the notice element in place, so it does not play again.

The notice itself is hidden from assistive technology (aria-hidden="true"). KitShell renders after its <main> two live regions, role="status" and role="alert", empty and present on every page, since a region inserted already holding its text is announced unreliably. kit.notice.js, at start and on each enhancedload, writes the page's first notice outside an inert element, its mark's alternative, its text and its step, by textContent into the status region for a landed notice or the alert region for one that did not land, and empties the other; a page with no notice empties both. A notice already told with the same words is not told again. A KitNotice outside KitShell renders nothing, since no region there can tell it: the shell gives its page the cascading value a notice renders under. Without script a notice is drawn and not announced.

A position: fixed element is placed against an ancestor that has a transform, not the viewport. The shell's main region has one only while a page change plays (see The admin shell): a post answered by a page on another path plays the page change, and unless the change is the fade alone, for --kit-d-enter (240ms) the notice is placed against <main>, off the screen on a page longer than the window, and then lands at the viewport's foot, most of its rise played. A notice inside an element an app's own rule transforms moves with that element.

Form fields

KitField renders one labelled control with its hint and its error. Kind is Text, Email, Password, Number, Date, Search, Textarea, Select, Checkbox or Toggle; Name and Label are required.

<KitField Name="Email" Label="Email" Kind="KitFieldKind.Email" Value="@model.Email" Required
          Hint="We send the sign-in link here." Error="@errors.GetValueOrDefault("Email")" />
<KitField Name="Role" Label="Role" Kind="KitFieldKind.Select" Value="@model.Role" Placeholder="Choose a role"
          Options="@([("operator", "Operator"), ("approver", "Approver")])" />
<KitField Name="Notify" Label="Email me on changes" Kind="KitFieldKind.Toggle" Value="@model.Notify.ToString()" />
  • The <label> names the control by for and id; the hint and the error describe it by aria-describedby.
  • An Error marks the control aria-invalid="true" and shows its text after a glyph whose text alternative is the word "Error", so it is not colour alone. Static rendering posts a plain form, so the error text comes from the server; the field shows what it is given.
  • Required puts required on the control and a visible mark in the label, read as "(required)".
  • The id is kit-field- and the Name, every character that is not an ASCII letter or digit written as _ and its four hex digits (Items[0].Name is kit-field-Items_005B0_005D_002EName). It is the same on every render and different for every other name. Two fields of one Name on one page, in two forms, each need their own Id.
  • A Password never writes Value into the page, so a stored secret shows only as set or not set; it carries autocomplete="new-password" unless AutoComplete says otherwise, since browsers ignore off on a password and would fill the administrator's own saved password.
  • A Select takes its Options as value and text pairs, in order; the option whose value equals Value, compared ordinally, is selected. Placeholder adds a first, empty option, chosen when Value is empty.
  • Min, Max and Step are a Number's or a Date's; ReadOnly is an input's or a textarea's, since a browser lets a select, a checkbox and a toggle change though they are read-only (use Disabled). A parameter the kind cannot honour is refused with an exception, as are Options on any kind but a Select.
  • InputMode is the keyboard a touch screen shows (inputmode): none, text, decimal, numeric, tel, search, email or url, on a Text, Email, Password, Number or Search input or a Textarea. MaxLength is the most characters the control takes (maxlength), at least 1, on a Text, Email, Password or Search input or a Textarea. Any other value or kind is refused with an exception. With neither set, nothing is written. A browser limits what is typed, not what is posted, so the server still checks the length. An inputmode or a maxlength written as an attribute, in a splat or in any case, is the parameter: a string maxlength such as "80" is read as its number, and one that is no whole number is refused. One held in an Attributes dictionary passed whole is refused, since the field would drop it without a word. Given through @attributes beside its parameter, as MaxLength="12" with a splat holding maxlength="80", the renderer keeps the last value and drops the other before the field sees its parameters, so the field cannot refuse it. Code that builds the render tree and writes both is refused.
  • Every other attribute lands on the control. The field owns id, name, required, disabled and aria-invalid on every control; type, value, placeholder, min, max, step, readonly, autocomplete, inputmode and maxlength on an input; placeholder, readonly, autocomplete, inputmode and maxlength on a textarea; autocomplete on a select; type, value and checked on a box or a toggle; and role on a toggle. It writes them after the caller's, so a passed one is replaced; set them through the parameters. A passed inputmode or maxlength is the parameter itself, since a parameter's name is matched in any case. A passed class and a passed aria-describedby join the field's own. A url attribute is refused, as KitButton refuses it.
  • An input and a select are one field height tall: --kit-field-height, falling back to --kit-control-h.

Changes for an existing app: before InputMode and MaxLength, an inputmode or a maxlength the caller wrote landed on the control as written, on any kind. Each is now the parameter, so each of these throws where it rendered before:

  • an inputmode on a Date, a Select, a Checkbox or a Toggle, or one the HTML standard does not list;
  • a maxlength on a Number, a Date, a Select, a Checkbox or a Toggle, one under 1, or one that is no whole number;
  • either held in an Attributes dictionary passed whole, or written beside its parameter by code that builds the render tree.

A Checkbox or a Toggle posts value="true" when ticked and nothing at all when not: there is no hidden field. It is ticked when Value is true in any case, so Value="@model.Notify.ToString()" works. A handler reads an absent box as false by binding it to a bool, which the absent field leaves false: [SupplyParameterFromForm] public bool Notify { get; set; } in a component, or a bool property of an MVC model. A Toggle is the same checkbox with role="switch", drawn as a track and a thumb, so it never looks like a box to tick.

A disabled field, like an unticked box, posts nothing, and a viewer can post any field the page never showed them. So a handler writes only the fields the signed-in viewer may change, decided by their permission on the server, never by which fields arrived or which the page disabled, and leaves every other value as stored.

Setting fields

KitSettingField shows one declared setting as a row of a settings list: its label and purpose, one control of its kind (KitSetting.From makes its Setting from the framework's DeclaredSettingLine), the hint with its bounds and default, where its value comes from, and a pill and a sentence for each flag. A Secret, a row stored sensitive and a value shown as the mask are a password field that starts empty; nothing of the value is written into the page. With ReadOnly, or on a line that cannot be edited, the row shows its value as text, "Hidden" for one that may not be shown.

KitSettingField renders no form of its own: the screen places each setting in a form of its own, with its Save button. Its controls post the bare names Value, Amount and Unit (a duration as an amount posts Amount and Unit; every other kind posts Value), so the screen binds them with [SupplyParameterFromForm(Name = "")] and turns them into the setting's text with KitSettingValue.Compose:

<form method="post" @formname="setting" @onsubmit="Save">
    <AntiforgeryToken />
    <KitSettingField Setting="@setting" Fields="@Posted" Error="@error" />
</form>

@code {
    [SupplyParameterFromForm(FormName = "setting", Name = "")]
    private KitSettingFields? Posted { get; set; }

    private void Save() => composed = KitSettingValue.Compose(setting, Posted);
}

An unticked toggle posts nothing, so Value binds null, which KitSettingValue.Compose reads as false; when the toggle is the form's only field the whole KitSettingFields binds null, which Compose reads the same way. A line shown as the mask is the exception: controls left empty compose to the mask, which the framework's save reads as no change.

ChildContent, when given, is placed last in the row, in the control's column under the hint, the error and the lines, in a box of its own (kit-setting-actions) that stacks what it holds a section step apart. The settings screen puts its buttons and what a post came to there, so they sit inside the row they act on; with none given, no box is drawn.

<KitSettingField Setting="@setting" Fields="@Posted" Error="@error">
    <div class="kit-settings-actions">
        <KitButton Type="submit" name="op" value="save">Save</KitButton>
    </div>
</KitSettingField>

Dialogs and confirms

KitDialog renders the browser's own <dialog>, which gives the backdrop, the focus trap and Escape. Variant is Modal, a box in the middle that rises as it opens, or Drawer, a panel the screen's full height at its inline-end edge that slides in; both are still under reduced motion. It is labelled by its Title, and its close button closes it and posts nothing (formmethod="dialog" and formnovalidate).

Any element with data-kit-open="<id>" opens the dialog of that id, which kit.dialog.js looks up at the click, so a dialog an enhanced navigation removed is simply not opened. A click outside the dialog's box, on the backdrop, closes it. An opener inside a popover hides the popover first, and the popover's trigger takes the focus back when the dialog closes.

<KitButton data-kit-open="remove" data-kit-fill-user-id="@user.Id" data-kit-fill-name="@user.Name">Remove</KitButton>

<KitConfirm Id="remove" Title="Remove this user?" FormAction="~/users/remove" FormName="remove-user"
            Fields="@(["user-id"])" ConfirmText="Remove">
    <p><span data-kit-slot="name"></span> is signed out and cannot sign in again.</p>
</KitConfirm>

Before it opens, the script clears every marked target it can fill, then copies each data-kit-fill-<name> of the opener, as text, into the target of that name, matched ignoring case. A target is an element with data-kit-slot="<name>", or a control marked data-kit-fillable that is a textarea or an input of one of six types: hidden, text, search, email, tel or url. A marked control of any other type (a checkbox, a radio, a file input, a number) or a select is never cleared or filled. Only marked fields are filled, so a form the server filled in a dialog keeps its values; KitConfirm marks its hidden fields. One dialog can serve a whole list this way, and it never shows or posts the last row's values. A name is lower-case letters and digits joined by hyphens. A name starting _ is never filled, so a row cannot overwrite the form's _handler or its antiforgery token. An opener marked aria-disabled="true" opens nothing.

With FormAction and FormName, a dialog's title, body and footer sit in one <form method="post"> with @formname and the antiforgery token, Blazor writing the form's _handler field itself; a footer button with Type="submit" posts the body's fields to the action, and a handler with that FormName receives it. The action goes through KitHref.Local: a path on this site or a ~/ path, joined to the request's path base. A refused action renders no posted form; the dialog then only closes. KitConfirm is such a dialog with a hidden field for each of its Fields, a cancel button that sends nothing, and a confirm button, Danger unless ConfirmVariant says otherwise; a confirm whose action KitHref.Local refuses throws, since a confirm must post.

A confirm posts to the page that renders it, to an endpoint that is not a Blazor page (a minimal API or an MVC action, which reads the token itself), or to a Blazor page that renders a form of the same name. A Blazor page that only binds the name, with [SupplyParameterFromForm(FormName = …)] and no such form, answers the post with 400.

A component that handles its own confirm passes OnConfirm. The confirm's form is then a named form with that handler on it (KitDialog's OnSubmit), so the post runs the handler in the request that renders the page again, after the component has bound the fields with [SupplyParameterFromForm(FormName = …)]. The confirm must be rendered in that request too, or Blazor answers the post with 400. Without OnConfirm the form carries no handler, as before.

Row menus

KitMenu renders a row menu on the browser's own popover: a trigger, a ghost KitButton with popovertarget and aria-haspopup="menu", showing three dots with its Label as aria-label (or its label as text with ShowLabel), and a popover panel with role="menu". The browser opens the panel and closes it on a click outside it or on Escape; kit.menu.js places it under its trigger and inside the viewport, focuses its first item, and moves among the items with the arrow keys, Home and End. Each row's menu needs its own Id, unique on the page.

@foreach (var user in users)
{
    <KitMenu Id="@($"user-{user.Id}-menu")" Label="@($"Actions for {user.Name}")">
        <KitMenuItem Href="@($"~/users/{user.Id}")">Open</KitMenuItem>
        <KitMenuItem OpenDialog="remove" data-kit-fill-user-id="@user.Id" data-kit-fill-name="@user.Name" Danger>Remove</KitMenuItem>
        <KitMenuItem Action="~/users" FormName="disable-user" name="user-id" value="@user.Id">Disable</KitMenuItem>
    </KitMenu>
}

<KitMenuForm FormName="disable-user" Action="~/users" OnSubmit="Disable" />

Each KitMenuItem, role="menuitem", is one of four kinds:

  • a link, Href through KitHref.LocalOrHttps;
  • a dialog opener, OpenDialog naming a KitDialog or KitConfirm, with its data-kit-fill-<name> values written on the item as on any opener; the dialog script hides the menu first and gives its trigger the focus back on close;
  • a post button, which submits the KitMenuForm of its FormName (form=) to its own Action (formaction=, through KitHref.Local), with the name and value written on the item: the pressed row's value alone is posted;
  • a theme choice, ThemeChoice light, dark or system, a role="menuitemradio" that kit.theme.js switches as it switches a KitThemeSwitch choice, aria-checked on the theme the server read.

The page places one KitMenuForm for each FormName, outside any form, since a form inside a form is dropped and Blazor refuses a post to a page holding two forms of one name. It is hidden, and carries the action, the @formname and the antiforgery token, Blazor writing the _handler field itself; its OnSubmit runs when the form is posted to the page and may redirect. A post item whose FormName has no KitMenuForm on the page would submit nothing, so kit.menu.js shows it disabled, at start and after every enhanced navigation, and warns in the console which form id is missing. The KitMenuForm must sit outside any form: inside one it is dropped, its fields join the enclosing form, and a GET form would put the antiforgery token in the url. A post item may post to the page that renders its KitMenuForm, to an endpoint that is not a Blazor page (a minimal API or an MVC action, which reads the token itself), or to a Blazor page that renders a KitMenuForm of that name; a Blazor page that only binds the name, with [SupplyParameterFromForm(FormName = …)] and no such form, answers the post with 400. A KitMenuForm with PostsElsewhere registers no name on its own page: it writes the _handler field of its FormName itself and posts it to its Action, a page that registers that name and runs its handler; it takes no OnSubmit, and posted to a page registering no such name it answers 400. The shell's sign-out form is one.

A target KitHref refuses renders the item as disabled text (aria-disabled="true"), which takes no focus. Danger marks a destructive item. Every other attribute lands on the item's element; a url attribute and a name starting _ are refused.

The admin shell

KitShell is the layout an app's layout wraps its pages in. It renders, in order, a skip link to the main region, a side rail (<nav aria-label="Main">) with the Brand and the Menu, a top bar holding the user's menu, and <main id="kit-main"> holding the page, with any Messages above it as KitAlerts, and after it two empty live regions a notice is announced in (see Notices). It adds no script.

@inherits LayoutComponentBase

<KitShell Brand="Elfrique Admin" Menu="@menu" UserName="@user.Name" Messages="@messages"
          SignOutAction="~/account/sign-out" SignOutFormName="@KitSignOut.FormName">
    @Body
</KitShell>

@code {
    private IReadOnlyList<KitNavItem> menu =
    [
        new("dashboard", "Dashboard", "~/", Current: true),
        new("people", "People", Children: [new("users", "Users", "~/users"), new("roles", "Roles", "~/roles")]),
    ];
}

A KitNavItem has a Key, its text, an href, children and Current. An item with children is a group, a native <details> with a chevron, open when it holds the current item; a group with an href too is refused, naming its Key. The current item carries aria-current="page" and shows it by weight and the surface's soft fill, never an ink fill, or where the rail's line is drawn (below) by weight and the line. An href goes through KitHref.Local, since a menu is often stored rows an administrator can edit: an item with no href (one an on-click function drove, say) is text and logs nothing, and one whose href KitHref.Local refuses is text and writes one Warning naming the item's Key, never its href, under the Solhigson.Admin.Components.KitShell category on every render. Every Key must be an id token: set, with no white space, control or format character, so a Key can forge no log line.

The user's menu, a KitMenu labelled with UserName, holds the three theme choices and sign-out. Sign-out is a post, never a link: a post item submitting the form the shell places after itself, outside any form, built from SignOutAction (through KitHref.Local, which must accept it) and SignOutFormName. An app signs out through the sign-out page (see The sign-out page): SignOutAction is that page's path and SignOutFormName is KitSignOut.FormName, as above. The app's layout leaves OnSignOut unset, and the shell's form is then a KitMenuForm with PostsElsewhere, its antiforgery token and a hidden _handler field written out, with no data-enhance and no script, posting to the page's handler. The shell registers no form name on the page it wraps, so a sign-out page inside the shell renders the name once, in its own form. OnSignOut is for an app with no sign-out page, whose shell handles the post itself: with it set, the shell's form registers the name, and posted to a page rendering the shell, Blazor checks the token and OnSignOut runs and may redirect. That registers the name on every page the shell wraps, so a page holding KitSignOut must not render a shell that sets OnSignOut. The action may also be an endpoint that is not a Blazor page (an MVC action or a minimal API), which checks the antiforgery token and signs out itself. The theme choices are menuitemradio items; the checked one shows a tick.

The rail is soft grey (--kit-ink-soft). At 720px and under it is one row above the page that scrolls inside itself, so the page never scrolls sideways. An item under the pointer takes the text colour; the current one also takes the surface's fill and is heavier. The skip link is hidden as .kit-sr text is until a keyboard focuses it. Its href is the page's own url and #kit-main, so it stays on the page under a <base href>, where a bare #kit-main would resolve against the base. The url is the one the browser asked for, the original one on a re-executed status code page, through KitHref.Local, and a url it refuses leaves the bare #kit-main; it carries data-enhance-nav="false", so Blazor does not fetch the page again for it.

In a browser that can anchor one element to another and scope the anchor's name (CSS anchor positioning with anchor-scope), the rail draws a line in the ink, --kit-rail-marker-line (3px), at the current item's start edge, and the current item keeps its weight and drops its soft fill, so the line and the weight mark it. After an enhanced navigation, which keeps the rail and moves aria-current, the line glides to the item picked over --kit-d-glide (340ms) on --kit-ease; a full load draws it in place. The line follows its item on any other move too: a group opened or closed above it, or the window resized across 720px, glides it. At 720px and under, where the rail is a row, the line lies under the item. While a group holding the current item is closed, the line sits at its summary. Each rail scopes its anchor (anchor-scope), so a second shell on the page anchors its own line. The line is the rail's last element, an empty span.kit-rail-marker hidden from assistive technology, so aria-current alone tells a reader the current item. A page with no current item draws no line. A browser without anchor positioning or anchor-scope lays out no line, since the stylesheet makes the span no box there, and the current item keeps its fill. The span carries no hidden attribute, so an app's reset such as [hidden] { display: none !important; } cannot hide the line. In forced colours, where fills are not drawn, the line is the system's text colour (CanvasText). Under prefers-reduced-motion --kit-d-glide is 0ms, so the line jumps.

A page change moves with its direction. After an enhanced navigation to another path, kit.nav.js fades the main region in over --kit-d-enter (240ms) on --kit-ease as it moves in from the side the page came from. A deeper page, one with more path segments past the path of document.baseURI (an app's path base), is pushed in from the right by --kit-enter-push (48px), and a shallower one from the left; where the main region's direction is rtl the two swap. A page at the same depth drifts in by --kit-enter-drift (22px) toward the rail item picked, along the rail: the shell renders data-kit-main on its <main> and data-kit-nav-index, its place in Menu, on each top-level rail item. Beside the rail's column, a current item further down the menu than the last page's brings the page up from below, one further up brings it down from above; at 720px wide and under, where the rail is a row, the page comes from the inline end or the start, mirrored under rtl. Where either page has no current item, the page fades in alone. The page left is not drawn leaving, since enhanced navigation has already replaced it.

A post answered on the same path, a change of the query alone (a filter, a pager's cursor), the first page and a full load move nothing, and so does a change to or from a page with no shell (an app's own sign-in page outside KitShell). A streamed update or a post answered in place while a move still plays leaves the move playing from where it was, even when an app's own enhancedload listener reads the layout first. A streaming layout whose first chunk renders no shell <main> gets no move on that navigation, since the move is chosen when that chunk is on the page. With the gate on, a streaming layout around the shell is refused for a viewer the gate holds (see The shell's gate). A signed-in viewer it lets through gets no shell in the first chunk, so the rail and bar arrive with the page and no page change moves. Drop [StreamRendering] from the layout, or turn the gate off. Under prefers-reduced-motion --kit-d-enter is 0ms, so nothing moves. Where an app's own rule sets the main region's animation, the move's classes come straight off and nothing moves.

While the page slides sideways or up the shell's body clips what passes its edge, so no scrollbar comes and goes; a page wider than the shell's body, a wide table the page scrolls sideways, loses its sideways scrollbar and is cut at the body's edge for the move's 240ms. The main region keeps no transform once it has come in, so a position: fixed element an app puts inside it is placed against the viewport again after the move.

The shell's gate

The shell holds a signed-in user to a required step before the page it wraps. Before it renders anything, it reads the viewer (IKitAccount.CurrentAsync). A viewer whose password must change is sent to ChangePasswordPath, and else one who must enrol to TwoFactorPath, each carrying the page's path as the return address. The query is left out, since a query can hold a secret, such as a reset link's token. The redirect is kept out of every cache.

A post to a page inside the shell is sent on the same way, before the page's handler runs. The shell renders nothing, neither the page nor its form, until the gate has answered, and Blazor calls a form's handler only once the page has rendered, so a post the gate sends on changes nothing. In the page's place the shell renders one form under the posted form's name, whose handler makes the redirect, so the post answers the redirect, not the framework's 400 for a form it cannot find. This holds too on a host that turned off the exception NavigateTo throws (BlazorDisableThrowNavigationException).

The gate sends no one away from three pages: the change-password page, the two-factor page, and the sign-out page that SignOutAction names. Each is compared under the path base, its query, a last / and case aside. Both paths are compared escaped as a url writes them, so a path written with a character outside ASCII, escaped or not, is the page its escaped form asks for. With OnSignOut set, SignOutAction is a page the shell wraps, any page of the app, so it is held as every other page is. A held user's post of the shell's own sign-out form still runs OnSignOut: the shell renders that form alone, and no page. Then, unless OnSignOut redirected, the post is redirected to the page's own path, its query left out. A GET there, and a post of any other form, is sent on.

The gate covers the pages inside the shell alone. An app's pages outside it, and an endpoint that is not a Blazor page, need the app's own guard. It is on by default, and KitAccountOptions.Gate = false turns it off. It holds no one:

  • with no request, as under an interactive render mode;
  • where no IKitAccount is registered (AddSolhigsonAdmin registers one);
  • for a visitor not signed in;
  • on a request a status code page or the exception handler re-executes. The request it re-executes was the one to hold, and the error page keeps its status. The gate trusts the path re-executed to be an error page: an app that re-executes to a working page holds no one there;
  • for a step whose path is null. The next step is still asked for, and the first time in the process a step is passed over, one Warning says so.

A read that throws lets the page render and writes one Error, so a broken read locks no administrator out of every page. A read cancelled while the request is live, as by a timeout of the app's seam, is such a fault. A read the request's own cancellation ends is none: the shell renders nothing and writes no line. The package's seam throws no fault and no cancellation while the request is live; it throws only the request's own. A fault in its read of the viewer answers no viewer, with its KitAccountFailed Error, and the page opens. A fault in its read of the enrolment answers that the viewer must enrol, so the gate sends them to the two-factor page: that fails closed, as the framework's rule does. So KitShellGateFailed is an app's own seam that threw.

On a response that has started, as under a layout with [StreamRendering], the gate can write no header and make no redirect. For a viewer it holds, the shell throws: "KitShell takes no stream rendering: its response started at its first await, so it can set no cookie and redirect nowhere." A visitor, and a viewer with no step to take, are served the page. The gate reads the viewer on every page inside the shell, and an account page inside it reads the viewer again.

Line Level Text What to do
KitShellGateFailed Error KitShell's gate could not read the viewer: {ExceptionType}; the page renders with no step asked for. The app's own IKitAccount threw, or could not be resolved. Fix it: until then no user is held to a step inside the shell. The line is under Solhigson.Admin.Components.KitShell and names the exception's type alone.
KitAccountPathNotSet Warning KitAccountOptions.{Option} is not set, so no page sends a signed-in user who must {Step} there, and the step is never asked for. Logged once per process. Set the path to the app's page, or leave it null where the app has no such page and wants the step off. The line is under Solhigson.Admin.Account.KitAccountOptions, and the sign-in pages write it too.

The menu from permissions

IKitMenuSource builds the shell's menu from the permissions the signed-in user's roles hold, read through the framework's PermissionManager (its cached menu read, and its cached read of every permission a role holds). Register it beside the identity manager, with the same type arguments:

builder.Services.AddSolhigsonIdentityManager<AppUser, AppDbContext>();
builder.Services.AddSolhigsonAdmin<AppUser, AppDbContext>();

AddSolhigsonAdmin<TUser, TKey, TContext>() is the overload for a key type other than string. Either registers, all scoped, the menu source, the users seam (see Users), the roles seam (see Roles), the audit seam (see Recording changes) and the audit reader seam (see Reading the audit trail). It also registers IHttpContextAccessor, which the audit seam reads the signed-in user through, and TimeProvider.System when the app registers no TimeProvider, and nothing else. The layout passes the menu to KitShell, and says so on the page when it could not be read, since an empty rail would otherwise read as a revoked grant:

@inherits LayoutComponentBase
@inject IKitMenuSource MenuSource

<KitShell Brand="Elfrique Admin" Menu="@_menu.Items" Messages="@_messages" UserName="@HttpContext!.User.Identity?.Name"
          SignOutAction="~/account/sign-out" SignOutFormName="@KitSignOut.FormName">
    @Body
</KitShell>

@code {
    private KitMenuResult _menu = new([], false);
    private IReadOnlyList<KitMessage>? _messages;

    [CascadingParameter]
    private HttpContext? HttpContext { get; set; }

    protected override async Task OnInitializedAsync()
    {
        _menu = await MenuSource.ForAsync(HttpContext!.User, HttpContext.Request.Path, HttpContext.RequestAborted);
        _messages = _menu.Failed ? [new(KitTone.Danger, "The menu could not be loaded. Reload the page to try again.")] : null;
    }
}

The menu shows; it does not enforce: each page's [Permission] is the gate. The roles are the principal's role claims, as [Permission] reads them, so the menu and the gate agree for the life of a cookie; a user who is not signed in, or who holds no role, is shown nothing. A permission the roles hold is an item, keyed by its name, its text the description or else the name, its href the stored url. A parent they do not hold is shown only as the label of a held child, and only when it is enabled; a disabled parent takes its children with it. A held parent with a url of its own and held children is a group whose first item is its own link. The order is the stored menu index, then the name. The current item is the one whose url, ~/ read as /, is the request's path without its path base, ignoring a trailing slash and case.

The source writes to none of the manager's cached answers: each item is a new object, so one user's menu never reaches another's. The answers are cached, so a grant shows when the cache next refreshes, as it does at the gate. A fault answers an empty menu with Failed set and writes one Error under Solhigson.Admin.Navigation.KitMenuSource, with the exception, the permission manager and the role names, any control or format character in a name written as its \uXXXX escape; the request's cancellation propagates and logs nothing. A permission whose name is no id token, which KitShell cannot key an item by, is left out with its children, and named by its id in one Warning.

Page header, lead, empty state and pager

A list screen opens, reads and pages the same way: KitPageHeader holds the title as the page's one <h1> (in the serif face), an optional Line under it, a subtitle such as a count or a scope, no wider than the measure, and an optional Actions slot at the title's end, which moves under the title when the header is 400px wide or less. A line that holds more than text, such as an email and a quiet link back to a list, is LineContent, markup shown in the line's place and style; when it is set, Line is not shown. A screen's purpose sentence is not the header's line: it is KitLead, a page's or a section's one lead sentence, at a section heading's size; it is a paragraph, never a heading.

<KitPageHeader Title="Users" Line="@($"{page.Total} users, {page.Invited} invited")">
    <Actions>
        <KitButton Variant="KitButtonVariant.Primary" Href="~/users/new">New user</KitButton>
    </Actions>
</KitPageHeader>
<KitLead>Who can sign in to the admin, and what each may do.</KitLead>

@if (page.Rows.Count == 0)
{
    <KitEmptyState Title="No users match" Line="No user matches these filters." ClearHref="~/users" />
}

<KitPager NextHref="@(page.NextHref)" FirstHref="@(page.FirstHref)" />

The hrefs are written @(page.NextHref): Razor reads a bare @page as the page directive.

KitEmptyState says what is empty and why, its title an <h2>, with an optional Action (such as a link to create the first row). With ClearHref it is the "no match for these filters" form and offers a "Clear filters" link; without it, the "nothing here yet" form, which offers the next step:

<KitEmptyState Title="No roles yet" Line="A role groups the permissions a user may hold.">
    <Action>
        <KitButton Variant="KitButtonVariant.Primary" Href="~/roles/new">Create the first role</KitButton>
    </Action>
</KitEmptyState>

A list whose viewer cannot add rows shows no action, and names in its Line who can: "An administrator adds roles." The empty state's action is Primary only when the header holds none: when the header already offers it, the empty state's button is Default, or the empty state leaves the action to the header, so a screen has one Primary action.

KitPager pages a keyset list with links: forward to NextHref, which carries the next page's cursor, and back to FirstHref; a keyset cursor has no previous page. With both it shows "First page" and "Next page"; with NextHref alone, the first page of several, "Next page"; with FirstHref alone, the last page, "First page" and "End of list"; with neither, nothing. Every href goes through KitHref.Local and a refused one renders no link; a refused NextHref shows no link and no "End of list", since the list may go on. A cursor in a link shows in the address bar, so it holds ids and instants alone, as the framework's do.

Data table and filter bar

KitTable<TRow> lists Rows under KitColumn<TRow>s, each a sentence-case Title and a cell, a template over the row that holds components and text, which Razor encodes: a cell is never an HTML string. Align="KitAlign.End" ends a column of numbers and sets them in tabular figures; Priority="KitPriority.Low" hides a column when the table is 720px wide or less, so a phone keeps the columns that matter in view, and the table scrolls sideways inside its own wrapper rather than widening the page. The columns are collected before the table is drawn, so one static render shows every header and cell; a column takes its row type from its table. Caption names the table for a screen reader, and shows with ShowCaption; Empty shows in the table's place when there is no row.

<KitTable Rows="@users" Caption="Users">
    <Empty>
        <KitEmptyState Title="No users match" Line="No user matches these filters." ClearHref="~/users" />
    </Empty>
    <ChildContent>
        <KitColumn Title="Name">@context.Name</KitColumn>
        <KitColumn Title="Status"><KitStatusPill Tone="@context.Tone" Text="@context.Status" /></KitColumn>
        <KitColumn Title="Sign-ins" Align="KitAlign.End" Priority="KitPriority.Low">@context.SignIns</KitColumn>
        <KitColumn Title="Actions" HideTitle Align="KitAlign.End">
            <KitMenu Id="@($"user-{context.Id}-menu")" Label="@($"Actions for {context.Name}")">
                <KitMenuItem Href="@($"~/users/{context.Id}")">Open</KitMenuItem>
            </KitMenu>
        </KitColumn>
    </ChildContent>
</KitTable>

HideTitle keeps a column's header for a screen reader alone, for a column whose cells say what they are, such as a row's menu. There is no sort or row-open script: a sortable column is a link the app writes in its cells or above the table.

KitFilterBar is a plain form around the app's KitFields, with an "Apply" button, a Default one since the screen's Primary action stays the header's, and, with ClearHref, a "Clear" link; it wraps onto as many rows as the width needs, and opts in to enhanced form handling (data-enhance), so the list is swapped in place. Enhance is true unless set. A bar holding a field named after a member of the form element, such as action, method or target, sets it false and then submits as a plain form, loading the page whole: the browser reads that field in place of the form's own member, so Blazor's enhanced submit, which reads the form's action, would fetch a wrong address. The audit screen's bar is such a bar. Method is KitFormMethod.Get unless set, so a filtered list has an address a user can keep and share. A filter on a personal value, such as an email or a name, uses Method="KitFormMethod.Post", so the value stays out of the address, the access log and the browser's history; a Post filter takes a FormName, its @formname, and carries the antiforgery token, Blazor writing the _handler field itself, and the page binds the fields with [SupplyParameterFromForm(FormName = …)]. Action, the page's own address when unset, and the clear link go through KitHref.Local: an Action it refuses throws, and a refused clear link is not shown. A list filtered by a Post keeps its filter on the server, in the session or behind an opaque server-side cursor, so the pager's links carry no personal value; or it is one page, with no pager. Id, when set, is the form's id, so a submit button elsewhere on the page can name the form (form="...") and post its fields; an Id holding white space, a control or a format character throws.

<KitFilterBar ClearHref="~/users">
    <KitField Name="role" Label="Role" Kind="KitFieldKind.Select" Options="@roles" Value="@Role" />
</KitFilterBar>

<KitFilterBar Method="KitFormMethod.Post" FormName="find-user" ClearHref="~/users">
    <KitField Name="email" Label="Email" Kind="KitFieldKind.Email" Value="@Email" />
</KitFilterBar>

The settings screen

KitSettingsEditor is the settings screen: every setting the app's catalogue declares, one section a group in the order the catalogue registered them, each setting a KitSettingField row in a box whose id is kit-setting- and its key, written as a field's id writes a name. Its header, titled "Settings", counts the settings and, when a setting carries a flag or the table holds a row no setting declares, links to the "needs attention" filter, saying how many. Above the groups it shows a warning that a secret's save is refused while the legacy encryptor is in force and a setting is a Secret or stored sensitive; the attention view also says how many stored rows match no declared setting, and that a row is cleared when the app declares it in its catalogue, or it is removed from the settings table. Under the groups, the section "Rows with no declaration" lists those rows (see Removing a row no setting declares). A GET filter bar finds settings by words in their key, name or purpose, never in a value, and by "needs attention". A component cannot be given a route, so the app writes the page:

@page "/admin/settings"
@using Microsoft.AspNetCore.Authorization
@using Solhigson.Framework.Web.Attributes
@using Solhigson.Framework.Web.Authorization
@attribute [Permission("settings.view")]
@inject IAuthorizationService Authorization

@if (canEdit is bool edit)
{
    <KitSettingsEditor CanEdit="@edit" HistoryHref="~/admin/audit" />
}

@code {
    private bool? canEdit;

    [CascadingParameter]
    private HttpContext? HttpContext { get; set; }

    protected override async Task OnInitializedAsync()
    {
        var decision = await Authorization.AuthorizeAsync(HttpContext!.User, PermissionPolicy.For("settings.edit"));
        canEdit = decision.Succeeded;
    }
}

The page's [Permission] lets a viewer see the screen; CanEdit, false unless set, is a second permission's, decided on the server. Without it a Personal value is shown as "Hidden", and the listing is read outside a write session; with it the value is in its field. A Secret's value is never written into the page, with or without it. The sample renders the editor once canEdit is decided. An editor whose CanEdit changes lets a read in flight end and reads the listing again, and a render, a streamed one included, shows only a listing read with the CanEdit in force, so none shows a Personal value that CanEdit forbids; a read that failed is not made again, so one fault is one Error and one alert.

HistoryHref, null unless set, is the audit page's path on this site, alone, with no query or fragment: the page of The audit screen, ~/admin/audit in the sample. With it, each row's control column ends with "History", a Ghost button link to that page at ?type=AppSetting&id=<key>, each value escaped with Uri.EscapeDataString and the link passed through KitHref.Local. It names no day, so the list reads the setting's whole history. A visually hidden "of" and the setting's label follow the word, so each row's link names its setting by its label. A setting's history lists the changes made on the settings screen, by the type AppSetting and the setting's key; it does not list the rows audit capture may write for the AppSetting table under the row's numeric id. Without HistoryHref no link renders; a value that is no path on this site, or that holds a query or a fragment, throws when the page renders.

The app must have called RegisterSolhigsonDependencies with a database (or RegisterSolhigsonDependenciesWithProvider), which registers the SolhigsonConfigurationService and the ConfigurationWrapper the editor injects. It registers its settings catalogue at start (SolhigsonConfigurationService.UseSettingsCatalog); until it does, the screen shows the empty state "No settings are declared", and a registered catalogue that declares nothing shows "The catalogue declares no setting". AddRootEncryption at start lifts the warning on a secret's save.

The page refuses framing, so no other site can lay the screen under a decoy. The app must send X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on this page; the framework and the template send neither, and the editor sets no header.

A listing that cannot be read shows a Danger alert, "The settings could not be loaded", and writes one Error under Solhigson.Admin.Components.KitSettingsEditor, naming the component, with the exception; the page holds none of its text. The request's own cancellation propagates and logs nothing.

Saving and resetting a setting

With CanEdit true, every line is a form of its own. The form posts to the page's path and the row's id, without the filter's query, so the posted line is on the page whatever filter it matched. Each form sits in a FormMappingScope named from its key, and Blazor writes its _handler, such as [SignIn_003AMaxAttempts]setting; the form also holds the antiforgery token, the key and the field. A line shows:

  • "Save" when it can be edited, but a toggle. A toggle shows no "Save": it saves when it changes. Its "Save" is inside <noscript>, for a browser that runs no script. A toggle that can also be reset has a visually hidden "Save" as its form's first submit button, so Enter in the form saves it and never resets it. The button is clipped to nothing (kit-sr) rather than not rendered, since a browser may skip a button with no box when Enter submits; it is out of the tab order (tabindex="-1") and of the accessibility tree (aria-hidden="true").
  • "Reset to default" when the listing calls it resettable. A Secret shows it only while a row of it that no read sees is stored.
  • The reset alone when it cannot be edited but can be reset, such as a Startup setting's row.
  • No button when it can be neither saved nor reset. Its form is still there, so a form posted after its line lost its last button is answered at the line.

Every button is named op, its value save or reset; the alerts and buttons sit under the field, in its column.

With CanEdit false no form is rendered, so a post gets the framework's 400 and nothing is written. The handler also checks CanEdit before any call, so a post that reaches it in another way writes nothing.

A line whose value may be shown also posts the row state it was loaded with. The save passes that state on as its SettingLoad, so a save of a row changed since the page loaded is refused. A Secret, or a row stored sensitive, posts no row state. A post whose key is not its form's, whose row state the page did not write, or whose button no form has, saves nothing and says "This form is out of date: nothing was saved."

The outcome is said at the line:

Outcome Shown as
Saved A Success alert, "Max attempts saved."
Reset A Success alert that names the value now in force.
No change, or no row to reset A Neutral note that nothing changed.
A Secret posted blank A Neutral note that the stored secret was kept.
Refused The sentence beside the field, which keeps what was typed but never a secret's. A line with no field shows it in a Warn alert. The sentence names the setting by its label and says what to enter, such as "Enter a whole number from 1 to 10.", never the key in brackets or the declaration's terms.
Changed since the page loaded A Warn alert that nothing was saved and names the value now stored, which the field then shows.
Failed A Danger alert that nothing was saved, with no exception text.
Cache not told A Warn alert that other instances may show the old value until their settings cache recovers.

A setting no longer declared when its save runs has no line, so its outcome is said above the groups.

Removing a row no setting declares

Under the groups, the section "Rows with no declaration" lists each stored row the catalogue does not declare in a KitTable: its name, and its flags as the setting field's short pills, such as "Looks secret". No value is shown, since nothing says whether such a row holds a secret. The filters leave the section as it is, so the "needs attention" view shows it too. The section is not rendered when no catalogue is registered, when the catalogue declares no setting, or when no such row is stored: with no catalogue every row would be listed.

With CanEdit true, each row has a "Remove" button. It opens one KitConfirm, "Remove this row?", filled with the row's name: "The row … matches no declared setting. Older code may still read it by name, and this screen cannot put it back." The confirm's "Remove row" posts the name to the page's path and the section's id, #kit-settings-stray. The editor handles the post itself (OnConfirm), with the handler stray-remove. It checks CanEdit before any call, then calls the framework's RemoveUndeclaredRowAsync, which judges the name again: a name a setting declares, or a row the database matches to one, is refused. The confirm is rendered whenever a removal could be made, so a confirm posted after its row went is answered; with no stray row left, the section shows its heading and the outcome alone.

The outcome is said under the section's heading, above its table:

Outcome Shown as
Removed A Success alert, "The row Retired:Banner was removed."
No such row A Neutral note, "No stored row is named Retired:Banner; nothing was removed."
Belongs to a setting A Warn alert naming the setting by its label, "Nothing was removed: SignIn:MaxAttempts belongs to the setting Max attempts. Reset that setting above instead."
Refused otherwise A Warn alert with the framework's sentence, opening "The row Retired:Banner was not removed."
Failed A Danger alert that nothing was removed, with no exception text.
Cache not told A Warn alert, as for a save.

With CanEdit false neither the buttons nor the confirm are rendered, so a post gets the framework's 400 and nothing is removed; the handler's own check covers a post that reaches it another way. Neither is rendered either when KitHref.Local refuses the page's path as the confirm's action, such as a path holding an escaped backslash that reaches the page by an optional route part.

Recording who changed a setting

Each save, reset or removal done is recorded through the audit seam, IKitAudit (see Recording changes), after it is done. The audit row holds:

  • the category SecurityEvent;
  • the action settings.saved, settings.reset or settings.stray-removed (KitAuditActions);
  • the entity type AppSetting (KitAuditEvent.SettingEntityType), with the setting's key, or the removed row's name, as both the entity id and the subject's display name;
  • the actor;
  • a payload of the key, PreviousShown and NewShown, the values before and after as the framework's result shows them. A Secret's value, a row stored sensitive and a Personal value are the mask. A removal's NewShown is null, and its PreviousShown is the value removed: the mask for a row stored sensitive or under a secret-looking name, else the value, which is what a developer puts back.

A refusal, no change, a change made elsewhere and a failed save or removal change nothing, and record nothing.

When the record cannot be written, the change is not undone. The two are written by different contexts, so the screen shows the Success alert and a Warn alert: "No audit record was written for this change. Record it by hand if the audit trail must hold it; the app's log holds the error." A reset's says "this reset", a removal's "this removal".

When no change can be recorded, the screen shows a Warn alert above the groups with CanEdit true, titled "Changes here leave no audit record". The read-only screen, where nothing changes, does not show it. No change can be recorded when:

  • IKitAudit is not registered;
  • no audit service resolves;
  • the app's context does not map AuditTrail and no IAuditSink is registered.

The record is written with no cancellation, so a save is recorded even when the operator has left the page.

The screen writes one log line, under Solhigson.Admin.Components.KitSettingsEditor. The audit seam writes its own lines under Solhigson.Admin.Auditing.KitAudit (see Recording changes). The save, the reset and the removal write theirs under Solhigson.Framework.Infrastructure.ConfigurationWrapper, with the setting's key and never its value when the value may not be shown. The settings cache's invalidation writes under Solhigson.Framework.EfCore.Caching.EfCoreCacheManager, and its Redis change tracker under Solhigson.Framework.EfCore.Caching.MemoryCacheProvider:

Line Level Text What to do
KitSettingsUnlisted Error {Component} could not read the settings listing, so the page shows that the settings could not be loaded. Read the exception; fix the database or the catalogue it names.
Saved Information The setting [{setting}] was saved: {previous} to {saved}; cache confirmed {cacheConfirmed}. Nothing. A False means other instances may show the old value until their cache recovers.
Reset Information The setting [{setting}] was reset: {removed} row(s) removed, {previous} to {inForce}; cache confirmed {cacheConfirmed}. As for Saved.
Removed Information The undeclared row [{setting}] was removed; cache confirmed {cacheConfirmed}. As for Saved.
Not declared Warning A {save|reset} named the setting [{setting}], which is not declared; nothing was {saved|reset}. Declare the setting in the catalogue, or stop posting it.
Not done Warning The setting [{setting}] was not {saved|reset|removed}: {reason} Act on the reason: a setting read at start is changed in configuration; a row nothing would answer without keeps its value; a declared setting's row is reset, not removed.
Refused Warning The setting [{setting}] was not {saved|reset|removed}: {rule}. Act on the rule: a value in bounds, a page loaded again, or AddRootEncryption for a secret.
Saved plain Warning The setting [{setting}] is saved plain although its name {reason} (term '{term}'): its value is a flag or a number. Check the name does not hold a secret.
No catalogue Warning No settings catalog is registered (SolhigsonConfigurationService.UseSettingsCatalog), so a settings table write is held to no declaration, only to the encryptor and secret-name rules. Logged once per process. Register the catalogue at start.
Failed Error {Saving|Resetting|Removing} the setting [{setting}] failed. Read the exception; the screen said nothing was done, so the operator tries again.
Cache timed out Warning [{CacheType}]: Invalidation of {Types} did not complete within {Timeout} The value is stored; other instances may serve the old value until their cache entry expires. Check the cache store (Redis) and its latency.
Cache failed Warning [{CacheType}]: Invalidation of {Types} failed Read the exception; as for a timeout, other instances may serve the old value until their cache entry expires.
Cache not invalidated Error [{CacheType}]: Unable to invalidate cache A fault other than Redis's in the save's own invalidation (the EF Core interceptor's). Read the exception; other instances may serve the old value until their cache entry expires.
Change tracker unavailable Warning Change tracker unavailable: {Kind} ({Reason}) on {Channel}; entries cached before the outage are served until they expire or the tracker recovers, nothing new is cached, and the poll retries Redis every {Interval}; a writer should use InvalidateAndWaitAsync to confirm a change was published Logged once per outage, by the first call that finds Redis down, the save's invalidation included; a Redis failure the save meets writes neither "Cache failed" nor "Cache not invalidated". Restore Redis; until then the screen says the cache was not told.
Change tracker available again Warning Change tracker available again: Redis answered; {Lost} invalidations were lost on this pod during the outage ({Resend}) Closes the outage, once. Nothing, unless the lost invalidations were not sent again.

Recording changes

IKitAudit (Solhigson.Admin.Auditing) is the one seam through which every admin screen records a change it made. AddSolhigsonAdmin registers it, scoped, as KitAudit<TContext> over the app's identity context TContext. The app must map AuditTrail in that context's OnModelCreating and migrate, or register an IAuditSink that writes the rows elsewhere. The framework's RegisterSolhigsonDependencies registers the audit service, IAuditTrailService<TContext>. That registration is made through Autofac, which the service collection does not see. So the seam resolves the audit service, the actor provider and the context from the request's services at first use, not at registration.

TContext must be registered scoped, as AddDbContext and the framework's Autofac module register a context. The seam looks for an unsaved row on the instance it resolves, which must be the one the framework's service wrote on.

  • Records is false when no audit service resolves, or when the context does not map AuditTrail and no IAuditSink is registered. The framework's service would then drop the row with a log line, so the seam does not say a row was written. A screen asks Records to say on the page that its changes are not recorded. An app that never called AddSolhigsonAdmin gets a seam whose Records is false.

  • RecordAsync(KitAuditEvent, CancellationToken) writes one row and answers whether it was written; handed to the app's sink counts as written. It throws only the caller's own cancellation. A write that throws is logged and answered false. The framework's service swallows a failed write, so the seam also answers false in two cases:

    • A row the service left unsaved on the context. The seam detaches it, so no later save in the request writes it.
    • A sink that threw. With a sink and the framework's own service, the seam writes through an instance of that service of its own, over the app's sink behind a watch, and reads what the handoff threw. The container's registrations are left as they are, so no other caller resolves the watch.

    With an audit service of the app's own in place of the framework's, the seam answers false for what that service throws, and cannot see what it swallows: a write it swallows is answered true.

  • KitAuditEvent carries the category, the action, the subject's entity type, id and display name, and the payload. The payload is stored as it is: the framework masks nothing on this path, so a screen passes a projection that holds only what the row may show.

  • The actor is the app's IAuditActorProvider's. The framework's default provider gives the unattributed actor. When it does, the actor is built from the request's principal, and its source is web. Its id is read as the users seam reads the acting user (see The acting user): the first claim of Identity's ClaimsIdentity.UserIdClaimType (NameIdentifier unless the app sets another), counted only when the identity that holds it is signed in. Its name is that identity's. With no such id, the name is the principal's own identity's when it is signed in. An app whose tokens carry the id as sub sets UserIdClaimType to sub. A provider of the app's own that names an actor is used as it is.

  • An event that names its own actor (KitAuditEvent.ActorUserId) is recorded with that id as its actor, and no name. The provider's source and address are kept, and an unattributed source becomes web. The account seam's events do this: a sign-in is made on an anonymous request, so the user it is about is its actor.

The seam writes these lines under Solhigson.Admin.Auditing.KitAudit, with the entity id (a setting's key) and never the actor or a value:

Line Level Text What to do
KitAuditOff Warning Admin changes are not recorded in the audit trail: {Reason} Each admin screen that changes data says so above its content. Logged once per process. Act on the reason: register the audit service (RegisterSolhigsonDependencies), map AuditTrail in the context and migrate, or register an IAuditSink; call AddSolhigsonAdmin when the seam is not registered. A reason that the service could not be resolved carries the exception.
KitAuditFailed Error The audit row of {Action} on [{EntityId}] was not written: {ExceptionType}; the change itself was made, and is not undone. The line names the exception's type only, never the exception or its message, which can hold what the row held. Read the audit service's or the sink's own log for the cause, and fix the audit store. The change has no audit row, so record it by hand if the audit trail must hold it.
KitAuditUnsaved Error The audit row of {Action} on [{EntityId}] was not written: the audit service left it unsaved, and its own log line holds the cause; the change itself was made, and is not undone. Read the framework's line under AuditTrailService, "Explicit audit event was swallowed under the never-block invariant", for the exception, and act as for KitAuditFailed.

Reading the audit trail

IKitAuditReader (Solhigson.Admin.Auditing) is the one seam through which an admin screen reads the audit trail. AddSolhigsonAdmin registers it, scoped, as KitAuditReader<TContext> over the framework's IAuditTrailReader<TContext> for the app's identity context, with either overload. A seam the app registered first is kept. The framework registers its reader through Autofac, open-generic, so the seam resolves the reader and the context from the request's services at first use. AddSolhigsonAdmin also registers TimeProvider.System when the app registers no TimeProvider; the seam reads the time from it.

Member Answers What it reads
Available bool False when no reader resolves, when the context does not map AuditTrail, or when resolving the reader or the context threw. It is decided once a request, at the first use of Available or of a signed-in viewer's read; a refused read resolves nothing. A throw writes one KitAuditReaderUnresolved, naming the first member that resolved the reader, and is not tried again in the request. When false, every read of a signed-in viewer answers NotAvailable and queries nothing. Available never throws.
SearchAsync(principal, search, ct) KitAuditPage (Rows, NextCursor, From, To, Offset, ReadAt, Scoped, NamesUnavailable, Outcome, Message) One page of the framework's SearchAsync, newest first, at the reader's default page size. Every filter and the cursor in search are passed through. The page says the window, the offset, the instant the time was read at and the scope it read.
GetAsync(principal, id, createdKey, ct) KitAuditLookup (Record, Outcome, Message) The framework's GetAsync of one row. id is the row's id in its "D" form and createdKey is the row's CreatedKey. An id that is not a Guid in that form, a key AuditTrailKey.TryParseCreatedKey refuses, and a key that matches no row all answer NotFound. The first two read nothing.

A KitAuditSearch holds FromDay, ToDay, Category, Action, EntityType, EntityId, ActorUserId, Cursor and Zone. Each string filter narrows by exact equality when it is not blank. The days are the viewer's days in Zone, the last one searched whole; a null zone is UTC.

The window is the framework's AuditTrailWindow.Resolve:

  • The time is read once. The offset is Zone.GetUtcOffset at that time, so a zone in its summer gives its summer offset. With no zone, the offset is zero.
  • With no days, a search naming an entity type, an entity id or an actor is scoped (AuditTrailSearch.IsScoped). It reads all time, from 1 January 2000 to the midnight after today in UTC.
  • Any other search with no days reads the viewer's today at the offset.
  • From and To on the page are UTC instants; Offset is the offset used.

A KitAuditRow holds Id, CreatedKey, Created (UTC), Category, Action, ActionLabel, Subject, Actor, EntityType, EntityId, ActorUserId, Linkable, ActorLinkable and ActorAttempted. ActionLabel is KitAuditLabels.For (below). Subject and Actor are the framework's AuditDisplay labels, built from the names stored on the row or, where it stores none, the names looked up for the viewer (below).

Linkable says whether a link may carry the row's entity id. It is true for a DataChange, whose id is an entity's key, and for an action the package records, compared exactly as stored: the settings screen's (KitAuditActions), the user screens' (KitUserAudit) and the role screens' (KitRoleAudit). It is false for every other row, such as a sign-in event, whose entity id may be text a caller typed.

ActorLinkable says whether a link may carry the row's ActorUserId: the id is stored and is a user's key, on a Linkable row or on a row whose actor the viewer's name lookup named. A sign-in event's actor id may be text a caller typed too. ActorAttempted says the row stores an actor's name and no actor id, on a SecurityEvent that is not Linkable, the name not the framework's AuditActor.Unattributed: the identity a caller gave, never a person the trail knows.

A KitAuditRecord is a row with Sentence, SourceType, SourceId, UserIp, Changes and Snapshot read by the framework's AuditPayload, and Restricted and NamesUnavailable (below). Sentence is KitAuditLabels.Sentence of the record's category, action, entity type, Actor and Subject. It is worked out each time it is read, so a copy of the record with other names reads with those names. The seam's types give a log their key, their outcome or the names of the filters set, never a value.

The people on a row

A name a row stores shows to every viewer. An id a row stores with no name is looked up through the framework's UserAdministration.ResolveDisplayNamesAsync, for the viewer, in one call a page or a record:

  • An actor id is looked up when the row stores no actor name.
  • A subject id is looked up only when the row stores no subject name, its entity type is a user's and its action is in KitAuditOptions.ResolvedSubjectActions. A user's entity type is one in KitAuditOptions.UserEntityTypes, or the class name of the identity's own user (the context's TUser), which audit capture stamps on a data change of a user. A row with a blank action is never looked up, since its entity id may be text a caller typed.
  • A user the viewer's rules scope admits shows as the rules' display name. Any other id shows as a fragment (AuditDisplay.IdFragment), as it does with no lookup.
  • When the lookup fails, NamesUnavailable is true on the page or the record, and a screen says so. The framework's UserAdministration writes the Error.
  • With no IUserAdministrationRules<TUser, TKey> registered, nothing is looked up and nothing is logged for it.

The viewer is read as the users seam reads the acting user. Both sets of KitAuditOptions compare exactly as stored; an app changes them with services.Configure<KitAuditOptions>(...):

Option Default Change it when
UserEntityTypes User An app records rows of its own whose entity id is always a user's id, under another entity type. The identity's own user class needs no entry.
ResolvedSubjectActions The user screens' users.* actions and the account seam's account.* actions, each keyed by the id of a user read from the store An app records an action of its own whose entity id is always a user's id. It is an allow-list: an action keyed by typed text is never added.

A KitAuditRecord of a user's entity type is checked once with IKitUsers.GetAsync of its entity id. The check follows the users seam's reach rule, the rules' scope and their roles, which is stricter than the scope alone that names follow. These make the record Restricted:

  • any answer but Done: a user out of reach or missing (NotFound), a refused viewer (ActorRefused) or a fault (Failed);
  • an entity id that is not a user's key: the record is not Linkable and its action is not in ResolvedSubjectActions, so the id may be text a caller typed. It is restricted with no check, so the text never reaches the users seam's log;
  • a blank entity id, also with no check.

A restricted record keeps who did what to whom and carries no Changes, no Snapshot and no UserIp: an email change stores the previous address, and an address is personal data. Any record also withholds its actor's UserIp unless the lookup names the actor for the viewer: an actor out of the viewer's scope and a failed lookup both withhold it, and NamesUnavailable says which. A record's one lookup asks for its actor's id even when a name is stored, and the stored name still shows; the answer decides the address only. A record with no actor id keeps its UserIp, since no lookup can name its actor, so the record page shows it with ShowIp to every viewer unless the record is Restricted. A list shows no address and makes no such check.

With no rules registered, nothing is looked up, no record is restricted and every address shows: no scope is defined, so the audit page's permission is the only gate. Grant that permission only to roles that may see every user.

The words of an action

KitAuditLabels (Solhigson.Admin.Auditing) gives the words an audit screen shows for an action. Every text is unencoded; the screen encodes it.

Member Gives
For(category, action, entityType) The action's label in a list. A package action has its own label (table below). Any other action gets the framework's AuditDisplay.ActionLabel: a data change reads as its verb and entity type ("Update Invoice"), a blank action reads as its category's label ("Security Event"), and any other action reads as stored.
Sentence(category, action, entityType, actor, subject) The record as a sentence. A package action reads <actor> <verb phrase> <subject>, such as "Ada Obi changed the roles of Jane Doe". Any other action reads <label>: <subject>, by <actor>, with the label from For. A label that names the subject's type, a data change's, is followed by an unnamed subject, its type and its id fragment, as its fragment alone, so the type is said once: "Update Invoice: inv-1, by Ada Obi". A stored subject name that starts with the type and " · " loses that prefix in the sentence too; the record's Subject field keeps it. A blank actor reads "System" (AuditDisplay.SystemActor). A reset request (account.reset-requested), which anyone may make with no sign-in, reads "a visitor" for an actor that names no one, blank, "System" or "unattributed": "A visitor asked for a password reset link for Jane Doe". With a blank subject a verb phrase has no object, so every action then reads <label>, by <actor>. The names are joined as given, unmarked, so a subject's name, such as a role's, can imitate an actor clause. The sentence is therefore not the record's attribution on its own: a screen that shows it shows the Actor field beside it.
TypeInWords(entityType) "user" for User, "role" for Role and "setting" for AppSetting, compared exactly as stored. Any other type reads as stored, and a missing type gives an empty string.

An action belongs to the package only when it matches exactly as stored, letter case included. An app's own actions read as stored, so an app that wants words stores a readable action name. The package's actions and their words:

Action Label Verb phrase
settings.saved Setting saved saved
settings.reset Setting reset to its default restored the default of
settings.stray-removed Stray setting removed removed the stray setting
users.enabled User enabled enabled
users.disabled User disabled disabled
users.unlocked User unlocked unlocked
users.two-factor-reset Two-factor reset reset the two-factor sign-in of
users.roles-changed Roles changed changed the roles of
users.email-changed Email address changed changed the email address of
users.created User created created
users.password-link-sent Password link sent sent a password link to
roles.created Role created created
roles.permissions-changed Permissions changed changed the permissions of
roles.outside-grants-removed Grants outside the group removed removed the grants outside the group from
roles.deleted Role deleted deleted
account.signed-in Signed in signed in as
account.locked-out Locked out after wrong passwords or codes was locked out after wrong passwords or codes as
account.signed-out Signed out signed out as
account.reset-requested Password reset requested asked for a password reset link for
account.password-reset Password reset set a new password from a reset link for
account.password-changed Password changed changed the password of
account.two-factor-enrolled Two-factor turned on turned on two-factor sign-in for
account.two-factor-disabled Two-factor turned off turned off two-factor sign-in for

KitAuditLabels holds the package's one list of the actions it records, and Linkable reads it too; this table shows that list. A new action constant on KitAuditActions, KitUserAudit, KitRoleAudit or KitAccountAudit needs a label and a verb phrase in KitAuditLabels. Without them the package's reflection test fails, and the action's rows are not Linkable.

Every answer carries a KitAuditOutcome and a Message from KitAuditMessages.For:

Outcome Message
Done Done.
NotAvailable The audit trail is not available: no audit reader resolves for the app's context, or the context does not map AuditTrail. When resolving threw, the app's log holds the cause.
ActorRefused Sign in to read the audit trail: the request names no signed-in user, so nothing was read.
NotFound Audit record not found.
Failed The audit trail could not be read, so nothing is shown. Try again; the app's log holds the cause.

The viewer must be signed in and carry a user id, read as the users seam reads the acting user (see The acting user). Otherwise the answer is ActorRefused, and nothing is read or said about the set-up. A failed result from the reader is Failed with the sentence above, never the reader's own message. Nothing throws except the caller's cancellation.

The seam writes these lines under Solhigson.Admin.Auditing.KitAuditReader. A search's line names the filters set, never their values, since an entity id or an actor id can be text a caller typed:

Line Level Text What to do
KitAuditReaderNoActor Warning The audit reader seam refused {Method}: the principal carries no {ClaimType} claim on a signed-in identity, so it names no acting user; nothing was read. Check that the page requires a signed-in user. If the user is signed in, check that the identity carries the claim ClaimType names, or set IdentityOptions.ClaimsIdentity.UserIdClaimType to the claim it does carry.
KitAuditReaderSearchFailed Error The audit reader seam {Method} failed: window {From} to {To}, filters set {FiltersSet}, cursor given {CursorGiven}; nothing was shown. The line carries the exception. Check the audit store; a window that is empty means the fault came before the window was placed.
KitAuditReaderGetFailed Error The audit reader seam {Method} failed: record [{Id}], created key [{CreatedKey}]; nothing was shown. The line carries the exception. Check the audit store. The id and key are percent-encoded and cut to 64 characters with a ... marker.
KitAuditReaderUnresolved Error The audit reader seam {Method} failed: resolving the audit reader of {ContextType}, or the context, threw; the audit trail reads as not available for the rest of the request. The line carries the exception. Method is the first member that resolved the reader: available, or a signed-in viewer's search or get. A throw while resolving answers NotAvailable, never Failed. Fix the registration of the reader or the context it names.

A failed result from the framework's reader is logged by the reader under AuditTrailReader; the seam writes no second line for it.

The lines the audit screens cause

The audit screens write no line of their own. Beside the seam's lines above, the calls a read makes into the framework and the users seam write their own lines. The framework's reader writes these under AuditTrailReader, a search's naming the filters set and never their values. Each carries the exception, whose message is the provider's own:

Level Text When What to do
Error Audit trail search failed on {ContextType}: window {From} to {To}, page size {PageSize}, cursor given {CursorGiven}, {ElapsedMs} ms, filters set {FiltersSet}. A list's search threw inside the framework's reader. The screen shows the Failed alert. Read the exception and check the audit store.
Error Audit trail get failed on {ContextType}: created {Created}, {ElapsedMs} ms. A record's read threw inside the framework's reader. The page shows the Failed alert. As for a search.

The name lookup and a record's reach check write under UserAdministration (UserAdministrationDiagnostics.LoggerCategory), by ids or counts only, never a name, a filter's value or an exception's message. The lookup's lines, resolve_display_names, name the count of ids passed and no id; the reach check's, can_administer, name the viewer's id and the record's user id:

Level Text When What to do
Warning User administration {Operation} of {IdCount} ids refused: the actor is not a stored, enabled user A list or a record read by a signed-in account that is disabled or no longer stored. Its people show as id fragments. The account's session outlived its disable or delete: end its sessions.
Error User administration {Operation} of {IdCount} ids failed at step {Step}: {ExceptionType} The lookup threw. The screen says "Names could not be loaded". Read the step and the exception's type, and check the store and the app's rules.
Warning User administration {Operation} by actor {ActingUserId}: target {TargetUserId} not found within its reach A record about a user the viewer may not reach, or one no longer stored. The record is Restricted. Expected for a viewer outside the user's scope or roles. A rise: records about users out of reach are being opened.
Warning User administration {Operation} refused: actor {ActingUserId} is not a stored, enabled user (target {TargetUserId}) A record about a user, read by a signed-in account that is disabled or no longer stored. The record is Restricted. As for the lookup's refusal: end its sessions.
Error User administration {Operation} failed for actor {ActingUserId} and target {TargetUserId} at step {Step}: {ExceptionType} The reach check threw. The record is Restricted. Read the step and the exception's type, and check the store and the app's rules.

The reach check is the users seam's GetAsync: a step of it after the reach that throws writes KitUsersFailed, method get, under Solhigson.Admin.Users.KitUsers (see Log lines), by ids and the exception's type only, and the record is Restricted. The users seam's KitUsersNoActor is never written for it, since the reader refuses that viewer first. Each lookup adds one to the counter user_administration (see The framework's lines and counters), tagged method resolve_display_names, and each reach check one tagged can_administer. With no rules registered no such call is made, and none of these lines is written.

The audit screen

KitAuditList lists the audit records of one window, newest first, one page at a time, through IKitAuditReader.SearchAsync. A component cannot be given a route, so the app writes the page:

@page "/admin/audit"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("audit.view")]

<KitAuditList DetailHref="~/admin/audit/{id}/{created}" TimeZone="@AppZone" />
Parameter Required What it does
DetailHref yes The address of a record's page: a path on this site that holds {id} and {created}. Each row's id, in its "D" form, replaces {id}, and its CreatedKey replaces {created}, each url-encoded; the link then goes through KitHref.Local. A DetailHref without both, or one KitHref.Local refuses with a value in place, throws when the screen renders. Pass the two values to IKitAuditReader.GetAsync as the record's page receives them.
TimeZone no The viewer's zone: the days searched, the window's words and each record's time are in it. UTC when not set.

The app must call AddSolhigsonAdmin (see Reading the audit trail) and map AuditTrail in the context it passes. The page must require a signed-in user, since the screen passes the request's HttpContext.User. Today is the viewer's day at the instant the seam read the window at (KitAuditPage.ReadAt), so the header, the presets and the rows never disagree about it.

The screen has these parts, in this order:

  1. The header, "Audit trail". Its line says the window searched, in the viewer's zone, with the zone named: "Today, 10 Nov 2026 (UTC)", or "1 Nov 2026 to 10 Nov 2026 (UTC)", the second day the last one searched. A search that names a subject or a person and no day reads all time, and says "History of <subject>" or "Activity by <person>", each as a fragment of its id. The header's actions are "Today", "Last 7 days" and "Last 30 days": the filters in force over those days, each ending today. The one that is the window is marked aria-current="page".
  2. The filters: the first day and the last day, and the category. Under them, "More filters" holds the action, the subject's type, the subject's id and the person's user id. It is open when any of them holds a value.
  3. The table: when, what, the subject and the person. "When" is the record's date over its time of day, in the viewer's zone; the column's title names the zone. "What" is the action's label, which links to the record's page, with its category under it. The subject is hidden in a narrow table; the person stays. No row carries a colour.
  4. The pager: "Next page", and "First page" only when a cursor was given.

The filters are a GET form, so a filtered list has an address a user can keep:

Filter Field Values Search
From from A day, yyyy-MM-dd FromDay
To to A day, yyyy-MM-dd, searched whole ToDay
Category category DataChange, SecurityEvent, BusinessEvent Category
Action action The action as stored, such as users.enabled Action
Subject type type The entity type as stored, such as User EntityType
Subject id id The entity id as stored EntityId
Person's user id actor The acting user's id ActorUserId

The settings screen, the role page and the user page link to this page through their HistoryHref with these names: a setting's history by type and id, a role's by type and id, a user's by id alone, and a person's activity by actor, each with no day. An app whose audit page reads other names gets links that filter nothing, so its page must be KitAuditList, or read these names.

Each filter matches exactly, letter case included: the reader offers no search inside a value. A day in any other form, a category that is not one of its names (7, datachange) and a blank value are ignored, and the field shows empty. A cursor that does not parse serves the first page.

The pager and the presets keep the filters as they were given, the presets each with its own days, never the window the filters resolved to, so a person's whole history stays whole on the next page. A search with no day that names no subject or person carries the day it read, so its pages never cross a midnight. Every link goes through KitHref.Local, each name and value escaped with Uri.EscapeDataString.

A subject links to its history only when the row is Linkable. A person links to their activity only when the row's ActorLinkable says the actor id is a user's key: on a Linkable row, or on a row whose actor the viewer's name lookup named. A sign-in event's entity id and actor id may be text the caller typed, so the screen puts neither in a link, which an access log would record. An actor with no id whose name the row stores, on a sign-in or other security event that is not Linkable (ActorAttempted), is the identity a caller gave, such as a failed sign-in's user name. It reads "Attempted as <name>", muted, since a caller may give the name "System" or another person's. The framework's own unattributed name is no attempt and is not marked. No id longer than its fragment shows as text; a full id is only in a link or in a field the viewer filled in.

The filter bar is a plain GET form, never an enhanced one: its field action hides the form's own action from a script, so Blazor's enhanced submit would fetch a wrong address. Applying the filters loads the page whole.

Empty states and alerts of the audit screen

With no rows and a category or an action set, the screen shows "No records match these filters", with a link that clears every filter. Otherwise it shows "No activity in this window", with the window searched, and one remedy:

  • On a search of a subject or a person with days, "All dates": the same filters with no day, so all time.
  • On a search of no subject or person, "Last 30 days", unless the window already holds all of those days.
  • On a search of a subject or a person with no day, which read all time, none.
Outcome What the screen shows
Done with NamesUnavailable A Warn alert, "Names could not be loaded", above the rows.
NotAvailable A Warn alert of the outcome's Message alone, which names the reader and the AuditTrail mapping the app's context needs.
ActorRefused, Failed A Danger alert of the outcome's Message alone, and no table.

The screen writes no log line; the seam's lines, and those its reads cause (see The lines the audit screens cause), are above.

The audit record page

KitAuditDetail shows one audit record, whole, through IKitAuditReader.GetAsync. The app writes the page, with the record's id and created key in its route, the address the list's DetailHref names:

@page "/admin/audit/{Id}/{Created}"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("audit.view")]

<KitAuditDetail Id="@Id" Created="@Created" ListHref="~/admin/audit" UserHref="~/admin/users/{id}" TimeZone="@AppZone" />

@code {
    [Parameter]
    public string? Id { get; set; }

    [Parameter]
    public string? Created { get; set; }
}
Parameter Required What it does
Id yes The record's id, as the route gives it.
Created yes The record's created key, as the route gives it.
ListHref yes The audit screen's page: a path on this site with no query or fragment of its own. The header's "Audit trail" link and the not-found page's way back go to it, and every link to the list adds the list's query to it. A ListHref that KitHref.Local refuses, or one holding ? or #, throws when the page renders.
TimeZone no The zone the record's time shows in; UTC when not set. The time names the zone's id.
UserHref no The address of a user's page: a path on this site that holds {id}, which the actor's id replaces, url-encoded. The person's "User page" link goes to it, only when the actor's id is a user's key (ActorLinkable). A UserHref without {id}, or one KitHref.Local refuses with a value in place, throws when the page renders.
ShowIp no Whether the page shows the address the record came from. False unless set.

The page must not use stream rendering: no @attribute [StreamRendering] on it or on a layout around it. A page that streams sends its status before the lookup returns, so a record not found is answered with 200, not 404. That page shows the header "Audit record" and the empty state "Record not found", with "Audit trail" as its action.

ASP.NET Core 10 sends a page that sets 404 with no body: it leaves the answer to the app's status code pages. Add them, such as app.UseStatusCodePagesWithReExecute("/not-found"), or the browser shows an empty page.

The app must call AddSolhigsonAdmin (see Reading the audit trail) and map AuditTrail in the context it passes. The page must require a signed-in user, since the page passes the request's HttpContext.User.

An app that captures its user class, so that a user's data change is recorded, adds "securitystamp" to AuditCaptureOptions.AdditionalSensitiveNamePatterns, through a pre-populated AuditCaptureOptions singleton of its own, which the framework's registration (PreserveExistingDefaults) leaves in place. The framework's default patterns (AuditFieldMasker.DefaultSensitiveNamePatterns) do not mask SecurityStamp, so the row would store it as it is, and this page would show it. A pattern masks any property whose name holds it, letter case ignored, so "securitystamp" masks the secret and nothing else, where a plain "stamp" would also mask any Timestamp column.

Rows captured before the pattern keep the raw stamp. An app that has already captured its user class adds the pattern, then rotates every user's security stamp (UserManager.UpdateSecurityStampAsync) before it grants the audit page's permission; rotating ends every open session at the next stamp check. An app never opts Identity's user-token, user-login or user-claim types into capture, since their values are credentials no pattern masks and their records are not Restricted.

The page has these parts, in this order:

  1. The header. Its title is the record as a sentence (KitAuditRecord.Sentence), so the action is said once. Its line says when the record was written, in the viewer's zone, to the second, as the list's time column does, with the zone named as the list names it: "10 Nov 2026, 11:58:00 (UTC)". Then a quiet "Audit trail" link back to the list.
  2. A Warn alert, "Names could not be loaded", when the record's NamesUnavailable, as on the list; a Neutral alert, "Details withheld", when the record is Restricted.
  3. The facts: the category; the action as stored, the one place it shows, with "All records of this action"; the subject, with "History of this <type>" only when the record is Linkable; the person, read "Attempted as <name>" for an identity a caller gave, with "Activity by this person" and, with UserHref, "User page", each only when ActorLinkable; the source; and the address, only with ShowIp.
  4. "What changed", a table of each field before and after, when the record holds changes; "Recorded values", a table of each field and its value, when it holds a snapshot. A record with neither says "No field values were recorded."

"All records of this action" lists every record of the stored action from the first day of all time to today, since an action names no subject or person, and the list would otherwise read today alone. The history and the activity links read all time, as the list's own do. Each link is built through KitHref.Local on ListHref, with the list's query names, each value escaped with Uri.EscapeDataString, so an entity id holding &, # or // reads back as itself. No full id shows as text: the subject and the person show as their fragments, and the record's source id is not shown.

A value equal to the capture's mask (AuditFieldMasker.MaskMarker, ***) or the settings' mask (SettingsCatalog.Mask) reads "Hidden"; a null reads "Not set", an empty string "Empty", and a value of white space alone "White space only". Each is muted, so a blank cell never stands for any of them. Any other value keeps its white space, and a value that starts or ends with white space is tinted to its extent, so a trailing space reads as a change. The reader unmasks nothing. A payload that is not the stored shape shows as stored under "Shown as stored", as text, in the kit's code block (see The application log record page), reached by keyboard as a region named for its section. The block keeps the class it shipped with, kit-audit-raw, beside kit-code, and its height is the component token it shipped with, --kit-audit-raw-height, the measure unless the app sets it. Nothing in a record is ever markup: every value is written as text, encoded.

The address a record came from is personal data: the page shows it only with ShowIp, and never for a Restricted record. The seam gives no address either when the viewer's name lookup did not name the actor; the fact then reads "Not available". A record with no actor id keeps its address, which ShowIp shows to every viewer unless the record is Restricted, so an app turns ShowIp on only where the address may be shown to every holder of the audit page's permission.

Outcome What the page shows Status
Done The record. A Done answer with no record, which only an app's own seam can give, shows the Failed alert. 200
NotFound The header "Audit record" and the empty state "Record not found", with "Audit trail" as its action. 404, when the response has not started
NotAvailable A Warn alert of the outcome's Message alone, under the header "Audit record" and its "Audit trail" link. 200
ActorRefused, Failed A Danger alert of the outcome's Message alone, under the header "Audit record" and its "Audit trail" link. 200

A record restricted for the viewer keeps who did what to whom, says its values and address are not shown, since the record is about a user the viewer may not see or one the page cannot check, and shows no value, no section and no address. The page writes no log line; the seam's lines, and those its reads cause (see The lines the audit screens cause), are above.

Reading logs

IKitLogs (Solhigson.Admin.Logs) is the one seam through which an admin screen reads logs: the application log through the framework's IAppLogReader, and the API exchanges through its IApiLogReader. AddSolhigsonAdmin registers it, scoped, as KitLogs, with either overload. A seam the app registered first is kept. The readers are the app's: AddSolhigsonLokiReader registers the ones that read Grafana Loki. They read Solhigson:Logs:LokiReadEnabled, Solhigson:Logs:LokiUrl, Solhigson:Logs:LokiUser, Solhigson:Logs:LokiToken and OTEL_RESOURCE_ATTRIBUTES. Give the reader a token that can only read logs, never the export's write credential, limited where the store allows to the app's own services and environment. Each reader is resolved from the request's services at its first use, once a request. A resolve that throws is that read's Failed, and is tried again at the next read. The seam reads the time from the TimeProvider that AddSolhigsonAdmin registers when the app registers none.

Every member takes the viewer's principal first. A principal that names no signed-in user is ActorRefused, and nothing is resolved or read. The viewer is read as every seam of the package reads the acting user.

Member Answers What it reads
GetSourceAsync(principal, kind, ct) KitLogSource (State, Newest, Outcome, Message) Whether KitLogKind.App or KitLogKind.Api can be read here. State is NotRegistered when no reader resolves. It is Off when the reader's ReadEnabled is false or, for Api, when the host does not export its API exchanges (OtlpExportState.ApiLogsExporting is false, or no OtlpExportState is registered). Neither reads anything. Otherwise it is Ready, and the newest record is read: Newest is a time (At), NoneInDay when the reader finds no record in its last 24 hours, or Unknown when that read failed, with the failure's Outcome.
SearchAppLogsAsync(principal, search, ct) KitLogPage<AppLogRecord> (Rows, NextCursor, From, To, Offset, Since, ReadAt, Outcome, Message) One page of the reader's SearchAsync, newest first, at the reader's default page size, over the window below.
GetAppLogAsync(principal, id, ct) KitLogLookup<AppLogRecord> (Value, Outcome, Message) The reader's GetAsync of one record. An id the reader refuses and one that matches nothing are both NotFound.
AppLogsOfRequestAsync(principal, requestId, around, ct) KitLogLookup<KitAppLogsOfRequest> (Records, More) The reader's GetByChainIdAsync: the first 50 records of one request, oldest first, and whether more exist. The reader reads the UTC day of around and the day either side. A request id that is not 32 hexadecimal characters is NotFound, and nothing is read.
SearchApiLogsAsync(principal, search, ct) KitLogPage<ApiLogRecord> As SearchAppLogsAsync, for the API exchanges.
GetApiLogAsync(principal, id, ct) KitLogLookup<KitApiExchange> (Record, RequestHeaders, ResponseHeaders) The reader's GetAsync of one exchange, with its headers read (below).

A KitAppLogSearch holds FromDay, ToDay, Since, MinSeverity, RequestId, UserId, Cursor and Zone. A KitApiLogSearch holds FromDay, ToDay, Since, Service, Method, StatusCode, PathContains, RequestId, Cursor and Zone. Each filter is passed to the reader as given: MinSeverity as the lowest severity shown, UserId as the record's user, Service as the service name, and StatusCode 0 as a call that reached no response. A request id that is not 32 hexadecimal characters is dropped, not failed, and the search reads every request. A cursor the reader refuses is dropped too, and the first page is read in its place.

The window is UTC instants, the end exclusive:

  • The time is read once. With no zone, the offset is zero.
  • With days, the window runs from the viewer's midnight of the first day to the midnight after the last, capped at now. A missing side takes the other's day. A first day after the last is read as the last alone.
  • Each midnight is placed at the zone's offset at that midnight, not at now. So a day of summer time, read in winter, is the day it was: in Europe/London, 24 October 2026 is 23:00 UTC on the 23rd to 23:00 UTC on the 24th. A midnight the clock reads twice is its first reading. A midnight the clock skips is the instant of the change.
  • With no days, the window is the hour before Since, or before now when Since is absent or later. The value used is returned as the page's Since. A list passes it back with the next cursor, so its window does not slide. The hour ends at the whole second at or before that value, so a link that carries it in whole seconds names the same window.
  • From and To on the page are UTC instants. Offset is the zone's offset at the start's midnight with days, and at the time of the request with none. ReadAt is the time of the request: the one reading of the clock the window was placed at.

Records are answered as the reader answers them, masked as they were exported. Nothing is unmasked, and no value is markup. A KitApiExchange reads each block of headers into a KitLogHeaders. A stored JSON object gives Entries, its names and values in the stored order; a value that is not a JSON string keeps its JSON text. Anything else stored is kept whole in Stored. None stored is KitLogHeaders.None.

Outcome When Sentence
Done The read was made. "Done."
NotRegistered No reader of that log resolves. "No application log reader is registered, so the application log cannot be read here. AddSolhigsonLokiReader registers the one that reads Grafana Loki." The API exchanges' sentence names them in its place.
Off The reader's ReadEnabled is false. "Reading logs is switched off here (for Grafana Loki, Solhigson:Logs:LokiReadEnabled is not true), so nothing was read."
Off The host does not export its API exchanges. "API exchanges are not exported from this host (Solhigson:Logs:ApiLogsToLokiEnabled is not true, or its logs do not export), so there are none to read."
ActorRefused The viewer is not signed in. "Sign in to read the logs: the request names no signed-in user, so nothing was read."
NotConfigured The reader answered missing-setting:<key>. "The log store is not configured: {key} is not set, so nothing was read. Set it in the app's configuration." A key that is not 1 to 128 letters, digits, _, ., : or - is not shown, and the sentence says the app's log names it.
Unreachable The reader answered timeout or transport, or threw a cancellation the caller did not ask for. "The log store did not answer, or could not be reached, so nothing is shown. Try again in a minute; the app's log holds the cause." After it, every later read in the same request answers Unreachable without calling either reader.
Refused The reader answered an HTTP status code. "The log store refused the read with HTTP {code}, so nothing is shown. Check the store's address and credentials; the app's log holds the cause."
NotFound The reader answered not-found or invalid-id, or the request id is not one. "Log record not found."
Failed The reader refused the read before making it: disabled, or an invalid- class such as invalid-trace-id or invalid-cursor (a refused cursor is first read again without it). The reader writes no line for these. "The log reader refused this read as it was asked, so nothing is shown. Reload the page and try again; if it still fails, check that reading logs is switched on here."
Failed The reader answered any other class, or a step of the seam threw. "The logs could not be read, so nothing is shown. Try again; the app's log holds the cause."

Nothing throws but the caller's own cancellation. The types give a log their outcome or their name, never a value.

The logs seam's log lines

The table lists the lines the log screens cause that an operator acts on, each with its level and what to do. The screens write no line of their own. The seam writes these lines under Solhigson.Admin.Logs.KitLogs. A line names the method, the step, the exception's type, the viewer's id and a fixed target: app_logs, api_logs, or logs for a kind that is neither. It never holds an id, a filter or a path the viewer typed, nor the exception's message. A failed read that the reader answered writes no line here. The framework's Grafana Loki reader writes its own, SolhigsonLokiReadFailed, under Solhigson.Framework.Logging.Loki.LokiReadClient, once for each read it could not make. It names the read's kind, the failure and the time taken, never the store's address, the token or the exception. A read it refuses before making one, disabled or an invalid- class, writes no line, and neither does a record it does not find.

Line Level Text What to do
KitLogsFailed Error The logs seam {Method} failed at step {Step}: {ExceptionType}; actor [{ActingUserId}], target [{Target}]. Read the step. Resolve means the reader could not be resolved, or its ReadEnabled threw: check the app's registration of the reader. Call means the reader threw, which the framework's readers do only on the caller's cancellation, or answered success with no payload: read the app's own reader. With TaskCanceledException or OperationCanceledException, the reader timed out on its own, and the answer is Unreachable. With ArgumentOutOfRangeException at Resolve, the kind asked for is neither log. With ArgumentNullException at Call, the search was null. Methods: app_source, api_source, app_newest, api_newest, search_app_logs, get_app_log, app_logs_of_request, search_api_logs, get_api_log, and source for a kind that is neither.
KitLogsNoActor Warning The logs seam refused {Method}: the principal carries no {ClaimType} claim on a signed-in identity, so it names no acting user; nothing was read. A logs screen was reached by a viewer who is not signed in. Put a [Permission] held only by operators on the page that hosts the screen, as the samples do; [Authorize] alone lets every signed-in user read every log.
SolhigsonLokiReadFailed Error Loki read failed: kind {LokiReadKind}, failure {LokiReadFailure}, elapsed {LokiReadElapsedMs} ms Read the failure. missing-setting: and a key means that setting is not set, and the screens answer NotConfigured: Solhigson:Logs:LokiUrl, which must be an absolute https URL with no user, query or fragment, Solhigson:Logs:LokiUser, Solhigson:Logs:LokiToken, or OTEL_RESOURCE_ATTRIBUTES, which must name deployment.environment.name. A number is the HTTP status the store answered, and the screens answer Refused: with 401 or 403, check the user and the token; with a 3xx, set the store's own address, since no redirect is followed; with any other, check the address and the store. timeout means one read took over 10 seconds (LokiReadClient.ReadTimeout), or one page's reads over 20: check Grafana Loki. transport means the store could not be reached or its answer could not be read: check the address, then Grafana Loki. Both answer Unreachable. Kinds: list, load-more, detail, chain and newest read the application log, and api-list, api-load-more, api-detail and api-newest the API exchanges.

The logs instruments

Each call the seam answers adds one to the counter logs, and records its time in seconds on the histogram logs.duration, on the meter Solhigson.Admin (KitLogsDiagnostics.MeterName). The app adds it to its metrics pipeline (AddMeter("Solhigson.Admin")). Both are tagged with method and outcome, and nothing else. A call the caller cancelled is not recorded. A clock whose timestamp cannot be read times nothing, and the call is still counted. A listener that throws loses its measurement, and the call is still answered.

Tag Values
method app_source, api_source, source, app_newest, api_newest, search_app_logs, get_app_log, app_logs_of_request, search_api_logs, get_api_log. The newest record's read in GetSourceAsync is its own method, app_newest or api_newest, counted beside the source's.
outcome done, not_registered, off, actor_refused, not_configured, unreachable, refused, not_found or failed. A source that can be read is ready, whatever its newest read answered.

What to watch: failed means read the seam's KitLogsFailed line, or the reader's own line. A failed with neither line is a read the reader refused before making it: check that reading logs is switched on, then the link the viewer followed. A rise in unreachable or in logs.duration means the log store is slow or down: check Grafana Loki. Any not_configured or refused means the reader's settings are wrong: set the key the sentence names, or check the store's address and credentials. Behind a not_configured, a refused or an unreachable, the Grafana Loki reader's SolhigsonLokiReadFailed line names the failure, unless the seam answered without a read.

The application log screen

KitAppLogList lists the application log's records of one window, newest first, one page at a time, through IKitLogs.SearchAppLogsAsync. It says when the newest record arrived, through IKitLogs.GetSourceAsync. A component cannot be given a route, so the app writes the page:

@page "/admin/logs"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("logs.view")]

<KitAppLogList DetailHref="~/admin/logs/{id}" TimeZone="@AppZone" />
Parameter Required What it does
DetailHref yes The address of a record's page: a path on this site that holds {id}. Each row's AppLogRecord.Id replaces {id}, url-encoded; the link then goes through KitHref.Local. A DetailHref without it, or one KitHref.Local refuses with an id in place, throws when the screen renders. An id holding a literal %2F is linked only when {id} is in the query, since the router would read another id from the path.
TimeZone no The viewer's zone: the days searched, the window's words and each record's time are in it. UTC when not set.
StaleAfter no How old the newest record may be before the screen says logs may have stopped arriving. 15 minutes when not set. Zero or less turns the alert off, for an app that is quiet by nature.

The app must call AddSolhigsonAdmin and register a reader (see Reading logs). The page must require a permission held only by operators, as the sample's [Permission] does: the screen's only own check is that the viewer is signed in. It passes the request's HttpContext.User. Today is the viewer's day at the instant the seam placed the window at (KitLogPage.ReadAt), so the header, the presets and the rows never disagree about it. An app's own seam that gives no instant is read by the registered TimeProvider.

The screen has these parts, in this order:

  1. The header, "Application log". Its line says the window searched, in the viewer's zone, with the zone named: "Last hour, 14:02 to 15:02 (UTC)", "Today, 22 Nov 2026 (UTC)" or "20 Nov 2026 to 22 Nov 2026 (UTC)", the second day the last one searched. Then it says when the newest record arrived: "Newest record 15:01:58", "No record in the last 24 hours" or "Newest record unknown". A newest record of another day has its date first. An hour that ends on another day than today, a since carried from an earlier day, is led by its start's date: "21 Nov 2026, 07:00 to 08:00 (UTC)". Days read as the days asked for, days after today included. The header's actions are "Last hour", "Today" and "Last 7 days": the filters in force over those windows, each ending now. The one that is the window is marked aria-current="page": "Last hour" only for an hour that ends today, and none for days after today.
  2. A Warn alert, "Logs may have stopped arriving", when the newest record is older than StaleAfter, or there is none in the last 24 hours. A newest record the seam could not read raises none: the line says it is unknown.
  3. The filters: the first day and the last day, and the severity. The severity is a select of "All" and the framework's levels (SolhigsonLokiReaderOptions.DefaultSeverityLadder), each meaning that level and above. The select shows the level in force: with none given, the framework's default, Warning, which the screen asks for by name. An app's SeverityLadder and DefaultSeverity on the reader's options are not read by the screen. Under them, "More filters" holds the request id and the user id. It is open when either holds a value.
  4. The table: when, the severity, the message and the source. "When" is the record's date over its time to the second, in the viewer's zone, in tabular figures; the column's title names the zone. An error or a critical record is a Danger pill, and a warning a Warn pill, each read ignoring case. Every other severity is muted text. The message is one line, cut at the measure or at its column's width, whichever is narrower, and links to the record's page. Its column takes the width the other columns leave. The source is the logger's last segment, such as Command for Microsoft.EntityFrameworkCore.Database.Command, with the whole name in its title. The source is hidden in a narrow table.
  5. The pager: "Next page", and "First page" only when a cursor was given.

The filters are a GET form, so a filtered list has an address a user can keep:

Filter Field Values Search
From from A day, yyyy-MM-dd FromDay
To to A day, yyyy-MM-dd, searched whole ToDay
(none) since Whole unix seconds: the end of the hour read, with no day Since
Severity severity All, Trace, Debug, Information, Warning, Error or Critical MinSeverity
Request id chain The request's id, 32 hexadecimal characters RequestId
User id user The user id a record names UserId
(none) cursor The next page's cursor Cursor

Each filter matches exactly. These are ignored, and the field shows empty:

  • A day in any other form.
  • A severity not spelled as the select spells it (error, 4); the select then shows the level in force.
  • A since that is not whole unix seconds of the calendar.
  • A request id that is not one, and a blank user id.

The form sends no cursor and no since, so a changed filter or window opens its first page over a fresh hour.

The pager and the presets keep the filters as they were given, the presets each with its own window and no cursor. With no day, the pager carries the since the seam read to, so the hour's pages never slide. Every link goes through KitHref.Local, each name and value escaped with Uri.EscapeDataString. A message is text: markup in it, a <script> included, is shown, never run.

Empty states and alerts of the application log screen

With no rows and a request id or a user id set, the screen shows "No records match these filters", with a link that clears every filter. Otherwise it shows "No records in this window", with the window and the severity searched, and the next wider window:

  • After an hour that starts today, at or after its midnight, "Today".
  • After an hour that starts earlier in the last 7 days, or days that start inside them and do not cover all of them, "Last 7 days". Days after today count as ending today.
  • After any other window, a pointer to the date fields.
Outcome What the screen shows
NotRegistered, Off "This app has no log store" in the list's place, with the outcome's Message, which names the registration or the setting that turns it on. No filters, presets or alert.
NotConfigured, Unreachable, Refused, ActorRefused, Failed A Danger alert of the outcome's Message alone, and no table, with the Warn alert beside it when the newest record is old.

The screen writes no log line; the seam's lines and instruments (see Reading logs) are above.

The application log record page

KitAppLogDetail shows one application log record, whole, through IKitLogs.GetAppLogAsync, and the first records of its request through IKitLogs.AppLogsOfRequestAsync. The app writes the page, with the record's id in its route, the address the list's DetailHref names:

@page "/admin/logs/{Id}"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("logs.view")]

<KitAppLogDetail Id="@Id" ListHref="~/admin/logs" DetailHref="~/admin/logs/{id}" ApiLogHref="~/admin/api-logs" TimeZone="@AppZone" />

@code {
    [Parameter]
    public string? Id { get; set; }
}
Parameter Required What it does
Id yes The record's id (AppLogRecord.Id), as the route gives it.
ListHref yes The application log screen's page, a path on this site: the header's "Application log" link and the not-found page's way back. A ListHref that KitHref.Local refuses throws when the page renders.
DetailHref yes The address of a record's page, as the list's: a path on this site that holds {id}, which each record of the same request replaces, url-encoded. A DetailHref without it, or one KitHref.Local refuses with an id in place, throws when the page renders.
TimeZone no The viewer's zone: the record's time and day, and the request's times. UTC when not set.
ApiLogHref no The API log list's page, a path on this site with no query or fragment of its own. With it, the request id links to "API exchanges of this request": that list over the record's day, in the viewer's zone, for that request id (from, to and chain). An ApiLogHref that KitHref.Local refuses, or one holding ? or #, throws when the page renders.
ShowPersonal no Whether the page shows the user id and the address the record names, and the further properties that name a person or their address, which are personal data. It governs those facts alone. False unless set.

The page must not use stream rendering: no @attribute [StreamRendering] on it or on a layout around it. A page that streams sends its status before the lookup returns, so a record not found is answered with 200, not 404. That page shows the header "Log record" and the empty state "Record not found", with "Application log" as its action. As on the audit record page, ASP.NET Core 10 sends a page that sets 404 with no body, for the app's status code pages.

A record can hold stack traces, ids and the values a request carried, so the page writes Cache-Control: no-cache, no-store and Pragma: no-cache before its first await, and no cache keeps it. It renders on a request alone: placed under an interactive render mode it throws.

The app must call AddSolhigsonAdmin and register a reader (see Reading logs). The page must require a permission held only by operators, as the sample's [Permission] does: the page's only own check is that the viewer is signed in. It passes the request's HttpContext.User.

The page has these parts, in this order:

  1. The header. Its title says what happened and where: the severity, then "in" the source's last segment, "Error in PaymentService"; "Log record" stands for a record with no severity, and a record with no source has the severity alone. Its line says when the record was written, in the viewer's zone, to the millisecond, with the zone named: "22 Nov 2026, 10:30:00.125 (UTC)". Then a quiet "Application log" link back to the list.
  2. The message, whole, once, in the kit's code block, no wider than the measure.
  3. The facts: the source, its whole name; the machine; and the request id, with "API exchanges of this request" when ApiLogHref is set. With ShowPersonal, the user id and the address, "User id" and "Address". Then each further property (AppLogRecord.CustomProperties), its name and its value, but a chainId that repeats the request id. A value keeps its line breaks and breaks anywhere rather than widen the page. A name or a value of white space alone reads "White space only", and an empty one "Empty", as on the audit record page. With ShowPersonal off, a muted line under the facts says how many further properties were held back as personal data, when any were.
  4. "Exception", when the record carries one: its type and message, and its stack trace in the code block.
  5. "Same request", when the record's request id is one the seam reads: a table of the request's first 50 records, oldest first. "When" is the record's date over its time to the millisecond, in tabular figures; the severity is the list's pill; the message is one line, cut, linking to its record's page. This record's row, the first of its id, is not a link: it sits on the soft ink, with a Highlight edge in forced colours, and its message is marked aria-current="true". A line says "This request has more than 50 records: the first 50 are shown." when it has more, and "This record is not among those shown." when it is not.

The seam reads a request from its start, over the UTC day of the record and the day either side, so a request with thousands of lines shows its first 50, and this record may come after them. A request id that is not 32 hexadecimal characters, which only an app's own seam or reader can answer, shows as text, with no link, and no "Same request" section: nothing is read for it. A chain id an app sets through SetCurrentLogChainId shows as the further property chainId.

The user id and the address are personal data, shown only with ShowPersonal. The framework's reader puts every label but the ones it maps into the further properties, so a person can be named there too. With ShowPersonal off, the page also hides each further property whose name, ignoring case, begins with enduser_, user_, client_, network_peer_, net_peer_, net_sock_peer_ or http_client_ip; each whose name, its underscores dropped, is or ends with userid (UserId, ActingUserId, TargetUserId); and each whose value is the record's user id or address under another name. A field of the app's own that names a person by another name and value, such as an Email in a log message's template, is shown: an app keeps such a field out of its logs where it writes them.

ShowPersonal governs the facts and the further properties only. The message, the exception, its stack and the request's messages are shown as written, whatever ShowPersonal says, and may name a person: the framework's sign-in, two-factor, reset and permission lines put a user id in their message. The page's permission is the control for those.

The kit's code block (class kit-code) holds every stored text a page shows whole: a log record's message, an exception's stack trace and an audit payload as stored. It is mono text on the surface in a hairline frame, its lines kept and broken anywhere, so a long unbroken line never widens the page on a phone, and it scrolls inside itself. A log record's message and an exception's stack are no taller than the component token --kit-code-height, the measure unless the app sets it; an audit payload keeps the token it shipped with, --kit-audit-raw-height. It is a region named for what it holds, reached by keyboard (tabindex="0").

Nothing in a record is ever markup: the message, each property's name and value, the exception and its stack are written as text, encoded, so a <script> or a url in them is shown, never run or linked. The only links are the list's, the API log list's and the records' of the request, each built through KitHref.Local, each value escaped with Uri.EscapeDataString.

Outcome What the page shows Status
Done The record. A Done answer with no record, which only an app's own seam can give, shows the Failed sentence. 200
NotFound The header "Log record" and the empty state "Record not found", which says log stores keep records for a limited time, with "Application log" as its action. 404, when the response has not started
NotRegistered, Off "This app has no log store", with the outcome's Message, under the header "Log record" and its "Application log" link. 200
NotConfigured, Unreachable, Refused, ActorRefused, Failed A Danger alert of the outcome's Message alone, under the header "Log record" and its "Application log" link. 200

A read of the request's records that is not Done shows its state as the list does, in the section's place, under the record. The page writes no log line; the seam's lines and instruments (see Reading logs) are above.

The API log screen

KitApiLogList lists the API exchanges of one window, newest first, one page at a time, through IKitLogs.SearchApiLogsAsync. It says when the newest exchange arrived, through IKitLogs.GetSourceAsync. A component cannot be given a route, so the app writes the page:

@page "/admin/api-logs"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("logs.view")]

<KitApiLogList DetailHref="~/admin/api-logs/{id}" TimeZone="@AppZone" />
Parameter Required What it does
DetailHref yes The address of an exchange's page: a path on this site that holds {id}. Each row's ApiLogRecord.Id replaces {id}, url-encoded; the link then goes through KitHref.Local. A DetailHref without it, or one KitHref.Local refuses with an id in place, throws when the screen renders. An id holding a literal %2F is linked only when {id} is in the query, since the router would read another id from the path.
TimeZone no The viewer's zone: the days searched, the window's words and each exchange's time are in it. UTC when not set.
StaleAfter no How old the newest exchange may be before the screen says logs may have stopped arriving. Zero, off, when not set. An app that calls nothing for a while is healthy, so set it only for one whose traffic never stops.

The app must call AddSolhigsonAdmin, register an API exchange reader and export its exchanges (see Reading logs). The page must require a permission held only by operators, as the sample's [Permission] does: the screen's only own check is that the viewer is signed in. It passes the request's HttpContext.User. Today is the viewer's day at the instant the seam placed the window at, as on the application log screen.

The screen has these parts, in this order:

  1. The header, "API log". Its line is the application log screen's: the window searched, in the viewer's zone, with the zone named, then when the newest exchange arrived. Its actions are the same "Last hour", "Today" and "Last 7 days".
  2. The application log screen's Warn alert, "Logs may have stopped arriving", only when StaleAfter is set.
  3. The filters: the first day and the last day, the method and the status code. The method is a select of "Any" and GET, HEAD, POST, PUT, DELETE, OPTIONS or PATCH. The status code is 0, or a number from 100 to 599, matched exactly; 0 is an exchange that got no response. Any other value is ignored: the list is unfiltered, and the field shows empty. Under them, "More filters" holds the service, the part of the path and the request id. It is open when one holds a value.
  4. The table: when, the request, the status, the duration and the service. "When" is the exchange's date over its time to the second, in the viewer's zone, in tabular figures; the column's title names the zone. The request is the method, in the sans face at weight 600, then the path, which is masked and holds no query. It is one line, cut as the application log's message is, and links to the exchange's page. A status of 500 or above is a Danger pill, and so is 0, which reads "No response". A status of 400 to 499 is a Warn pill. Every other status is muted text, as the application log's quiet severities are. The duration's title is "Duration (ms)", and each cell holds the whole number of milliseconds alone, grouped, at the column's end in tabular figures; a duration that is not a number is an empty cell. The duration and the service are hidden in a narrow table.
  5. The pager: "Next page", and "First page" only when a cursor was given.

A list row shows no body, no header and no query: those are on the exchange's page alone.

The filters are a GET form, so a filtered list has an address a user can keep:

Filter Field Values Search
From from A day, yyyy-MM-dd FromDay
To to A day, yyyy-MM-dd, searched whole ToDay
(none) since Whole unix seconds: the end of the hour read, with no day Since
Method method GET, HEAD, POST, PUT, DELETE, OPTIONS or PATCH Method
Status code status 0, or 100 to 599, in ASCII digits StatusCode
Service service The service's name, typed, matched exactly Service
Path contains path Any part of the path, ignoring case PathContains
Request id chain The request's id, 32 hexadecimal characters RequestId
(none) cursor The next page's cursor Cursor

There is no filter by a class of status, such as every 5xx. These are ignored, and the field shows empty:

  • A day in any other form, and a since that is not whole unix seconds of the calendar.
  • A method not spelled as the select spells it (get, PROPFIND); the select then shows "Any".
  • A status that is not one to three ASCII digits naming 0 or 100 to 599 (+404, 0404, 600).
  • A blank service or path, and a request id that is not one.

The form sends no cursor and no since, so a changed filter or window opens its first page over a fresh hour. The path filter travels in the address, so the app's access log holds what was typed into it.

The pager and the presets keep the filters as they were given, the presets each with its own window and no cursor. With no day, the pager carries the since the seam read to. Every link goes through KitHref.Local, each name and value escaped with Uri.EscapeDataString. A path is text: markup in it, a <script> included, is shown, never run.

Empty states and alerts of the API log screen

With no rows and a service, a path or a request id set, the screen shows "No records match these filters", with a link that clears every filter. Otherwise it shows "No records in this window", with the window, and the method and the status code when set, and the application log screen's next wider window.

Outcome What the screen shows
Off, the host's API exchange export off "This app does not export API exchanges" in the list's place, with the outcome's Message, which names the setting Solhigson:Logs:ApiLogsToLokiEnabled. No filters, presets or alert.
NotRegistered, Off, reading off "This app has no log store" in the list's place, with the outcome's Message, which names the registration or the setting that turns it on. No filters, presets or alert.
NotConfigured, Unreachable, Refused, ActorRefused, Failed A Danger alert of the outcome's Message alone, and no table.

The screen writes no log line; the seam's lines and instruments (see Reading logs) are above.

The API exchange page

KitApiLogDetail shows one API exchange, whole, through IKitLogs.GetApiLogAsync: the record as exported, with its request and response headers read from their stored JSON. The app writes the page, with the exchange's id in its route, the address the list's DetailHref names:

@page "/admin/api-logs/{Id}"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("logs.view")]

<KitApiLogDetail Id="@Id" ListHref="~/admin/api-logs" AppLogHref="~/admin/logs" TimeZone="@AppZone" />

@code {
    [Parameter]
    public string? Id { get; set; }
}
Parameter Required What it does
Id yes The exchange's id (ApiLogRecord.Id), as the route gives it.
ListHref yes The API log screen's page, a path on this site: the header's "API log" link and the not-found page's way back. A ListHref that KitHref.Local refuses throws when the page renders.
TimeZone no The viewer's zone: the exchange's time and day. UTC when not set.
AppLogHref no The application log list's page, a path on this site with no query or fragment of its own. With it, the request id links to "Application log of this request": that list over the exchange's day, in the viewer's zone, for that request id (from, to and chain). An AppLogHref that KitHref.Local refuses, or one holding ? or #, throws when the page renders.

The page must not use stream rendering: no @attribute [StreamRendering] on it or on a layout around it. A page that streams sends its status before the lookup returns, so an exchange not found is answered with 200, not 404. That page shows the header "API exchange" and the empty state "Record not found", with "API log" as its action. As on the application log record page, ASP.NET Core 10 sends a page that sets 404 with no body, for the app's status code pages.

An exchange can hold what a request carried, its bodies and its headers, so the page writes Cache-Control: no-cache, no-store and Pragma: no-cache before its first await, and no cache keeps it. It renders on a request alone: placed under an interactive render mode it throws.

The app must call AddSolhigsonAdmin, register an API exchange reader and export its exchanges (see Reading logs). The page must require a permission held only by operators, as the sample's [Permission] does: the page's only own check is that the viewer is signed in. It passes the request's HttpContext.User.

The page has these parts, in this order:

  1. The header. Its title is what was called: the method, then the path, whole, "POST /api/orders/{id}"; an inbound exchange records its route. A path with no method stands alone, and an exchange with no path, or one of white space alone, reads "No path recorded". The title wraps, a long unbroken path breaking anywhere rather than widen the page on a phone, and is never cut. Its line gives the status as the list's pill or muted code, when the exchange happened, in the viewer's zone, to the millisecond, with the zone named, how long it took, "120 ms", when that is a number, then a quiet "API log" link back to the list. The line is a row that wraps, its parts a step apart, as on the application log record page.
  2. The facts: the service, the host and the direction; the status with its words, "404 Not Found"; the duration; the path and its query, whole, as text, in the mono face; the request id, with "Application log of this request" when AppLogHref is set; and, when the exchange recorded an exception, its type and message, "Exception" and "Exception message". A value the exchange does not hold reads "Not set". An exchange has no caller address, so the page shows none. Its request headers are shown as exported, though, so a caller's address or identity can appear under a header the masker's floor does not name, such as X-Client-IP (the floor names X-Forwarded-For and its common kin): an app adds such a header to ApiTraceMaskOptions.ProtectedFields.
  3. A muted line: "Bodies and headers are shown as exported, with protected values already removed."
  4. "Request": its headers, a list of each name and its value in the stored order, or "Headers shown as stored" and the text in the kit's code block when what is stored is not a JSON object, or "No headers". Then its body, as stored, in the code block: JSON is not reformatted. An absent or empty body reads "No body". A header's name or value, or a body, of white space alone reads "White space only", and an empty name or value "Empty", as on the audit record page. A body cut at capture, which the framework does past ApiTraceMaskOptions.MaxBodyBytes, is under "This body was cut at capture: only its start was exported."
  5. "Response", the same. An exchange that got no response (status 0), with no response header and no response body stored, shows "No response" in their place.

A status's words come from one fixed table, ASP.NET Core's reason phrases (ReasonPhrases.GetReasonPhrase), the phrases it sends itself. A code the table has no phrase for, such as 299 or 599, shows as its number alone; 0 reads "No response". The exchange's own StatusDescription, an enum's name such as InternalServerError, is not shown.

The page unmasks nothing. The framework masks an exchange before it is exported (ApiTraceMasker, by ApiTraceMaskOptions): a protected header, query value or body field reads as the masker wrote it, ******, and a body it cannot mask is replaced whole. The page shows what the store holds. The end user's id (ApiLogRecord.EndUserId) is personal data, and the page has no parameter that shows it, so it is not shown; the request id links to the application log, whose record page shows it under its own ShowPersonal. The bodies, the query and the exception's message are shown as exported and may name a person: the page's permission is the control for those.

The link to the application log carries the exchange's day in the viewer's zone, taken from the time the exchange was recorded, at its response. A request that crosses midnight in that zone has lines on the day before, which the list's wider window shows.

Nothing in an exchange is ever markup: the title, the path, the query, each header's name and value, the bodies and the exception are written as text, encoded, so a <script> or a url in them is shown, never run or linked. The only links are the list's and the application log's, each built through KitHref.Local, each value escaped with Uri.EscapeDataString. A request id that is not 32 hexadecimal characters, which only an app's own seam or reader can answer, shows as text, with no link.

Outcome What the page shows Status
Done The exchange. A Done answer with no exchange, which only an app's own seam can give, shows the Failed sentence. 200
NotFound The header "API exchange" and the empty state "Record not found", which says log stores keep records for a limited time, with "API log" as its action. 404, when the response has not started
Off, the host's API exchange export off "This app does not export API exchanges", with the outcome's Message, which names the setting Solhigson:Logs:ApiLogsToLokiEnabled, under the header "API exchange" and its "API log" link. 200
NotRegistered, Off, reading off "This app has no log store", with the outcome's Message, under the header "API exchange" and its "API log" link. 200
NotConfigured, Unreachable, Refused, ActorRefused, Failed A Danger alert of the outcome's Message alone, under the header "API exchange" and its "API log" link. 200

The page writes no log line; the seam's lines and instruments (see Reading logs) are above.

Users

IKitUsers (Solhigson.Admin.Users) is the one seam through which the user screens read and change users. A screen injects this one type, whatever the app's user and key types. AddSolhigsonAdmin registers it, scoped, over the framework's UserAdministration that AddSolhigsonIdentityManager registers with the same type arguments:

  • AddSolhigsonAdmin<TUser, TContext>() (string keys) closes it over SolhigsonAspNetRole and string.
  • AddSolhigsonAdmin<TUser, TKey, TContext>() closes it over SolhigsonAspNetRole<TKey> and TKey.

A seam the app registered first is kept. The framework decides every reach; the seam adds no rule and hides no outcome. The app must register its IUserAdministrationRules<TUser, TKey>, else every call answers NoRules.

Member Answers What it reads
SearchAsync(principal, search, ct) KitUserPage (Rows, NextCursor, Outcome, Message) The framework's search. Every member of KitUserSearch (Text, Role, Enabled, LockedOut, TwoFactorEnabled, NotSignedInSince, HasPassword, Cursor, PageSize) is passed on as it is.
GetAsync(principal, userId, ct) KitUserLookup (Row, Outcome, Message) The framework's CanAdministerAsync. The row is the user it reached, as stored, with no second read; an edit the request has not saved does not show. The app's DisplayName is given a copy that no context tracks, with the password hash and stamps null, so a write to it is never saved. The roles are read from the database for the call, never a cache. One more read, the last, answers EmailShared (see Rows); a blank email skips it.
GrantableRolesAsync(principal, ct) KitRoleNames (Names, Outcome, Message) The framework's GrantableRolesAsync: the roles the acting user may grant.
RoleNamesAsync(ct) KitRoleNames Every stored role's name, ordered.
SetEnabledAsync(principal, userId, enabled, ct) KitUserResult (Outcome, Message, UserId, EndSessions, NeedsPasswordLink) The framework's SetEnabledAsync, which checks reach, refuses the acting user's own account (NotOwn) and answers Unchanged when the user already is as asked. A disable rotates the security stamp and answers EndSessions; so does a disable answered Unchanged. An enable answers NeedsPasswordLink when the user has no password. The seam passes these on and acts on neither: the caller ends the sessions and asks for the link.
UnlockAsync(principal, userId, ct) KitUserResult (Outcome, Message, UserId) The framework's UnlockAsync on the user's id, which checks reach, refuses the acting user's own account (NotOwn) and acts on the row it loaded, never on a user looked up again by name. A user not locked out answers Unchanged. A lockout by wrong authenticator codes is Identity's lockout end, so it ends too, and the code counters are cleared where two-factor is registered. The seam writes no audit row: the caller does.
ResetTwoFactorAsync(principal, userId, ct) KitUserResult (Outcome, Message, UserId, EndSessions, HadPassword, TwoFactor) The framework's CanAdministerAsync on the user's id first. The seam then loads the acting user by the principal's id: one that no longer loads answers ActorRefused, and one whose stored key is the reached user's answers NotOwn, whatever form the id takes (a braced Guid, say). The user it reached, never one looked up again, then goes to the two-factor manager's ResetAsync with the acting user's id as Identity writes it. The manager refuses the acting user's own account again (NotOwn) and a user not enrolled (NotEnrolled); otherwise it removes the authenticator, the password and any lockout end, rotates the security stamp and answers EndSessions and HadPassword. TwoFactor holds the manager's outcome and Message its sentence; a reach refusal leaves TwoFactor null. A host with no two-factor answers Failed before any read. The seam writes no audit row, ends no session and sends no notice: the caller does.
SetRolesAsync(principal, userId, roles, loadedRoles, ct) KitUserResult (Outcome, Message, UserId, EndSessions, Granted, Revoked, Disabled, Stale) The framework's CanAdministerAsync on the user's id first, then the acting user loaded, as for ResetTwoFactorAsync (ActorRefused, NotOwn by the stored keys). The seam then reads the user's roles from the database and compares them with loadedRoles, the roles the page was rendered with. It compares sets of names normalized as Identity normalizes a role's name (RoleManager.NormalizeKey, upper case by default), so case, order and repeats do not count; Identity and the framework take names that differ only by case as one role. When the sets differ, the answer is Stale with Unchanged, the user's id, and nothing written. Otherwise the framework's SetRolesAsync decides (see Changing a user's roles). Done carries the names granted and revoked, Disabled and EndSessions. The comparison is a read before the write, not a lock: a change between the two is the framework's own crossing-write refusal, IdentityFailed. The seam writes no audit row, ends no session and sends no notice: the caller does.
ChangeEmailAsync(principal, userId, newEmail, ct) KitUserResult (Outcome, Message, UserId, EndSessions, PreviousEmail) The framework's ChangeEmailAsync, which decides everything (see Changing a user's email): EmailChangeOff unless the app turned the change on, then the reach and the acting user's own account (NotOwn) by the stored keys, then RoleOutOfReach when the user holds a role the acting user may not grant, then InvalidEmail, Unchanged for the address held, and EmailInUse. Done carries EndSessions and the address it replaced as PreviousEmail; the new address starts unconfirmed. RoleOutOfReach here has its own sentence, about the roles the user holds. Neither address goes in a log line. The seam writes no audit row, ends no session and sends no notice: the caller does.
CreateAsync(principal, newUser, ct) KitUserResult (Outcome, Message, UserId, NeedsPasswordLink, Granted, Disabled, BuildRefused) The app's IKitUserFactory<TUser>, else the package's default, builds the user from KitNewUser (Email, Phone, Roles, Form; see Building the new user). A refusal of the factory's answers Failed with BuildRefused and its sentence, nothing written. A string id the build left null or empty is a new sequential Guid. The seam reads the stored names of the roles asked for, at step Roles, before anything is written. The framework's CreateAsync then decides everything (see The new-user screen): NoRules, ActorRefused, EmptyRoleSet, RoleNotFound, RoleOutOfReach, RoleSetRefused, InvalidEmail, EmailInUse, NotFound for a new user outside the acting user's reach, which it rolls back and which has its own sentence, IdentityFailed and Failed. Done carries the new id, NeedsPasswordLink, the roles asked for as Granted (each once, under its stored name, so "CLERK" is recorded as "Clerk") and Disabled when the framework started the user disabled. Neither the address nor the phone goes in a log line. The seam writes no audit row and sends no link: the caller does.
TwoFactorAvailable bool True when the framework's two-factor manager of the same closure resolves, that is, when the app called AddSolhigsonTwoFactor.
SignInNeedsConfirmedEmail bool True when an unconfirmed address keeps a user from signing in, as Identity's SignInManager decides it: SignIn.RequireConfirmedEmail is on, or SignIn.RequireConfirmedAccount is on and the app's IUserConfirmation answers by Identity's own DefaultUserConfirmation rule, which confirms an account by its address. A subclass that keeps that rule counts. A confirmation that overrides Identity's rule, or an app's own, does not count. A confirmation that throws as it resolves counts, with one Error.

The acting user

The acting user is read on the server from the principal, never from a value a page binds. Its id is the first claim of Identity's own ClaimsIdentity.UserIdClaimType, the claim UserManager.GetUserId(principal) reads. The claim counts only when the identity that holds it is signed in. A principal can hold several identities, and one signed-in identity does not vouch for an id another carries. A principal that names no acting user so answers ActorRefused and reads nothing. A screen passes the request's HttpContext.User.

Rows

A KitUserRow holds:

  • Id, as UserManager.GetUserIdAsync gives it.
  • DisplayName: the rules' DisplayName, else the email.
  • Email, EmailConfirmed and UserName.
  • EmailShared: true when another user holds the email as the framework's reset request finds an address (RequestPasswordResetAsync): another user's NormalizedEmail is the email normalized by UserManager.NormalizeEmail, whatever that user's state, a disabled one included. The other user is any stored user, one outside the viewer's reach included; the row names neither it nor its reach. The reset request a user asks for then sends a link to neither account. The user page's "Send password link" still reaches the address with the package's default notices, or an app's own that issues the link by id (IssuePasswordResetAsync). A blank email is never shared, so two users with no email share nothing. Only GetAsync reads it, in one query; SearchAsync never does, so it is false on every list row.
  • Roles, ordered.
  • Enabled, TwoFactorEnabled and HasPassword.
  • LockedOutUntil: set only when lockout is on for the account and its end is after now. The clock is the registered TimeProvider, the one the framework reads.
  • LastSignIn: read as UTC.
  • IsViewer: true when the acting user's loaded key equals the row's. The keys are compared, never the ids' text.

A row holds no password hash, stamp or token. Email, UserName and DisplayName are [PersonalData]. A row's text (ToString) is its id.

Outcomes and sentences

Every answer carries the framework's UserAdministrationOutcome and a Message for the operator. KitUserMessages.For(outcome) gives one sentence for each user-administration outcome, and KitUserMessages.For(TwoFactorOutcome) one for each two-factor outcome. Show Message as it is. These outcomes matter to a reading screen:

Outcome Meaning Sentence
Done The read was made. Done.
NotFound The user is missing, or out of the acting user's reach. Both share one sentence, so an id cannot be probed. User not found.
NoRules The app registers no IUserAdministrationRules for its user and key types. Never shown as an empty list. Names the registration to add.
ActorRefused The principal names no acting user, or the framework refused it (missing or disabled). Says the account may not administer users.
Failed A step threw. A fixed sentence; the app's log holds an Error naming the step.

A write adds these outcomes:

Outcome Meaning Sentence
Unchanged The user already was as asked, such as a disable another administrator made first. Nothing was written. Nothing changed: the user was already as asked.
NotOwn The user is the acting user's own account. Says the account may not change itself.
IdentityFailed Identity refused the write. Asks the operator to reload and try again.

An email change adds EmailChangeOff, InvalidEmail, EmailInUse and RoleOutOfReach, each with its own sentence. RoleSetRefused shows the app's own reason, when the app gives one. A role change from a page whose roles changed since it was rendered answers Stale true with Unchanged, and its sentence asks the operator to reload. A create adds EmptyRoleSet, RoleNotFound, RoleOutOfReach, RoleSetRefused, InvalidEmail and EmailInUse; a refusal of the user factory's answers Failed with BuildRefused true and the factory's own sentence. KitUserResult (Outcome, Message, UserId, EndSessions, NeedsPasswordLink, Granted, Revoked, Disabled, PreviousEmail, HadPassword, Stale, TwoFactor, BuildRefused) is what each later write of the seam answers.

A two-factor reset reads the manager's outcome as one of these:

TwoFactor Outcome
Reset Done
NotEnrolled, TwoFactorOff Unchanged
NotOwn NotOwn
Any other Failed

Nothing throws except the caller's cancellation.

Auditing

KitUserAudit holds the audit vocabulary for the user screens. The entity type is User and the entity id is the user's id. The actions are users.enabled, users.disabled, users.unlocked, users.password-link-sent, users.two-factor-reset, users.roles-changed, users.email-changed and users.created. Each is recorded as a SecurityEvent through IKitAudit (see Recording changes). A payload holds no personal value but one: users.email-changed holds the address the change replaced, never the new one, since recovering a taken account needs it.

Log lines

The seam writes these lines under Solhigson.Admin.Users.KitUsers. A line carries ids only, never an email, a name or an exception's message. An id is percent-encoded, so a line break in it forges no line, and cut to 64 characters with a ... marker.

Line Level Text What to do
KitUsersNoActor Warning The users seam refused {Method}: the principal carries no {ClaimType} claim on a signed-in identity, so it names no acting user; nothing was read. Check that the page requires a signed-in user. If the user is signed in, check that the signed-in identity carries the claim ClaimType names, or set IdentityOptions.ClaimsIdentity.UserIdClaimType to the claim it does carry.
KitUsersFailed Error The users seam {Method} failed at step {Step}: {ExceptionType}; actor [{ActingUserId}], target [{TargetUserId}]. Read the step. Row means the app's DisplayName threw for the user the target names; Read means the role table could not be read; Resolve means the two-factor manager could not be built, so TwoFactorAvailable answers false, or, for reset_two_factor, the app called no AddSolhigsonTwoFactor, or, for sign_in_needs_confirmed_email, the app's IUserConfirmation could not be built, so SignInNeedsConfirmedEmail answers true; Actor means the acting user could not be read again after the reach; Build means the app's IKitUserFactory threw or answered no build for create; Reset means the two-factor manager's reset threw, such as for a user store that is not Identity's EF UserStore with AutoSaveChanges on; ActingId means the principal could not be read. EmailShared means the read of whether another user holds the user's email failed. Other steps (Roles, Password, Viewer) are Identity's reads; check the store.

A fault inside the framework's own call (step Call) is answered Failed by the framework, which writes its own Error under UserAdministration. The seam writes no second line for it.

The framework's lines and counters

Each call the seam makes into the framework writes the framework's own lines, by ids only, never an email, a name or a role's name. Under UserAdministration (UserAdministrationDiagnostics.LoggerCategory) it writes:

  • A Warning for a user not found within reach, a refused actor, the acting user's own account, a write Identity refused, a role the acting user may not grant, an address in use, and an unlock whose two-factor code counters were not all cleared.
  • An Error for NoRules, a step that threw, a user store it cannot rely on, and a create or a role change refused for unsaved changes of the app's own in the context, or for rows it wrote beyond what was asked.
  • An Information line for each write done.

A search, a lookup or a list of grantable roles that is answered writes no line.

A two-factor reset writes its lines under Solhigson.Framework.Identity.TwoFactor (TwoFactorDiagnostics.LoggerCategory): an Information line for a reset that landed; a Warning for a self-reset refused, a write Identity refused, a reset answered failed whose commit may have landed, and a reset read back as landed after another request saved the account; and an Error for a step that threw. Clearing the user's code counters once a reset has landed writes its Warnings under Solhigson.Framework.Identity (SignInDiagnostics.LoggerCategory), with the sign-in's lines. The XML documentation of UserAdministrationDiagnostics and TwoFactorDiagnostics lists every line.

Each call also adds one to a counter on the meter Solhigson.Framework.Identity, which the app adds to its metrics pipeline (AddMeter("Solhigson.Framework.Identity")). The package's own lines add to no counter.

Counter Tags What to watch
user_administration method: the framework's method, such as search, can_administer (the user page's lookup, the audit record page's reach check, and the reach of a role change and of a two-factor reset), resolve_display_names (the audit screens' name lookup), grantable_roles, set_enabled, unlock, set_roles, change_email or create. outcome: the answer, such as done, unchanged, not_found, actor_refused, no_rules, identity_failed, failed or cancelled. failed, no_rules or identity_failed: read the framework's line under UserAdministration. A rise in not_found or actor_refused: ids out of reach, or accounts that may not administer, are being tried.
two_factor method: reset for the user page's reset. outcome: such as reset, not_enrolled, not_own or failed. failed: read the framework's Error under Solhigson.Framework.Identity.TwoFactor.

Account

IKitAccount (Solhigson.Admin.Account) is the one seam through which the account pages sign a user in and out. A page injects this one type, whatever the app's user and key types. AddSolhigsonAdmin registers it, scoped, over the framework's identity manager that AddSolhigsonIdentityManager registers with the same type arguments, and over its two-factor manager when the app calls AddSolhigsonTwoFactor:

  • AddSolhigsonAdmin<TUser, TContext>() (string keys) closes it over SolhigsonIdentityManager<TUser, TContext>, SolhigsonAspNetRole and string.
  • AddSolhigsonAdmin<TUser, TKey, TContext>() closes it over SolhigsonIdentityManager<TUser, TKey, TContext>, SolhigsonAspNetRole<TKey> and TKey.

A seam the app registered first is kept. The framework decides every sign-in; the seam adds no rule.

Member Answers What it does
SignInAsync(userName, password, ct) KitSignInResult The framework's password step, with lockout on. A null name or password is passed on as empty, so it is refused as a wrong one is.
TwoFactorSignInAsync(code, pendingUserId, ct) KitSignInResult The framework's code step, for the device that passed the password step. A host with no two-factor answers TwoFactorTimedOut before any read, and writes no line, since anyone can post to the code step.
SignOutAsync(ct) bool Signs this device out. The account and its security stamp are left as they are, so no other session ends. To end every session of a user, use the sessions seam. Then records account.signed-out for the user the request names (see Auditing sign-ins). False, with one Error and no row, when the sign-out threw.
CurrentAsync(principal, ct) KitAccountView or null The signed-in user, read by the users seam's rule (see The acting user). Null for a principal that is not signed in, for an id no user has, and for a disabled user. Null, with one Error, when the read threw.
RequestPasswordResetAsync(email, ct) KitPasswordResetAnswer The framework's reset request for the address typed. When the framework answers Send, the seam builds the reset link, mails it through the app's IKitAccountMail and records account.reset-requested (see The reset link and the account mail). InvalidEmail for an address that is not one; Requested for every other outcome, so a page cannot tell them apart. It returns no sooner than 700 ms after it was called.
ResetPasswordAsync(userId, token, newPassword, ct) KitPasswordSetResult The framework's password reset from a link, with the id and the token the link carried. When the framework sets the password (Done), or may have set it (Unconfirmed), the seam ends the user's sessions through the app's IKitSessions, records account.password-reset and tells the owner through IKitAccountMail.NotifyAsync (see The reset-password page). It signs no one in. A null id, token or password is passed on as empty, so it is refused as a wrong one is.
ChangePasswordAsync(principal, currentPassword, newPassword, ct) KitPasswordSetResult The framework's password change for the user principal names, read by the same rule as CurrentAsync, never an id a page gives. The seam reads the user through the request's user manager and stages nothing in the request's context before the framework's call. The framework proves the current password with lockout on, and, done, keeps this device signed in. When it changes the password (Done), or may have (Unconfirmed), the seam records account.password-changed and tells the owner through IKitAccountMail.NotifyAsync; IKitSessions is not called (see The change-password page). Failed, with no line, for a principal that is not signed in or an id no user has. A null password is passed on as empty.
BeginEnrolmentAsync(principal, password, ct) KitEnrolmentResult Once the framework's CheckPasswordAsync proves password the user's current one, the framework's BeginEnrolmentAsync for the user principal names, read by the same rule as CurrentAsync: a new authenticator key stored, and Done carrying it (SharedSecret) and the address an app scans (AuthenticatorUriSecret). It rotates the security stamp, so the seam then refreshes this device's sign-in (SignInManager.RefreshSignInAsync), which keeps this device signed in (see The two-factor page).
CurrentEnrolmentAsync(principal, ct) KitEnrolmentResult The framework's CurrentEnrolmentAsync, read whether a key is pending, never the key: Pending, its SharedSecret and AuthenticatorUriSecret empty, or NoKey when none was begun. It changes nothing and asks no password, so it shows no key: a session alone, a stolen one among them, must not copy it.
ShowEnrolmentAsync(principal, password, ct) KitEnrolmentResult Once password is proved, as for the begin, with the same answers when it is not, the framework's CurrentEnrolmentAsync: the pending key, not reset, as Done carrying it and its address, or NoKey when none was begun. It changes nothing of two-factor. Only a right password whose stored hash Identity rehashes rotates the security stamp, and the seam then refreshes this device's sign-in, as for the begin.
CompleteEnrolmentAsync(principal, password, code, ct) KitEnrolmentResult Once password is proved, as for the begin, the framework's CompleteEnrolmentAsync with the code as typed: Done turns two-factor on, then the seam refreshes this device's sign-in, as for the begin, and records account.two-factor-enrolled. CodeNotValid changes nothing and keeps the key.
DisableTwoFactorAsync(principal, code, ct) KitTwoFactorOffResult The framework's DisableAsync with the code as typed, never the password: Disabled turns two-factor off, then the seam refreshes this device's sign-in, records account.two-factor-disabled and tells the owner. A wrong code counts toward the account's lockout. When the framework sets EndSessions, the result carries it and the seam ends the user's sessions through the app's IKitSessions (see Turning two-factor off).

Each enrolment call answers NotSignedIn, with no line, for a principal that is not signed in, an id no user has and a disabled user; NotAvailable on a host with no AddSolhigsonTwoFactor or with it switched off; AlreadyEnrolled, NeedsRootRing, NoKey and CodeNotValid as the framework answers them; and Failed, with one KitAccountFailed Error, when a step threw. The begin, the show and the complete first prove the password, by the check a password change makes, so a session alone, a stolen one among them, cannot add a device or copy the key: a wrong one answers WrongPassword and counts toward lockout on Identity's own counter, the one sign-in uses, and a blank one answers WrongPassword uncounted, as a password change's does; LockedOut for an account locked by this check or before it, the check that locks it recording account.locked-out at step two-factor-on, a show's as a begin's, since both are steps of turning two-factor on; SignInAgain for an account with no password. None of them changes the key, the stamp or two-factor. A right password whose stored hash Identity rehashes rotates the stamp, so the seam refreshes this device's sign-in after every call that proved it, whatever the call answered. A check the framework could not make answers Failed, its Error the framework's password line, method check. KitEnrolmentResult.ToString() gives the outcome alone, so a log line that writes a result writes no key. AuthenticatorUriSecret is [PersonalData].

A page passes the request's HttpContext.User to CurrentAsync.

The sign-in result

KitSignInResult holds Outcome, PendingUserId, Next and Message.

  • Outcome is a KitSignInOutcome. It has each of the framework's SignInOutcome values, by the same name and number, and Failed for a call that threw.

  • PendingUserId is set only when Next is Code. The sign-in page carries it to the code page in the query field PendingUserId (KitSignInResult.PendingUserIdQueryName), and the code page passes it to TwoFactorSignInAsync with the code. It is no secret and no claim. The code step signs in only the account that Identity's two-factor cookie names, and only when that account's id is ordinally the id given; any other id answers TwoFactorTimedOut. So the id is never the basis of a sign-in by itself.

  • A right password for a user with Identity's two-factor on, on a host that called no AddSolhigsonTwoFactor, needs a code no step can check. The seam signs this device out, so it keeps no two-factor cookie, and the password step answers Failed, with one Error at the step Resolve. A sign-out that throws writes one more Error, at the step SignOut, and the answer stays Failed.

  • Next says where the user goes next. The seam checks in this order:

    1. Code: a two-factor code is needed.
    2. ChangePassword: the user's RequirePasswordChange is set.
    3. Enrol: the two-factor manager's RequiresEnrolmentAsync is true. If that read throws, the answer is Enrol, so a required enrolment is never skipped.
    4. Done: none of these.

    Every refusal and every fault answers None, so a page that checks for Done never lets a refused attempt through. A seam never answers Succeeded without a step (Done, ChangePassword or Enrol), nor RequiresTwoFactor without Code and the pending id. An app that registers its own IKitAccount keeps these pairs: the account pages send no one on for any other pair and say sign-in is unavailable, while the cookie that seam set stands.

  • Message is KitAccountMessages.For(Outcome). Show it as it is.

The result tells no disabled, locked or unknown account apart from a wrong password. Each of these gets the same sentence, the same Next and no pending id. The log lines do the same.

Outcome Sentence
Succeeded Signed in.
RequiresTwoFactor Enter the code your authenticator app shows.
Rejected, Disabled, LockedOut, AuthenticatorUnreadable, TooManyCodeAttempts Sign-in was refused. Check what you typed and try again, or ask an administrator for help.
TwoFactorTimedOut This sign-in has expired. Sign in again with your password.
CodeCapUnavailable, Failed Sign-in is unavailable for a moment. Try again shortly.

A name no user has is refused as Rejected. A value no outcome has, such as one a newer framework adds, reads as Failed.

After a sign-in

Once the framework signs the user in, the sign-in stands. The seam then does three things, and catches each on its own:

  1. It records the audit row.
  2. It writes the user's last sign-in time through the framework's UpdateLastLoginTimeAsync. The framework puts back a write that throws or that Identity refuses, owned values included, so a later save in the same request writes nothing of it. A refused write is the framework's one Error, not the seam's. The row comes first, so no fault of the time write can cost the record of the sign-in.
  3. It reads the next step.

A fault in any of them writes one Error naming the step and the user's id. The outcome stays Succeeded. These steps do not read the caller's token, so the caller's cancellation after the sign-in abandons none of them. The caller's cancellation before the framework answers is thrown on to the caller.

The account view

KitAccountView holds:

  • UserId, as UserManager.GetUserIdAsync gives it. The view's text (ToString) is its id.
  • DisplayName, by the users seam's rule, the same code the users page reads. The app's IUserAdministrationRules.DisplayName is given an untracked copy of the stored user, its credential columns null. A blank answer, or no rules registered, shows the user's email. A name the rules throw for fails the read: the view is null, with one Error at the step DisplayName.
  • HasPassword, TwoFactorEnabled and MustChangePassword (the user's RequirePasswordChange).
  • TwoFactorAvailable: true when the two-factor manager of the same closure resolves.
  • CanEnrol: the two-factor manager's CanEnrol. It is true when two-factor is available and switched on, the user is not enrolled, and a key can be stored. Storing a key needs a root key ring (IRootEncryptor) and the framework's root-encrypting user store. A switch that throws gives false, with one Error at the step CanEnrol.
  • MustEnrol: true when two-factor is available and the manager's RequiresEnrolmentAsync is true, or when that read threw.

Return addresses

KitReturnUrl.Safe(value, pathBase, fallback) answers what KitHref.Local(value, pathBase) gives for value, else fallback. A page passes every return address through it before it redirects. So //host, /\host, https:host, /%2F%2Fhost and every other shape that KitHref.Local refuses go to the fallback, and a ~/ path is joined to the path base.

Options

KitAccountOptions holds what the account pages need from the app:

Option Default Meaning
Brand Admin The app's name, shown above the account pages' form.
HomePath ~/ Where a signed-in user goes when no return address is safe, and where a viewer already signed in is sent.
PublicOrigin null The origin an emailed link starts with, such as https://admin.example.com. It is never read from a request's Host header.
SignInPath ~/account/sign-in The sign-in page.
CodePath ~/account/code The page that asks for the code.
ChangePasswordPath ~/account/change-password The change-password page, where the sign-in page and the shell's gate send a user whose password must change (see The change-password page). Null when the app has no such page: then no page sends a user there, and the step is never asked for.
TwoFactorPath ~/account/two-factor The page where a user enrols, and where the sign-in page and the shell's gate send a user who must enrol. Null when the app has no such page: then no page sends a user there, and the step is never asked for.
Gate true Whether KitShell holds a signed-in user to a required step before the page it wraps (see The shell's gate).
ResetPath ~/account/reset-password The page an emailed reset link opens. A reset link is built with no request, so ~/ here is the origin's root: an app under a path base writes the base in the path, such as /admin/account/reset-password.
ForgotPasswordPath ~/account/forgot-password The forgot-password page, where the reset-password page sends a user whose link no longer works, unless the page is given its own ForgotHref.

AddSolhigsonAdmin validates the options when they are first read and at start. The host does not start when:

  • PublicOrigin is set and is not an absolute https address of a host alone (http only on a loopback host). It must have no user name, no path beyond /, no query and no fragment.
  • A path is one KitHref.Local refuses. ChangePasswordPath and TwoFactorPath may be null instead.

Set them with services.Configure<KitAccountOptions>(...).

Auditing sign-ins

KitAccountAudit holds the audit vocabulary for the account seam. The entity type is User and the entity id is the user's id. Each event is recorded as a SecurityEvent through IKitAudit (see Recording changes). The payload of a sign-in or sign-out row holds the step only, password, code, sign-out or two-factor-off, and of a lockout row also change-password or two-factor-on.

  • account.signed-in is recorded for each sign-in.
  • account.signed-out is recorded for each sign-out of a signed-in user. The seam reads the user's id from the request's principal before it signs the device out, so the row names the user whatever the sign-out leaves on the request. A request that names no signed-in user records nothing, so no row has a blank id. A sign-out that threw records nothing. A row that cannot be written is an Error of its own, and the device stays signed out. Any live session can repeat the post, each one writing a row, so the app's rate limiter must cover the sign-out path (see The sign-out page). The change-password page signs a locked account out on every post, so the app's rate limiter must cover the change-password path too (see The change-password page).
  • account.locked-out is recorded for the attempt that locks the account, and for no later attempt. The framework's answer carries no user id, so the seam reads the user by the name given from the user store, and only on that attempt. At the code step, the user is the pending user. An app with Identity's Stores.ProtectPersonalData on stores names protected, so the read finds no one: such an app gets no account.locked-out row at the password step, and each locking attempt writes a KitAccountFailed Error at step LockedUser (KeyNotFoundException). A wrong code that locks the account while turning two-factor off records it too, at step two-factor-off, for the first lockout of a streak only. A wrong current password that locks the account records it too: at step change-password on the change-password page, and at step two-factor-on when setting up two-factor. The user is read from the signed-in account, so these rows are written whatever the store's protection of names.
  • A refused attempt records nothing. So a name no user has records nothing, and an anonymous caller cannot write audit rows at will.
  • account.reset-requested is recorded when the framework answers a reset request with a link to send. Its payload is LinkSent, true when the app's mail seam answered that it sent the link. An address no account holds, a disabled account, an address two users share and a user past the framework's cap of three links an hour record nothing. The row holds no address, no link and no token. An address no account holds writes no row. The cap holds only with an ICounterStore that answers in time, and AddSolhigsonAdmin registers none. With no store, during a store outage, or on a count the store answers late, the framework lets every link go uncapped. Then an anonymous caller writes a row, and mails a link, for every request for a known address. So register a counter store (AddSolhigsonThrottling for Redis, or your own) and rate-limit the forgot-password path (see The forgot-password page).
  • account.password-reset is recorded when a password is set from a reset link. Its payload is Confirmed: true when the framework set the password; false when its save failed and the account could not be read back, so the password may be the new one. A link that does not work, a refused password and a fault before the save record nothing. The row holds no token and no password.
  • account.password-changed is recorded when a signed-in user changes their own password. Its payload is Confirmed, as for account.password-reset. A wrong current password, an unchanged or refused new one, a lockout, an account with no password and a fault before the save record nothing of it. The wrong current password that locks the account records account.locked-out, its step change-password; a later attempt on the locked account records none. The row holds no password.
  • account.two-factor-enrolled is recorded when a signed-in user turns two-factor on for their own account. Its payload is Factor, authenticator. A begin, a wrong code and a fault record nothing. The row holds no key, no address and no code, and names the user as its actor.
  • account.two-factor-disabled is recorded when a signed-in user turns two-factor off for their own account, with a code from their app. Its payload is Factor, authenticator, the factor removed. A wrong code, a refusal, an account already off and a fault record nothing. A wrong code here that locks the first lockout of the account's streak, where the framework answers NotifyHolder, records account.locked-out, its step two-factor-off, as a sign-in's locking attempt does; a later lockout of the same streak records none, and the framework's own Warning names the user. The row holds no code, and names the user as its actor.

A sign-in is made on an anonymous request, and a sign-out is made by the user on their own device, so each event names the user it is about as its actor (KitAuditEvent.ActorUserId), with no name. A reset request names no actor: anyone who knows an address can make one, so the row's actor is the request's, unattributed for a visitor. Its sentence reads "A visitor asked for a password reset link for Jane Doe" (see KitAuditLabels.Sentence). A password set from a link names the user as its actor, as a sign-in does: only the holder of a token mailed to the user's own address can make it. A password change names the user as its actor too: only the signed-in user, with their current password, makes it.

The account seam's log lines

The seam writes these lines under Solhigson.Admin.Account.KitAccount. A line carries ids only. It never holds a name or an address that was typed, a password, a code, a reset link or a token. An id is percent-encoded and cut to 64 characters, as the users seam writes it.

Line Level Text What to do
KitAccountFailed Error The account seam {Method} failed at step {Step}: {ExceptionType}; actor [{ActingUserId}], target [{TargetUserId}]. Read the step. Call means the framework's own call threw, so the answer is Failed; check the identity store. Resolve means the two-factor manager could not be resolved, or, for sign_in, a right password needs a code and the app called no AddSolhigsonTwoFactor; call it, or turn the user's two-factor off. UserId and Read are Identity's reads of the user; after reset_password, a UserId fault means the store read of the user's id threw, so the sessions, the row and the notice used the id the link carried; the password is set all the same. After change_password, a UserId fault means the same read threw, so the row and the notice used the principal's id; the password is changed all the same. Read after change_password means the read of the signed-in user threw, and Call that the framework's call threw; nothing was changed in either case. A session end or a notice the app's seam did not make after reset_password is not this line: it is KitUserSeamFailed (the seam threw) or KitUserSeamDefault (no seam registered) under Solhigson.Admin.Users.KitUserSeams. LastSignIn means the last sign-in time was not written. SignOut means the device could not be signed out after a password that needs a code no step can check; the device may keep its two-factor cookie until it expires. LockedUser means the locked user could not be read, so no account.locked-out row was written; with KeyNotFoundException, the store found no user by the name given, as under Stores.ProtectPersonalData. Audit means the audit seam could not be resolved, so no row was written; after sign_out the device is signed out all the same. Enrol means the enrolment read threw, so the user is sent to enrol. CanEnrol means the two-factor switch threw, so the view offers no enrolment. DisplayName means the app's rules threw for the user's display name, so the view is null; fix the rules. Clock means the registered TimeProvider could not be resolved, so the reset floor ran on the system clock. Floor means the floor's wait threw, so the answer came early. Origin means the account options could not be read, so no link was sent. Link means the link could not be built from PublicOrigin and ResetPath, so no link was sent. Refresh means this device's sign-in could not be refreshed after an enrolment's begin or complete, or a turn-off, which stands: the device is signed out at its next stamp check, so sign in again. Lockout means a turn-off's refusal that ends the sessions could not read whether the account is locked, so the answer is CodeCountUnavailable; the sessions end all the same. Methods: sign_in, two_factor_sign_in, sign_out, current, request_password_reset, reset_password, change_password, begin_enrolment, current_enrolment, show_enrolment, complete_enrolment, disable_two_factor, and password_link for a link a user screen sends.
KitAccountNoOrigin Error KitAccountOptions.PublicOrigin is not set, so no reset link was built for {Action} on user [{TargetUserId}] and none was sent. Set it to the address the app is reached at, such as https://admin.example.com. Set PublicOrigin. Until then no reset link goes out, from the forgot-password page or a user screen, and the forgot-password page still shows its one sentence.
KitAccountNoResetToken Warning The framework issued no reset token for {Action} on user [{TargetUserId}]: no such user, a disabled one, or one with no email address; no link was sent. A user screen asked for a link the framework would not issue. Give the user an email address, or enable them first.

The seam's KitAccountNoActor line is never written: a visitor who is not signed in is no fault. The mail seam's default and its faults write KitUserSeamDefault and KitUserSeamFailed under Solhigson.Admin.Users.KitUserSeams (see The app's sessions and notices). An audit seam that throws writes KitUserSeamAuditFailed under Solhigson.Admin.Users.KitUserSeams. A row the audit service could not write is KitAuditFailed or KitAuditUnsaved under Solhigson.Admin.Auditing.KitAudit. In each case the sign-in, the sign-out, the password set or the password change stands. After a password set, the sessions seam's default and its faults write KitUserSeamDefault and KitUserSeamFailed there too: the user's sessions may still run, so end them by hand.

The framework's sign-in writes its own lines under Solhigson.Framework.Identity (SignInDiagnostics.LoggerCategory) and counts each step on its password_sign_in counter on the meter Solhigson.Framework.Identity. Its reset request writes its own under Solhigson.Framework.Identity.Password (PasswordDiagnostics.LoggerCategory): an Information line for each token issued, and a Warning for an address two users share and for a user past the cap, each naming ids only. Its password reset writes there too: an Information line for each password set, a Warning for a refused token of an enabled user, and an Error for a fault, never with the token or the password. Its password change writes there as well: an Information line for each password changed, a Warning for a wrong current password, for the attempt that locks the account, for a disabled user and for a change that lost to a parallel write of the account, and an Error for a fault or for a change staged before the call, never with either password.

The table lists the lines the account pages cause that an operator acts on, beside the seam's own, each with its level and what to do. The shell's gate writes KitShellGateFailed and KitAccountPathNotSet (see The shell's gate), and the two-factor page's code to scan writes KitQrCodeTooLong (see The two-factor page). The framework's lines name ids only, never a password, a token, a key or a code:

Line Level What to do
KitUserSeamDefault under Solhigson.Admin.Users.KitUserSeams Warning The app registers no IKitAccountMail, so no reset link and no notice is mailed, or no IKitSessions, so no session ends at once after a password set from a link, or after a turn-off refused because the account locked or its code could not be counted. A turn-off that lands still signs the user's other devices out at their next stamp check. Register the app's own (see The app's sessions and notices). Logged once per process.
KitUserSeamFailed under Solhigson.Admin.Users.KitUserSeams Error The app's mail or sessions seam threw, or could not be resolved, and counts as false: the link or the notice did not go out, or the user's sessions still run. Read the app's own log for the exception, and end the sessions by hand.
KitUserSeamAuditFailed under Solhigson.Admin.Users.KitUserSeams Error The app's audit seam threw, so the account event has no row; the sign-in, the sign-out or the change stands. Read the app's own log for the exception, and fix the seam.
KitAuditOff under Solhigson.Admin.Auditing.KitAudit Warning No account event is recorded. Act on the reason, as in Recording changes. Logged once per process.
KitAuditFailed or KitAuditUnsaved under Solhigson.Admin.Auditing.KitAudit Error The event's row was not written; the account change stands. Act as in Recording changes.
"Password sign-in: account {UserId} locked out by this attempt" and "Two-factor sign-in: account {UserId} locked out by this code, ..." under Solhigson.Framework.Identity (SignInDiagnostics.LoggerCategory) Warning The password or the code that locked the account. A rise means passwords or codes are being guessed: check that the rate limiter covers the sign-in and code routes. "Password sign-in: account {UserId} unlocked", an Information line, is written when the app ends a lockout through the identity manager's UnlockAsync. The user page's End lockout writes "User administration {Operation} by actor {ActingUserId} on target {TargetUserId} done: the lockout ended" in its place, and a lockout that runs out writes nothing.
"Two-factor sign-in: account {UserId} signed in on its password alone while two-factor is switched off" under Solhigson.Framework.Identity Warning An enrolled account was let in with no code, because TwoFactorOptions.Enabled answers false. This is expected while the switch is off on purpose; otherwise turn it on.
"Two-factor sign-in: account {UserId} refused: two-factor is on and its authenticator key cannot be read" under Solhigson.Framework.Identity Warning The account cannot sign in until its key is readable: restore the root key ring's key, or reset the user's two-factor on the user page.
"Two-factor sign-in: account {UserId} refused: two-factor is on and Identity signed it in without a code (a client it remembers)" under Solhigson.Framework.Identity Warning Identity let a remembered device skip the code; the framework refused the sign-in and forgot the device. The user signs in again and is asked the code.
"Two-factor sign-in: the counter store cannot count code attempts; until it does they are counted in this process, or refused where TwoFactorOptions.CodeCapFailsClosed is on" under Solhigson.Framework.Identity Warning Restore the counter store (Redis). "Two-factor sign-in: the counter store counts code attempts again after {OutageLength}; ...", an Information line, ends the outage.
"Two-factor sign-in: {What} not counted for account {UserId}" under Solhigson.Framework.Identity Warning {What} is wrong code or lockout streak: that count was not made, because no counter store is registered or it could not count. Register one with AddSolhigsonThrottling, or UseInMemoryCounterStore on one host, or restore it. The other "Two-factor sign-in:" Warnings say which lockout step failed, and most name the exception's type: check the identity store and the counter store.
"Sign-in: last login time of account {UserId} not written: Identity refused it: {ErrorCodes}" under Solhigson.Framework.Identity Error The sign-in stands, but its time is not stored. Read the error codes, and check the identity store.
"Two-factor sign-in: the switch TwoFactorOptions.Enabled threw {ExceptionType}; read as on: the code is asked" under Solhigson.Framework.Identity Error Fix the app's switch. Meanwhile every enrolled account is asked its code.
"Two-factor must-enrol check for user {UserId}: the switch TwoFactorOptions.{SwitchName} threw {ExceptionType}; read as on" under Solhigson.Framework.Identity.TwoFactor (TwoFactorDiagnostics.LoggerCategory) Error The Enabled or RequiredForGroupsEnabled switch threw. The shell's gate makes the check on every page it wraps, so the line repeats on each one. Meanwhile a user in a group of RequiredForGroups with two-factor off is sent to enrol. Fix the app's switch.
"Two-factor code refused unchecked for user {UserId}: {Reason}" under Solhigson.Framework.Identity.TwoFactor Warning A turn-off's code was refused before it was checked, and the user's sessions end. locked_out: the account is locked, until the lockout runs out or an administrator ends it. code_cap_reached: the account is over the cap of code attempts; a rise means codes are being guessed. code_cap_unavailable: the attempt could not be counted; restore the counter store.
"Two-factor change refused for user {UserId} at step {Step}: {ErrorCodes}" under Solhigson.Framework.Identity.TwoFactor Warning Identity refused the enrolment's or the turn-off's write at that step, and the answer is Failed. Read the error codes, and check the identity store.
"Two-factor {Method} of user {UserId} landed; another request saved the account since, so the account object keeps this call's concurrency stamp" under Solhigson.Framework.Identity.TwoFactor Warning The change stands. A later save of the same account object in that request loses on its concurrency stamp, and this line explains that failure. Nothing else is needed.
"Password reset {Method}: no counter store is registered; reset links are issued uncapped" under Solhigson.Framework.Identity.Password (PasswordDiagnostics.LoggerCategory) Warning The cap of three links an hour does not hold. Register a counter store with AddSolhigsonThrottling, or UseInMemoryCounterStore on one host. Logged once per process.
"Password reset {Method}: the counter store cannot count reset links; links are issued uncapped until it counts again" under Solhigson.Framework.Identity.Password Warning Restore the counter store (Redis). "Password reset {Method}: the counter store counts reset links again after {OutageLength}; {UncountedLinks} links were issued uncapped", an Information line, ends the outage.
"Password reset {Method}: a count of reset links was not answered within the floor; links are issued uncapped until one is" under Solhigson.Framework.Identity.Password Warning The counter store answers slower than what remains of the framework's 400 ms floor, less 50 ms, after its own read: check its latency. "Password reset {Method}: reset links are counted within the floor again after {OutageLength}; {UncountedLinks} links were issued uncapped", an Information line, ends it.
The framework's other password lines under Solhigson.Framework.Identity.Password Information, Warning or Error A Warning for an address two users share (give one of the accounts another email; each one's user page says its email is shared), for a user past the cap of three links an hour (a rise means addresses are being tried), for a refused reset token (a spent or expired link: the user asks for a new one) and for the change-password page's refusals; an Error for a fault: check the identity store.
The framework's code lines under Solhigson.Framework.Identity.AuthenticatorStep (UsedAuthenticatorStep.LoggerCategory) Warning "its time step is at or before the last one the account used": a code posted again, from one account a double post, from many a relay. "its time step could not be recorded": a right code refused because its step was not saved; check the identity store. "the last time step stored for the account cannot be read": every code of the account is refused until its two-factor is reset.
The framework's key line under Solhigson.Framework.Identity.AuthenticatorKey (AuthenticatorKeyStorage.LoggerCategory) Error A stored authenticator key the root key ring cannot open: the ring lacks the key it was stored under, or the row is not one the ring wrote. Restore the ring's key, or reset the user's two-factor.

The account counter

Each call the seam answers adds one to the counter account on the meter Solhigson.Admin (KitAccountDiagnostics.MeterName). The app adds it to its metrics pipeline (AddMeter("Solhigson.Admin")). A call the caller cancelled is not counted. A listener that throws loses the add, and the call is still answered. The framework's counter has no outcome for a call that threw, so this counter counts store outages too. With the shell's gate on, current also counts each page view inside the shell, the gate's read of the viewer, beside the account pages' own reads.

Tag Values
method sign_in, two_factor_sign_in, sign_out, current, request_password_reset, reset_password, change_password, begin_enrolment, current_enrolment, show_enrolment, complete_enrolment, disable_two_factor.
outcome For a sign-in step, the framework's outcome text, such as succeeded, rejected or locked_out. For sign_out, signed_out. For current, signed_in or not_signed_in. For request_password_reset, sent, not_sent (no origin, options that could not be read, a link that could not be built at the Link step, or a mail seam that answered false, threw or could not be resolved), no_send (no account, a disabled one, a shared address or the cap) or invalid_email. For reset_password, done, token_not_valid (every link that does not work), password_refused or unconfirmed (a password that may have been set). For change_password, done, current_not_valid, password_unchanged, password_refused, no_password, locked_out (the account is locked, by this attempt or before it), unconfirmed, or not_signed_in (a principal that names no stored user). For begin_enrolment, current_enrolment, show_enrolment and complete_enrolment, done, not_signed_in, not_available, already_enrolled, needs_root_ring, no_key or code_not_valid; for current_enrolment, pending (a key pending, which the read does not show) in place of done; for begin_enrolment, show_enrolment and complete_enrolment, also wrong_password, locked_out (the account is locked, by this check or before it) or sign_in_again (an account with no password). For disable_two_factor, done, not_signed_in, not_available, not_enrolled, code_not_valid, too_many_code_attempts (the account is locked) or code_count_unavailable (a refusal that ends the sessions for an account not locked: the code cap reached or not countable, or a wrong code's count not saved). failed for a call that threw, and for the framework's own Failed. For request_password_reset, failed is mostly the framework's own Failed, whose Error is the framework's password line under Solhigson.Framework.Identity.Password; otherwise it is a step of the seam's, named by KitAccountFailed.
floor For request_password_reset alone: held when some of the 700 ms floor remained once the request's steps were done, and its wait ran to its end; overrun when the steps ran to the floor's end or past it, or the floor's wait threw. The tag is counted, never logged, since an anonymous caller could drive a line a request.

A reset request is counted after its floor's wait, so one the caller cancels during the wait counts nothing. A link a user screen sends is not counted here; the framework counts its issue_reset.

What to watch: failed means read the seam's KitAccountFailed line, or for request_password_reset the framework's password line. A rise in rejected or locked_out means passwords are being guessed. Any not_sent means reset links are not reaching users: read KitAccountNoOrigin, KitAccountFailed and the mail seam's lines. A rise in no_send beside few sent means addresses are being tried. A rise in change_password current_not_valid or locked_out means a signed-in session is guessing its user's password: a stolen cookie, most likely. Any floor = overrun means the forgot-password page's timing can tell one request from another. Read floor beside outcome:

  • An overrun on sent or not_sent is a found account's own steps: the app's mail seam or the audit row took longer than the floor. Queue the mail, and answer once it is queued (see The reset link and the account mail).
  • An overrun on no_send, invalid_email or failed is the store or the clock: the framework's read took longer than the floor, or the floor's wait threw, which overruns every request. Read the framework's password line and the seam's KitAccountFailed line.

Keeping the account routes out of tracing

The framework's inbound trace copies each traced request's and response's body and headers, and the default LoggingApiTraceSink logs them unmasked. On the account routes they carry the passwords, the reset token, the authenticator key and the typed address. So:

  • An app that traces inbound requests (ApiConfiguration.InboundTraceEnabled) with an include list covering the account routes lists the sign-in, code, forgot-password, reset-password, change-password and two-factor routes in ApiConfiguration.InboundExcludePaths. That list matches the request's path without its path base: under the path base /admin, write /account/sign-in.
  • Where it persists inbound exchanges through the masker (ApiTraceMaskOptions.PersistInbound), it lists the same routes in ApiTraceMaskOptions.InboundExcludePaths too. That list matches the trace URL's path, path base included: under the path base /admin, write /admin/account/sign-in.

The session cookie rides every request a signed-in user makes, so excluding these routes does not keep it out of the default sink. An app that traces pages a signed-in user reaches registers a sink that keeps it out: one that masks through ApiTraceMasker, as the framework's LokiApiTraceSink does, which AddSolhigsonLogExport registers while the host exports its API exchanges, and whose floor (ApiTraceMaskOptions.ProtectedFieldsFloor) masks Cookie, Set-Cookie and Authorization; or its own IApiTraceSink that drops the Cookie and Set-Cookie headers. Keeping the include list (ApiConfiguration.InboundIncludePaths) to the app's API paths keeps the cookie out only where no signed-in browser calls those paths.

The sign-in page

KitSignIn (Solhigson.Admin.Components) is the sign-in page. The app writes the route, marks it anonymous and places it outside the shell:

@page "/account/sign-in"
@attribute [AllowAnonymous]

<KitSignIn ReturnUrl="@ReturnUrl" ForgotHref="~/account/forgot-password" />

@code {
    [SupplyParameterFromQuery(Name = KitReturnUrl.QueryName)] public string? ReturnUrl { get; set; }
}
Parameter Required What it does
ReturnUrl no Where the user goes after the sign-in. Only a value KitReturnUrl.Safe accepts is used; any other goes to HomePath.
ForgotHref no The forgot-password page, a path on this site. It is the quiet link beside the button. A value KitHref.Local refuses throws when the page renders.

The other addresses are the KitAccountOptions paths.

The page renders KitAuthFrame titled "Sign in" and one form, sign-in: "User name or email" (autocomplete="username"), "Password" (autocomplete="current-password") and the Primary "Sign in" button. The form posts to the page's own path, with ReturnUrl as its only query field, and with no data-enhance. A sign-in is therefore a full page load, and the browser has the seam's cookie before the next page asks for it.

The page sends the user on by the answer's Next:

Next Goes to
Done The return address, if KitReturnUrl.Safe accepts it; else HomePath.
Code CodePath, carrying the pending id and the return address.
ChangePassword ChangePasswordPath, carrying the return address; where it is null, as for Done.
Enrol TwoFactorPath, carrying the return address; where it is null, as for Done.

The package's seam passes over a change of password whose ChangePasswordPath is null: it answers Enrol for a user who must also enrol, else Done, and the first time in the process writes the KitAccountPathNotSet Warning.

A page carries the return address in its ReturnUrl query field, only when KitHref.Local accepts it. Only Succeeded moves the user on, or RequiresTwoFactor with Code and a pending id. Any other answer is a refusal.

The sign-in page carries the pending id to the code page, in the query field PendingUserId, escaped, before ReturnUrl: ~/account/code?PendingUserId=42&ReturnUrl=%2Fusers. No other address holds it. This is safe because the code step compares it with the account Identity's two-factor cookie names, so the id is never the basis of a sign-in by itself. A changed id answers TwoFactorTimedOut, and a code typed for another tab's password step is refused.

The code page's address holds the user's id. No default protected name of the framework's API trace masker covers PendingUserId. Keep the code route out of tracing, as Keeping the account routes out of tracing says.

A refusal renders the form again, with status 200:

  • the user name is kept;
  • the password is empty;
  • one Danger KitAlert above the form holds the answer's sentence and takes the focus as the page loads.

Each refusal of an account, such as a wrong password, an unknown name, or a disabled or locked account, is the same sentence and the same page. The page writes no log line; the seam writes them.

A viewer who is already signed in (CurrentAsync) is sent on before any form renders:

  1. to ChangePasswordPath, if their password must change and the path is set;
  2. else to TwoFactorPath, if they must enrol and the path is set;
  3. else to HomePath.

The first two carry the return address. A target that is the sign-in page itself is no redirect: the page, titled "Signed in", says "You are signed in." and renders no form.

The page writes Cache-Control: no-cache, no-store and Pragma: no-cache before its first await. The page must not use stream rendering: no @attribute [StreamRendering] on it or on a layout around it. On a page that streams, the response starts at the page's first await, so the page could set no cookie and redirect nowhere. The page yields once before it reads the viewer, and throws, saying so, when the response has started; this holds whether the seam answers at once or later. A post is rendered whole before its handler runs, so the handler yields and checks again before it calls the password step: no one is signed in on a page that streams. The page renders on a request alone, so it takes no interactive render mode.

A redirect is the framework's NavigateTo. A host that turned off its exception (BlazorDisableThrowNavigationException) gets the same redirects, and a post to the page of a viewer it has sent on calls nothing.

The code page

KitTwoFactorCode (Solhigson.Admin.Components) is the code page, the second step of a two-factor sign-in. The sign-in page sends a user here when their password was right and their account has two-factor on. The app writes the route at CodePath, marks it anonymous and places it outside the shell:

@page "/account/code"
@attribute [AllowAnonymous]

<KitTwoFactorCode PendingUserId="@PendingUserId" ReturnUrl="@ReturnUrl" />

@code {
    [SupplyParameterFromQuery(Name = KitSignInResult.PendingUserIdQueryName)] public string? PendingUserId { get; set; }
    [SupplyParameterFromQuery(Name = KitReturnUrl.QueryName)] public string? ReturnUrl { get; set; }
}
Parameter Required What it does
PendingUserId yes The id the sign-in page put in the address. With none, or a blank one, a GET sends the user to SignInPath, carrying the return address; where SignInPath is the code page itself, the page shows the expired sentence and "Sign in again" in place of the form, never sending the user round. A post holding no pending id renders no form, so the framework answers it 400.
ReturnUrl no Where the user goes after the sign-in, as on the sign-in page.

The page renders KitAuthFrame titled "Enter your code" and one form, two-factor-code:

  • "Code", a KitField with inputmode="numeric", autocomplete="one-time-code" and at most 12 characters, set in the mono face;
  • the pending id, in a hidden field, encoded;
  • the Primary "Sign in" button.

The form posts to the page's own path, with ReturnUrl as its only query field, and with no data-enhance. On a post the page reads the pending id from the form alone. The id is no secret and no claim: the code step compares it with the account Identity's two-factor cookie names. The code is passed to the code step as typed, and the framework drops its spaces and hyphens. The page writes the code into no field and no address.

The page sends the user on by the answer's Next, as the sign-in page does. Every other answer keeps status 200:

Answer The page shows
Rejected, a wrong code The form again, the field empty, with the error "That code was not accepted. Try the next one your app shows." under it. The field takes the focus.
TooManyCodeAttempts, LockedOut, Disabled, AuthenticatorUnreadable Under the title "Sign-in ended", the sign-in refusal sentence, in place of the form, and "Sign in again", a Primary link to SignInPath.
TwoFactorTimedOut Under the title "Sign-in ended", "This sign-in has expired. Sign in again with your password.", in place of the form, with the same link.
CodeCapUnavailable, Failed, any other The form again, empty, under "Sign-in is unavailable for a moment. Try again shortly." The next try can succeed.

Each sentence but the wrong code's is one Danger KitAlert that takes the focus as the page loads; the wrong code's is the field's error, and the field takes the focus. The form is not shown where no code can succeed. A wrong code is told apart from the other refusals, since the user already proved their password. An answer that sends the user to the code page again is no step at the code page: it reads as unavailable.

Everything else is as on the sign-in page. The page writes Cache-Control: no-cache, no-store before its first await. It must not use stream rendering, and throws, saying so, before it reads the viewer and before it calls the code step. A viewer who is already signed in is sent on before any form renders. A redirect is the framework's NavigateTo, and the page writes no log line.

The app places no other form of its own on the code page. A post of another form binds no pending id, so the page sends the user to sign in.

The sign-out page

KitSignOut (Solhigson.Admin.Components) is the sign-out page. The app writes the route at the path its shell's SignOutAction names, marks it anonymous, and places the page inside the shell or outside it:

@page "/account/sign-out"
@attribute [AllowAnonymous]

<KitSignOut />

The page takes no parameter; the sign-in path is KitAccountOptions.SignInPath. Its one form is named by the constant KitSignOut.FormName, which the shell's SignOutFormName is set from (see The admin shell), so the shell's item and the page share the one name.

Sign-out is a post with a token, never a link. A GET signs nobody out, whatever its query says. For a viewer signed in (CurrentAsync) it renders KitAuthFrame titled "Sign out" and the form, posting to the page's own path with no query field and no data-enhance, holding its antiforgery token, one sentence and one Primary "Sign out" button. The sentence says this device alone is signed out: "This signs you out on this device; your other devices stay signed in." A view with a DisplayName leads it with the name, set in a <bdi> so the name's direction cannot turn the sentence round: "Signed in as Ada Okoro. This signs you out on this device; your other devices stay signed in." A visitor not signed in is sent to SignInPath. Where SignInPath is the sign-out page itself, the page, titled "Signed out", says "You are signed out." and renders no form, never sending the visitor round.

A post without a valid antiforgery token is refused by the framework with 400, and signs nobody out. A valid post, from the page's form or the shell's item, calls SignOutAsync and sends the user to SignInPath. It signs this device out alone: the user's other devices stay signed in. Sign-out deletes this browser's cookie. The ticket in it stays valid until it expires or the user's security stamp changes, so a copy of the cookie taken before still signs in. The sessions seam (IKitSessions) is what ends every session of a user. The seam records account.signed-out with the user's id (see Auditing sign-ins). A post renders the form whoever the viewer is, so a post whose viewer is no longer signed in, with a token the framework still accepts, is sent to SignInPath too, and records nothing.

Each valid post writes a row, and the server keeps no record of a deleted cookie: the cookie's ticket and the user-bound antiforgery token stay valid on the server, so any live session can repeat the post and write another row. The app's rate limiter must cover the sign-out path.

A post sent after the sign-in cookie has expired is refused by the framework with 400, since its token is bound to the user it was made for, and the page's GET, which sends the visitor to sign in, is the fallback.

A sign-out the seam could not make renders the form again under "Sign-out is unavailable for a moment. Try again shortly.", one Danger KitAlert that takes the focus as the page loads, and the sentence naming the viewer. The status stays 200 and there is no redirect, so the user knows they are still signed in.

Inside the shell, KitAuthFrame draws no brand, since the shell's rail shows it, and takes the class kit-auth-in-shell: the frame adds no padding or centring of its own, so its title starts at the main region's padding, as KitPageHeader's does, the column still no wider than --kit-auth-w. Outside the shell the frame is as on the sign-in page.

Everything else is as on the sign-in page. The page writes Cache-Control: no-cache, no-store before its first await. It must not use stream rendering, and throws, saying so, before it reads the viewer and before it signs anyone out. A redirect is the framework's NavigateTo, and the page writes no log line. The page renders on a request alone, so it takes no interactive render mode.

The forgot-password page

KitForgotPassword (Solhigson.Admin.Components) is the forgot-password page. The app writes the route, marks it anonymous, and places it outside the shell or inside it. The sign-in page links to it through its ForgotHref:

@page "/account/forgot-password"
@attribute [AllowAnonymous]

<KitForgotPassword />

The page takes no parameter; the sign-in path is KitAccountOptions.SignInPath. It renders KitAuthFrame titled "Reset your password" and one form, KitForgotPassword.FormName (forgot-password), posting to the page's own path with no query field and no data-enhance: the email field (autocomplete="email"), one Primary "Send reset link" button and the quiet link "Back to sign in". The form carries novalidate, so a browser posts a blank or malformed address and the field's error answers it, not the browser's own bubble.

A GET asks for nothing, whatever its query holds: the field is bound from a post alone. A post without a valid antiforgery token is refused by the framework with 400. A valid post calls RequestPasswordResetAsync with the address as posted, and the page shows one of two things:

  • For every answer but an address that is not one, the same frame in place of the form, titled "Check your email": "If that address has an account, a reset link is on its way." in one Neutral KitAlert that takes the focus, and the Primary link "Back to sign in". The address is not on the page. The status is 200 and the headers are the same, so a visitor cannot tell whether the address has an account, whether it is disabled or past its cap, or whether the link was sent.
  • For an address that is not one, a blank one included, the form again, titled "Reset your password", the address kept in its field, encoded, under "Enter a valid email address.", the field taking the focus.

A viewer already signed in is sent on as the sign-in page sends them, and the post asks for nothing: a signed-in user changes the password from their own account page. The page writes Cache-Control: no-cache, no-store before its first await. It must not use stream rendering, and throws, saying so, before it reads the viewer and before it asks for a link. The page writes no log line, and renders on a request alone.

Each post takes at least 700 ms, the seam's floor. The app's rate limiter must still cover the forgot-password path. The framework's cap stops a fourth link an hour to one account, and only with a counter store that answers in time: AddSolhigsonAdmin registers none, so register one (AddSolhigsonThrottling, or your own). With none, during its outage or on a late count, every request for a known address mails a link and writes a row. The cap never stops a caller trying many addresses.

RequestPasswordResetAsync calls the framework's RequestPasswordResetAsync, which holds its own floor and caps a user at three links an hour, with a counter store that answers in time (see The forgot-password page). When it answers Send, the seam builds the link with KitResetLink.Build(origin, resetPath, userId, token) from KitAccountOptions.PublicOrigin and ResetPath, never from the request's Host or X-Forwarded-Host. The query is userId=<id>&token=<token>, each value escaped with Uri.EscapeDataString, so a token holding +, / or = reads back whole (KitResetLink.UserIdQueryName, KitResetLink.TokenQueryName). With no PublicOrigin no link is built and no mail is sent, KitAccountNoOrigin says so, and the page shows its one sentence all the same.

The seam then calls the app's mail seam, and records account.reset-requested with whether it sent the link (see Auditing sign-ins). The address typed is used for the framework's lookup alone, never after it.

IKitAccountMail (Solhigson.Admin.Account) is how the app mails a user about their account. AddSolhigsonAdmin registers none, so register yours before or after it:

services.AddScoped<IKitAccountMail, AppAccountMail>();
Member What it does
SendPasswordResetAsync(userId, link, ct) Mails the user the reset link. Answers true when the mail was sent or queued.
NotifyAsync(userId, notice, ct) Tells the user that notice happened to their account: PasswordReset, PasswordChanged, TwoFactorTurnedOff or TwoFactorTurnedOn. Answers true when the mail was sent or queued.

The seam is given the user's id, never an address. The app's seam mails the address the store holds for that user, read by the id, never an address a visitor typed. The link holds a token that sets the account's password, so the app's seam writes it to no log. The package calls each member with no cancellation.

The reset-password page's seam call sends PasswordReset once a password is set from a link (see The reset-password page), and the change-password page's sends PasswordChanged once a signed-in user changes it (see The change-password page). The two-factor page's sends TwoFactorTurnedOn once a signed-in user turns two-factor on (see The two-factor page), and TwoFactorTurnedOff once they turn it off (see Turning two-factor off). An app's seam that tells notices apart by name names all four members of KitAccountNotice.

Without a registration the package's default sends nothing and answers false, with one KitUserSeamDefault Warning a process. A seam that throws, or cannot be resolved, counts as false, with one KitUserSeamFailed Error naming the user's id and the exception's type, never the link.

The request returns no sooner than 700 ms after it was called, whatever happened inside it: an account found or not, disabled or capped, the mail seam answering, throwing or slow, the row written or not, no origin. It reads the registered TimeProvider once on entry and waits for the floor last, so the link, the mail, the row and their lines all happen inside it. A mail seam slower than the floor still shows through: a found account's request then takes longer than a missing one's. So the app's seam queues the mail, and answers once it is queued, never once the provider has sent it.

A user screen's "Send password link" sends the same link through the same seam (see The app's sessions and notices).

The reset-password page

KitResetPassword (Solhigson.Admin.Components) is the page an emailed reset link opens. The app writes the route at KitAccountOptions.ResetPath, marks it anonymous, and places it outside the shell or inside it. It reads the id and the token from the link's query by the names the link uses, and passes them on:

@page "/account/reset-password"
@attribute [AllowAnonymous]

<KitResetPassword UserId="@UserId" Token="@Token" />

@code {
    [SupplyParameterFromQuery(Name = KitResetLink.UserIdQueryName)]
    public string? UserId { get; set; }

    [SupplyParameterFromQuery(Name = KitResetLink.TokenQueryName)]
    public string? Token { get; set; }
}

ForgotHref, a path on this site, is where a user whose link no longer works asks for a new one; with none, the page links to KitAccountOptions.ForgotPasswordPath. A ForgotHref that KitHref.Local refuses throws. The sign-in path is KitAccountOptions.SignInPath.

The page renders KitAuthFrame titled "Choose a new password" and one form, KitResetPassword.FormName (reset-password), posting to the page's own path with no query field and no data-enhance:

  • "New password" and "Confirm new password", each autocomplete="new-password" and always empty;
  • the id and the token as hidden fields, each encoded;
  • one Primary "Set password" button.

A GET sets nothing, whatever its query holds: the passwords are bound from a post alone. A link with no id or no token, or a blank one, shows the dead-link frame below in place of the form, not an error. A post reads the id and the token from its hidden fields alone, never from its address. A post whose hidden id or token is missing or blank finds no form to post to: the framework answers 400, and nothing is set. A post without a valid antiforgery token is refused by the framework with 400.

A valid post first compares the confirmation with the new password, on the server, character by character. One that differs renders the form again under the confirmation's error, "The two passwords differ. Type the same password in both fields.", and calls nothing. Else the page calls ResetPasswordAsync and shows its answer:

Answer What the page shows
Done In place of the form, titled "Password set": one Success alert, "Your password is set.", then the Primary link "Sign in". The alert adds "When you sign in, you will be asked for the code your authenticator app shows." for an account with two-factor on, and "Your account is still locked for a while, so sign-in waits until the lock ends." for one still locked out.
TokenNotValid In place of the form, titled "Reset link ended": one Warn alert, "This link no longer works. Links work once and expire.", then the Primary link "Get a new link" to the forgot-password page.
PasswordRefused The form again, the password rules' reasons under the new password, encoded, as the app's validators wrote them. With no reason, "That password was refused. Choose a different one."
Unconfirmed In place of the form, titled "Password may be set": one Warn alert, "Your password may be set, but this could not be confirmed. Sign in with the new password; if it is refused, ask for a new link.", then the Primary link "Sign in" and the quiet link "Get a new link" to the forgot-password page.
Failed, and any other value The form again under one Danger alert, "Setting a password is unavailable for a moment. Try again shortly."

The dead link is one frame for every link that does not work: a spent, expired or never-issued token, an id no user has, and a disabled user's. The framework answers one outcome for each, and the page adds no difference. Each alert takes the focus as the page loads. Either field's error puts the focus on the new password, since both fields come back empty; the confirmation's error shows under the confirmation and describes the new password as well. The status is 200. Neither password is written into the page, an address, a log line or a row.

A password set ends the user's sessions through IKitSessions.EndAsync, records account.password-reset, and tells the owner through IKitAccountMail.NotifyAsync with PasswordReset, each under the user's id as the store writes it. The seam reads that id from the user store with no token, since Identity's AspNetUserManager passes the request's token to its own reads, and a client that drops once the save landed has cancelled it. Each step is caught on its own, with no cancellation, and none undoes the reset. An Unconfirmed answer runs the same steps, its row unconfirmed, since a password that may be the new one must not leave the sessions running. No other answer runs any of them. The reset signs no one in: the user signs in with the new password. With no IKitSessions of the app's, no session ends at once; register one (see The app's sessions and notices).

A viewer already signed in is served as a visitor is. The link is the whole authority, and a signed-in user may open a link for their own account or for another's, so the page reads no viewer.

The page writes Cache-Control: no-cache, no-store and Referrer-Policy: no-referrer before its first await, on every response it renders: each answer, and the 400 of a post with no hidden id or token. Its address holds the token, so no link or resource of the page may send it on, and every link is a path on this site. The framework's antiforgery 400 is written before the page runs, so it carries neither header. Its body holds no token and no password, and the post's address holds no token. An app that wants both headers on that answer too sets them on the reset route in its own middleware. The page must not use stream rendering, and throws, saying so, before it calls the seam. It writes no log line, and renders on a request alone.

The page sets Referrer-Policy: no-referrer itself, while it renders. An app's middleware that writes Referrer-Policy when the response starts (a Response.OnStarting callback) replaces it, and the token then goes in the Referer of the page's own requests to this site. Such an app must select no-referrer for the reset route there. It writes no referrer meta: Blazor's head shows one HeadContent at a time, so one of the page's would displace the head content of the app's own page or layout. A post from a page with no referrer carries Origin: null, so an origin-checking layer in front of the app, such as a WAF or the app's own CSRF middleware, must allow it on the reset route.

The link's address holds the token until the page is posted. So:

  • Keep the reset route's query out of request logging. ASP.NET Core's own request lines, an access log at a proxy or a load balancer, and an APM agent all write the query by default. Log the reset route's path alone, or drop the query field token (KitResetLink.TokenQueryName).
  • Exclude the reset route from tracing, as Keeping the account routes out of tracing says. The masker protects a query field named token by default, and the route stays out all the same.
  • The app's rate limiter must cover the reset-password path. The framework's refusals take different times: a malformed id reads nothing, a missing or disabled user reads one row, and an enabled user's wrong token reads one row, then checks the token. With sequential ids, such as an int key, a stranger timing the answers could tell an enabled account's id from the rest.

The change-password page

KitChangePassword (Solhigson.Admin.Components) is the page where a signed-in user changes their own password, and where the sign-in page and the shell's gate send a user whose password must change. The app writes the route at KitAccountOptions.ChangePasswordPath, inside its signed-in layout, and the page carries [Authorize]: a component cannot challenge, so the app's authorization is what keeps visitors out. The page reads the return address from the query by KitReturnUrl.QueryName, as the sign-in page sends it:

@page "/account/change-password"
@attribute [Authorize]

<KitChangePassword ReturnUrl="@ReturnUrl" ForgotHref="/account/no-password" />

@code {
    [SupplyParameterFromQuery(Name = KitReturnUrl.QueryName)]
    public string? ReturnUrl { get; set; }
}

ForgotHref, a path on this site, is a page of the app's that gives a signed-in viewer whose account has no password a reset link. The package offers no page for this: its forgot-password page serves visitors alone. So an app that has no such page leaves ForgotHref unset, and the page shows the no-password sentence alone, with no link. The example does not point it at the kit's forgot-password page, because that page sends every signed-in viewer on, and the two pages would point at each other. A ForgotHref that KitHref.Local refuses throws. The sign-in path is KitAccountOptions.SignInPath.

The sentence sends the viewer to sign out, then to the sign-in page's "Forgot your password?" link. The sign-in page shows that link only where the app sets KitSignIn's ForgotHref.

The page renders KitPageHeader titled "Change password", the page's one <h1>; where an answer below takes the form's place, the header names that answer instead. Then, in one column no wider than --kit-auth-w, one form, KitChangePassword.FormName (change-password), posting to the page's own path with the return address as its one query field and no data-enhance:

  • "Current password", autocomplete="current-password", always empty;
  • "New password" and "Confirm new password", each autocomplete="new-password" and always empty;
  • one Primary "Change password" button.

When the viewer must change their password (KitAccountView.MustChangePassword), one Warn alert above the form says "A new password is needed before you go on." A viewer whose account has no password sees, in place of the form, the NoPassword answer below.

Every request reads the viewer through CurrentAsync. A visitor who is not signed in sees no form, by the sign-out page's rule: a GET is sent to SignInPath, with no return address; where SignInPath is this page itself, the frame titled "Signed out" says "You are signed out." A post from a visitor finds no form to post to, so the framework answers 400, and nothing is called. A GET changes nothing, whatever its query holds: the passwords are bound from a post alone. A post without a valid antiforgery token is refused by the framework with 400.

A valid post first compares the confirmation with the new password, on the server, character by character. One that differs renders the form again under the confirmation's error, "The two passwords differ. Type the same password in both fields.", and calls nothing, so it costs no attempt against the lockout. Else the page calls ChangePasswordAsync with the request's user and shows its answer:

Answer What the page shows
Done Titled "Password changed", in place of the form: one Success alert, "Your password is changed. Other devices are signed out the next time they are checked.", then the Primary link "Continue" to the return address KitReturnUrl.Safe accepts, else HomePath.
CurrentNotValid The form again, under the current password, "That is not your current password. Too many wrong tries sign you out."
PasswordUnchanged The form again, under the new password, "The new password is your current one. Choose a different one."
PasswordRefused The form again, the password rules' reasons under the new password, encoded, as the app's validators wrote them. With no reason, "That password was refused. Choose a different one."
NoPassword Titled "No password to change", in place of the form: one Info alert, "Your account has no password to change. Sign out, then ask for a reset link on the sign-in page.", then, with ForgotHref, the Primary link "Get a reset link"; without it, the sentence alone.
LockedOut The page signs this device out through SignOutAsync and sends the user to SignInPath. The sign-out deletes this browser's cookie alone: nothing changes the security stamp at a lockout, so a copy of the cookie taken before stays signed in until it expires or the stamp changes. A sign-out the seam could not make shows, titled "Account locked", in place of the form, one Danger alert, "Your account is locked after too many wrong passwords, and signing you out failed. Sign out, and sign in again once the lock ends.", and no form; the framework refuses every change while the account is locked, before it reads a password, and a reload tries the sign-out again.
Unconfirmed Titled "Password may be changed", in place of the form: one Warn alert, "Your password may be changed, but this could not be confirmed. The next time you sign in, try the new password first.", then "Continue".
Failed, and any other value The form again under one Danger alert, "Changing your password is unavailable for a moment. Try again shortly."

Each alert of an answer takes the focus as the page loads. The current password's error puts the focus on the current password; the new password's or the confirmation's on the new password, which the confirmation's error describes as well. The status is 200 but for the lockout's redirect. No password is written into the page, an address, a log line or a row.

A change keeps this device signed in: the framework refreshes its sign-in under the new security stamp. It records account.password-changed and tells the owner through IKitAccountMail.NotifyAsync with PasswordChanged, each caught on its own, with no cancellation, neither undoing the change. IKitSessions is not called: it cannot spare this device, and the new stamp ends the others. An Unconfirmed answer runs the same steps, its row unconfirmed. No other answer runs any of them. The framework clears MustChangePassword in the same save, so the next request's view no longer holds it.

The risk: Other devices stay signed in until Identity next checks the security stamp, at SecurityStampValidatorOptions.ValidationInterval, 30 minutes by default. A thief holding a copy of the cookie keeps it until then. An app that wants the change to sign them out sooner sets a shorter interval. A lockout changes no stamp: its sign-out deletes this browser's cookie alone, and a copy of the cookie taken before still signs in until it expires or the stamp changes.

The page writes no line of its own; the seam's and the framework's lines are those of The account seam's log lines:

Line Level What to do
KitAccountFailed at Read, method change_password Error The read of the signed-in user threw, and nothing was changed: check the identity store.
KitAccountFailed at Call, method change_password Error The framework's call threw, and nothing was changed: check the identity store.
KitAccountFailed at UserId, method change_password Error The id read after the change threw; the row and the notice used the principal's id, and the password is changed.
KitAccountFailed at Audit, method change_password Error The audit seam could not be resolved, so no row was written; the password is changed.
KitUserSeamFailed or KitUserSeamDefault under Solhigson.Admin.Users.KitUserSeams Error or Warning The owner was not told: fix or register the app's IKitAccountMail.
The framework's change lines under Solhigson.Framework.Identity.Password Information, Warning or Error A Warning for a wrong current password, the attempt that locks, a disabled user or a change that lost to a parallel write (the user tries again); an Error for a fault, or for a change the app staged in the request's context before the call: stage none there before a page calls the seam.

A locked account answers LockedOut to every post, with nothing checked, and each post signs the device out again and writes account.signed-out; a live session, a copied cookie included, can repeat it. The app's rate limiter must cover the change-password path.

Everything else is as on the sign-out page. The page writes Cache-Control: no-cache, no-store before its first await. It must not use stream rendering, and throws, saying so, before it reads the viewer and before it calls the seam. A redirect is the framework's NavigateTo. The page renders on a request alone, so it takes no interactive render mode. The page is exempt from the gallery test, as every account page is.

ChangePasswordAsync is a new member of IKitAccount. An app that registers its own IKitAccount must add it: until then that app does not build, as when ResetPasswordAsync was added.

The two-factor page

KitTwoFactorSetup (Solhigson.Admin.Components) is the page where a signed-in user turns two-factor on with an authenticator app, and where the sign-in page and the shell's gate send a user who must enrol. The app writes the route at KitAccountOptions.TwoFactorPath, inside its signed-in layout, and the page carries [Authorize], as the change-password page does. The page reads the return address from the query by KitReturnUrl.QueryName:

@page "/account/two-factor"
@attribute [Authorize]

<KitTwoFactorSetup ReturnUrl="@ReturnUrl" />

@code {
    [SupplyParameterFromQuery(Name = KitReturnUrl.QueryName)]
    public string? ReturnUrl { get; set; }
}

The page renders KitPageHeader titled "Two-factor", the page's one <h1>, in one column no wider than --kit-auth-w. Every request reads the viewer through CurrentAsync, then, for a viewer not enrolled, whether a key is pending through CurrentEnrolmentAsync, never the key. A GET changes nothing: it never begins an enrolment, and it shows no key. What the page shows is what the viewer may do now:

The viewer What the page shows
Not enrolled, no key yet One sentence on what two-factor asks for, then the form two-factor-begin with the password field and the one Primary "Set up two-factor".
A key pending Two numbered steps, the key hidden. "Add the key to your app": "Your key is hidden until you enter your password. Enter it to see the key again, or go on to the next step if your app already has it.", then the form two-factor-show with the password field, no hint, and the Default "Show the key again". "Enter your password and the code your app shows": the form two-factor-confirm, the password field and the code field with no hint in one group, since the step's heading says what to type, and the one Primary "Turn on two-factor", since an owner who added the key before the reload has only this left to do. Then the form two-factor-restart folded in a closed <details> whose summary is "Start over": "Starting over makes a new key. Codes from the key your app already has stop working, so add the new key to your app.", the password field, no hint, and the Default "Start over".
The answer to a proved set-up, show or start-over The same steps, with KitQrCode of the address and, under it, the key in the mono face in groups of four in place of the form two-factor-show, and no start-over. It is the only page that draws the key.
Two-factor on One Info alert, "Two-factor is on for your account. Each sign-in asks for the code your authenticator app shows.", then "Continue", then the form two-factor-disable folded in a closed <details> whose summary is "Turn off two-factor" (see Turning two-factor off).
Two-factor not registered, or switched off One Info alert, "Two-factor is not available on this site.", then "Continue", and no form.
Not enrolled, and the account has no password (KitAccountView.HasPassword false) One Warn alert, "Setting up two-factor asks for your password, and your account has none. Sign out, then ask for a reset link on the sign-in page.", and no form; after a post, the same alert in Danger.
KitAccountView.CanEnrol false One Warn alert, "Two-factor cannot be set up until the app registers root encryption, which keeps the key safe. Ask an administrator.", and no form.
The pending key could not be read One Danger alert, "Setting up two-factor is unavailable for a moment. Try again shortly.", then the Primary link "Try again" to the page's own address with its return address, and no form; the page it leads to reads the key again.

When the viewer must enrol (KitAccountView.MustEnrol), one Warn alert above says "Two-factor is needed before you go on." A visitor who is not signed in is sent to SignInPath, as on the change-password page, and a post from a visitor finds no form, so the framework answers 400.

Each form that acts or shows the key carries one password field of its own id, "Current password", named password, with autocomplete="current-password", required, and never written back. On the set-up and the confirm forms its hint says why it is asked again: "Asked again, even just after you signed in, so only someone who knows your password can add an app." A user the sign-in page sent here to enrol types the password a second time; the hint is for them. The show and the start-over forms have no hint, as the sentence over each says why.

The begin and the start-over call BeginEnrolmentAsync with the request's user and the password as typed, and Done shows the steps with the new key. The show calls ShowEnrolmentAsync with the password as typed, and Done shows the steps with the pending key, the same one, the stamp unchanged; Done with no key shows the steps again, the key hidden, under the Danger alert. The confirm calls CompleteEnrolmentAsync with the password and the code as typed. Each answer of the four:

Answer What the page shows
WrongPassword The form again, the key hidden, under the password field, "That is not your current password. Too many wrong tries sign you out.", the field taking the focus, the start-over opened for its own. A blank password reads the same.
SignInAgain One Danger alert, "Setting up two-factor asks for your password, and your account has none. Sign out, then ask for a reset link on the sign-in page.", and no form.
LockedOut As on the change-password page: this device is signed out and sent to SignInPath. The password that locked the account records account.locked-out, its step two-factor-on. When the sign-out fails, one Danger alert, "Your account is locked after too many wrong passwords, and signing you out failed. Sign out, and sign in again once the lock ends.", and no form.
Done One Success alert, "Two-factor is on. Each sign-in now asks for the code your app shows. Other devices are signed out the next time they are checked.", then the Primary link "Continue" to the return address KitReturnUrl.Safe accepts, else HomePath. "Continue" for two-factor on and for two-factor not available goes there too.
CodeNotValid The steps again, the key hidden, under the field, "That code was not accepted. Check the time on your phone and try the next code."
NoKey After a show or a confirm, the begin form, under one Info alert, "There is no key to confirm yet. Set up two-factor to get one."
AlreadyEnrolled, NotAvailable, NeedsRootRing That state, as in the table above.
Failed, and any other value The forms again under one Danger alert, "Setting up two-factor is unavailable for a moment. Try again shortly."

Each form renders by what the viewer may do, never by what the page showed last, so a stale post is answered in words and calls nothing. A set-up posted from a page loaded before a key existed keeps the pending key and says "Set-up has already begun, so its key is kept." over the steps, whose forms show the key again or confirm it. The start-over is a form of its own, two-factor-restart, so only a post from a page that offered it replaces the key. A code, a show or a start-over posted once no key is pending says there is none to confirm. Recovery codes are not offered.

Once two-factor is on, the seam records account.two-factor-enrolled, the user its actor, then tells the owner through IKitAccountMail.NotifyAsync with TwoFactorTurnedOn, as a password change is recorded and told (see The reset link and the account mail). Each is caught on its own, so a fault in either leaves two-factor on and the answer Done. A wrong code, a begin, a read and a show tell nobody.

A begin and a complete each rotate the security stamp, so the seam refreshes this device's sign-in after each, and the viewer stays signed in. A right password whose stored hash Identity rehashes rotates the stamp too, so the seam refreshes this device after any call whose password it proved that way, a show and a wrong code among them. Every other device of the user is signed out at its next stamp check. The refresh reads the request's sign-in as the authentication middleware read it, before the stamp rotated; a request with no sign-in cookie of the user is refreshed nothing.

The key and its address are written into the answer to a proved set-up, show or start-over alone: the address in the code's <svg>, the key as text. A page that only read the pending key, a stolen session's GET among them, draws neither, whatever an app's own CurrentEnrolmentAsync answers. Neither is in an address, a field's value, a log line or a row, and the code typed is written into no field. The answer's body holds the key, so the two-factor route is kept out of tracing, as Keeping the account routes out of tracing says. A page that shows the key must not be cached: the page writes Cache-Control: no-cache, no-store before its first await. It must not use stream rendering, and throws, saying so, before it reads the viewer and before it calls the seam. The page renders on a request alone, so it takes no interactive render mode. The page is exempt from the gallery test, as every account page is.

The page writes no line of its own; the seam's and the framework's lines are those of The account seam's log lines:

Line Level What to do
KitAccountFailed at Call, method begin_enrolment, current_enrolment, show_enrolment or complete_enrolment Error The framework's call threw, and the answer is Failed: check the identity store.
KitAccountFailed at Refresh, method begin_enrolment, show_enrolment or complete_enrolment Error This device's sign-in was not refreshed; the enrolment stands, and the device is signed out at its next stamp check.
KitAccountFailed at Audit, method complete_enrolment Error The audit seam could not be resolved, so no row was written; two-factor is on.
KitUserSeamFailed or KitUserSeamDefault under Solhigson.Admin.Users.KitUserSeams Error or Warning The owner was not told two-factor is on: fix or register the app's IKitAccountMail.
The framework's two-factor lines under Solhigson.Framework.Identity.TwoFactor (TwoFactorDiagnostics.LoggerCategory) Warning or Error A Warning for a wrong code; an Error for a fault. They name ids only, never a key or a code. The lines an operator acts on are in The account seam's log lines.
The framework's password lines under Solhigson.Framework.Identity.Password (PasswordDiagnostics.LoggerCategory), method check Warning or Error A Warning for a wrong password, or for the one that locks the account; an Error for a check that could not be made, and the answer is Failed. They name ids only, never a password.
KitQrCodeTooLong under Solhigson.Admin.Components.KitQrCode Warning The address to scan was too long for a code, so the page showed the scan label alone and the user types the key shown under it into their app. The address is the framework's otpauth:// address of TwoFactorOptions.Issuer, twice, and the user's email or user name: shorten the issuer. The line names the length, never the address. The gallery's own too-long example writes it too, with length 3015, on each render of the gallery.

A wrong code at the confirm changes nothing and is not counted toward lockout, but each post needs the password, whose wrong guesses are. The app's rate limiter must cover the two-factor path.

BeginEnrolmentAsync, CurrentEnrolmentAsync and CompleteEnrolmentAsync are new members of IKitAccount. An app that registers its own IKitAccount must add them: until then that app does not build, as when ChangePasswordAsync was added. The password argument of BeginEnrolmentAsync and CompleteEnrolmentAsync came after them, and breaks such an app's build again; its members must prove the password before they act, as the seam's do. ShowEnrolmentAsync came after them, and breaks such an app's build again: it must prove the password as the begin does before it answers the pending key, and its CurrentEnrolmentAsync should answer Pending with no key, since the page no longer draws a read's key. Its members answer a KitEnrolmentResult they build, as KitPasswordSetResult is built: new KitEnrolmentResult(KitEnrolmentOutcome.Done, key, address) for a key to show, new(outcome) for any other answer.

Turning two-factor off

For an enrolled viewer, the page folds the form two-factor-disable in a native <details>, closed until wanted, since turning two-factor off is rare and weakens the account. Its summary, "Turn off two-factor", is styled as the shell's groups, with the base focus ring. The form holds the line "An account whose role requires two-factor is asked to set it up again.", the code field with its hint, and "Turn off two-factor", the Default submit. The line is the same for every viewer: the page does not guess the viewer's role. The form asks for a code from the app, never the password, so a stolen session alone cannot drop the factor; a code replayed inside Identity's window is accepted, as at sign-in.

The post calls DisableTwoFactorAsync with the request's user and the code as typed. An answer whose EndSessions is set signs this device out (SignOutAsync) and sends the viewer to SignInPath, whatever its outcome; the seam has ended the user's other sessions through IKitSessions. Otherwise:

Answer What the page shows
Disabled One Success alert, "Two-factor is off, so sign-in no longer asks for a code. Other devices are signed out the next time they are checked.", over the page read again, which offers set-up again. The viewer stays signed in.
NotEnrolled One Neutral alert, "Two-factor was already off, so nothing changed.", over the page as it now is.
CodeNotValid The form again, the <details> open, under the field, "That code was not accepted. Check the time on your phone and try the next code. Wrong codes count toward locking your account."
TooManyCodeAttempts One Danger alert, "Your account is locked for a while, so two-factor stays on. Try again once the lock ends."
CodeCountUnavailable One Danger alert, "Codes cannot be checked right now, so two-factor stays on. Wait a few minutes, then try again."
NotAvailable Two-factor not available, as in the table above.
Failed, NotSignedIn, and any other value The form again, open, under one Danger alert, "Turning off two-factor is unavailable for a moment. Try again shortly."

The package's seam sets EndSessions on every TooManyCodeAttempts and CodeCountUnavailable, as the framework does, so with it those sentences show only when the sign-out fails. A sign-out that fails shows one Danger alert, with no form: for TooManyCodeAttempts, "Your account is locked for a while, so two-factor stays on, and signing you out failed. Sign out, and sign in again once the lock ends."; for CodeCountUnavailable, "Codes cannot be checked right now, so two-factor stays on, and signing you out failed. Sign out, sign in again, then try in a few minutes."; for any other answer an app's own seam gives with EndSessions, "Signing you out failed. Sign out, then sign in again." The seam answers TooManyCodeAttempts when the account reads locked out after the refusal, else CodeCountUnavailable: the framework's answer does not say whether the code cap was reached or could not be counted. It reads the lockout from the user store with no token, so a client that drops once the framework answered still reads locked. When it ends the sessions, its KitUserSeams lines name the action account.locked-out for TooManyCodeAttempts and for a code that locked the account, else account.two-factor-disabled, the turn-off that did not land. A user store with no lockout fails the read, a Lockout Error.

A turn-off posted from a page loaded while two-factor was on, once it is off, calls nothing and shows the page as it now is under the Neutral alert. Once two-factor is off, the seam refreshes this device's sign-in under the rotated stamp, records account.two-factor-disabled, the user its actor, and tells the owner through IKitAccountMail.NotifyAsync with TwoFactorTurnedOff. Each is caught on its own, so a fault in any leaves two-factor off and the answer Disabled. A wrong code here counts toward the account's lockout, as at sign-in, and the framework counts it against the sign-in code step's cap.

Line Level What to do
KitAccountFailed at Call, method disable_two_factor Error The framework's call threw, and the answer is Failed: check the identity store.
KitAccountFailed at Refresh, method disable_two_factor Error This device's sign-in was not refreshed; two-factor is off, and the device is signed out at its next stamp check.
KitAccountFailed at Lockout, method disable_two_factor Error Whether the account is locked could not be read, so the answer is CodeCountUnavailable; the sessions end all the same.
KitAccountFailed at Audit, method disable_two_factor Error The audit seam could not be resolved, so no row was written; two-factor is off.
KitUserSeamFailed or KitUserSeamDefault under Solhigson.Admin.Users.KitUserSeams Error or Warning The owner was not told two-factor is off, or the sessions were not ended: fix or register the app's IKitAccountMail and IKitSessions.

DisableTwoFactorAsync is a new member of IKitAccount. An app that registers its own IKitAccount must add it: until then that app does not build. It answers a KitTwoFactorOffResult it builds: new KitTwoFactorOffResult(KitTwoFactorOffOutcome.Disabled), and new(outcome, EndSessions: true) for an answer whose sessions are to end. Its NotifyHolder is the framework's: the package's seam has recorded account.locked-out when it is set, and the page does not read it.

The account frame

KitAuthFrame is the frame of the sign-in, code, sign-out, forgot-password and reset-password pages:

  • the options' Brand, in the serif face, when it is not blank;
  • one <h1>, its Title, in the serif face at --kit-fs-4;
  • then its child content.

They sit in one column no wider than --kit-auth-w, on the page's background, with no card, edge or shadow. A blank Title throws, since the title is the page's one <h1>. The frame writes no landmark, so the app's layout gives the page its <main>.

The gallery's KitAuthFrame section shows the sign-in form in its refusal state and a code form, both as outside the shell, whatever layout holds the gallery, and the sign-out form as inside the shell: no brand, the sentence and one Primary button. The account pages are exempt from the gallery test, so the section is where their states are seen.

Roles

IKitRoles (Solhigson.Admin.Roles) is the one seam through which the role screens read roles. A screen injects this one type, whatever the app's user and key types. AddSolhigsonAdmin registers it, scoped, over the framework's RoleAdministration that AddSolhigsonIdentityManager registers with the same type arguments, closed as IKitUsers is (see Users). A seam the app registered first is kept. The framework decides what the signed-in user may do with each role; the seam adds no rule and hides no outcome. The app must register its IUserAdministrationRules<TUser, TKey>, else every call but GroupNamesAsync answers NoRules for a signed-in actor.

Member Answers What it reads
ListAsync(principal, ct) KitRolePage (Rows, Outcome, Message) The framework's ListAsync: every stored role, ordered by group name then name. A role's name and size are not secret to an administrator, so every role is listed, whether or not the signed-in user may edit it.
GetAsync(principal, roleName, ct) KitRoleLookup (Row, Outcome, Message) The framework's GetAsync. It takes the role's name as a Razor component page's route value gives it; never decode that value again. A name that differs from the stored one only by letter case finds the role. A name null or blank, or one no role has, answers RoleNotFound.
HeldPermissionsAsync(principal, roleName, ct) KitHeldPermissions (Permissions, Outcome, Message) The framework's HeldPermissionsAsync: every stored grant of the role, as a HeldPermission with its class against the role's group's offer (Offered, OutsideGroup, NoDeclaration, UnknownGroup, Missing) and whether RemoveGrantsOutsideOfferAsync would remove it (Removable), whether or not the signed-in user may edit the role. The framework finds the role by its name exactly as stored, so pass the Name that GetAsync answered, not the route value. A name null or blank, or one no role has, answers RoleNotFound.
OfferedPermissionsAsync(principal, roleName, ct) KitOfferedPermissions (Permissions, Outcome, Message) The framework's OfferedPermissionsAsync: every permission the role's group may hold, as an OfferedPermission with whether the role holds it (Held), whether the signed-in user may give it (Grantable) and its top-most offered ancestor (TopId), in the editor's order. Only for a role the signed-in user may edit: one they hold answers NotOwn, one outside their grant RoleOutOfReach. Pass the Name that GetAsync answered.
SetPermissionsAsync(principal, roleName, ids, loadedHeldIds, ct) KitRoleResult The framework's SetPermissionsAsync: the role holds exactly ids among its offer, and an offered permission it holds that ids leaves out is revoked. The framework writes nothing and answers Stale when the offered permissions the role holds now are not loadedHeldIds, and PermissionOutOfReach when the set adds one the signed-in user may not give; removing one needs no grant. Done carries Granted and Revoked (names as stored), Dropped (the ids posted that were not given) and CacheConfirmed; Unchanged, nothing added or removed, carries Dropped. Neither carries a Row: read the role again.
RemoveGrantsOutsideOfferAsync(principal, roleName, ct) KitRoleResult The framework's RemoveGrantsOutsideOfferAsync: removes the role's grants outside its group's offer that the framework judges removable, those HeldPermissionsAsync marks Removable, judged again as it runs. An undeclared menu root and a name the database matches to a declaration allowing the group are outside the offer but kept. Done carries Revoked (names as stored), RemovedMissingIds (the removed grants naming no stored permission), which together count every grant removed, and CacheConfirmed; Unchanged removed nothing, as with no permission groups registered. A role whose group is not a known group answers GroupNotFound, nothing removed. Neither carries a Row: read the role again.
CreateAsync(principal, roleName, roleGroupName, ct) KitRoleResult The framework's CreateAsync: a role named roleName, trimmed, in the stored group roleGroupName names, holding no grant. The framework refuses, writing nothing, with InvalidName (blank, over RoleAdministration.MaxRoleNameLength, 64 characters; holding a slash, a backslash, an invisible character, two spaces in a row or a space other than U+0020; or not in Unicode's composed form, NFC: RoleAdministration.CreateAsync lists every case), GroupNotFound, RoleExists (a role of the name in any letter case), GroupOutOfReach, when the app's rules' MayCreateRoleAsync answers false, which it does unless the app writes it, or InTransaction, when the scope's context has a transaction open or an ambient one is, since the create commits its own. Done carries the new role as its Row, read back by the framework; its CanEdit false means the role is outside the signed-in user's own Grant answer, so someone whose answer holds it must set its permissions. Once Identity's save has returned, or where a cancellation that interrupts it throws as one (SQLite, PostgreSQL) and the role is stored, the framework answers Done; on SQL Server such a cancellation is rethrown though the role may be stored.
DeleteAsync(principal, roleName, ct) KitRoleResult The framework's DeleteAsync: removes the role and every grant it holds. The framework finds the role by its name exactly as stored, so pass the Name that GetAsync answered. It refuses, removing nothing, with RoleInUse when any user holds the role, in any tenant, NotOwn for a role the signed-in user holds, RoleOutOfReach for one outside their grant, RoleNotFound, InTransaction, since the delete commits its own, or IdentityFailed, when Identity refuses the write. Done carries the role as it was as its Row, RemovedPermissionNames (the names its grants named, as stored), RemovedMissingIds (its grants naming no stored permission) and CacheConfirmed. Failed may follow a commit, so read the role again to learn whether it is still stored. Once the role is deleted the framework answers Done even when the request is cancelled. Once a role of the name exists again, whether the app's seed or an administrator creates it, the framework's permission seed gives it, each time the seed runs (an app runs it at start-up), every grant whose permission names it in AllowedRoles and that its group may hold; remove the name from those declarations too. No session is ended: a role created again under the name gives its grants to any open session whose role claims still carry the name, until that session's stamp is next checked; an app that does not end sessions on a role change lets that interval pass before reusing a name.
PermissionsAsync(principal, ct) KitPermissionPage (Rows, GroupsRegistered, Outcome, Message) The framework's PermissionsAsync: every stored permission, enabled or not, as a CataloguedPermission, in the editor's order. Each carries its parent's name and description, the groups its declaration allows (Groups, null for a permission with no declaration, which is offered to no group) and the roles holding a grant of it (Roles, each a CataloguedRole with its id as text and its name). The roles come from one query joining the grants to their roles, read as ListAsync reads the roles, so an app's query filter on the roles applies to both; a grant naming no stored role names none. GroupsRegistered is false when the app registers no permission groups, and then no permission has groups. A permission's name and holders are not secret to an administrator, so every permission is listed, whatever the signed-in user may grant.
GroupNamesAsync(ct) KitRoleNames (Names, Outcome, Message) Every stored role group's name, ordered ordinally, read from the database for the call. The framework has no read of every group, so the seam reads the context's RoleGroups. It names no acting user.

The acting user is read as the users seam reads it (see The acting user). A principal that names no acting user answers ActorRefused and reads nothing. A screen passes the request's HttpContext.User.

A KitRoleRow holds:

  • Id: the role's key as text, a Guid key in its "D" form.
  • Name: the role's name as stored; null for a role stored with none.
  • GroupName and GroupKnown. GroupKnown is false only when the app registers permission groups (AddPermissionGroups) and the role's group is not one of them.
  • HolderCount: the users holding the role in every tenant, never the viewer's scope.
  • GrantCount: every stored grant of the role, those outside its group's offer included.
  • HeldByViewer: whether the signed-in user holds the role.
  • CanEdit: whether the signed-in user may edit the role's permissions. It is as stored when read; a write decides again.

Every answer carries the framework's UserAdministrationOutcome and a Message from KitUserMessages.For. The role outcomes each have their own sentence: InvalidName, GroupNotFound, RoleExists, GroupOutOfReach, PermissionOutOfReach, Stale and RoleInUse. The one exception is RemoveGrantsOutsideOfferAsync's GroupNotFound, which says "Nothing was removed: this role's group is not a declared permission group.", since the shared sentence speaks of a group chosen on the create screen. An outcome no version of the package knows gets one fixed sentence: "The answer is not one this version of the admin package knows; nothing more was done." Nothing throws except the caller's cancellation.

Each write the role screens make is added to the seam by the change that uses it. Every write answers KitRoleResult (Outcome, Message, Row, Granted, Revoked, Dropped, CacheConfirmed, RemovedPermissionNames, RemovedMissingIds). A save from a page whose role changed since it was rendered is the framework's own outcome Stale, never a flag; the removal of the grants outside the offer judges each grant again as it runs, so it has no Stale, and a page that counted grants since removed gets Unchanged. RemovedMissingIds holds the ids of removed grants whose permission is no longer stored, so the names and these ids together count every grant removed.

KitRoleLinks.For(template, name, context) builds every link to a role. The template is the app's address, holding {name} (~/admin/roles/{name}) or {role} (~/admin/users?role={role}). Each token is replaced by the name, url-encoded with Uri.EscapeDataString. The link then goes through KitHref.Local, with the request's path base. On a Razor component page, the route value of the link's segment is the name as stored: a name with a space, ?, #, %, a literal %41 or a slash arrives whole. Pass the route value to GetAsync as it is, and never decode it again: a second decode would open a%41 as the role aA, and fail on 50% off. The link is null when:

  • KitHref refuses it, such as for a name of ..;
  • the template is empty or holds neither token;
  • the name is null or empty;
  • the name holds a literal %2F and a token is in the address's path, before its first ? or #. ASP.NET Core decodes the request's path but its %2F, and the Blazor router decodes that %2F after, so a%2Fb would arrive as a/b, another role's name. In the query or the fragment the name arrives exact.

Auditing role changes

KitRoleAudit holds the audit vocabulary for the role screens. The entity type is Role, the entity id is the role's id, and the subject's display name is the role's name on every event, so a row names a deleted role. The actions are roles.created, roles.permissions-changed, roles.outside-grants-removed and roles.deleted. Each is recorded as a SecurityEvent through IKitAudit (see Recording changes). A change whose row was not written says so in the change's one alert, in Warn, and the audit seam writes its own Error, as on the user page.

The roles seam's log lines

The seam writes these lines under Solhigson.Admin.Roles.KitRoles, in the users seam's shape. A line carries ids only, never a role's name or an exception's message. Before the seam reads a role, the target is roles for a list, role for one role, groups for the group names, new for a create and permissions for the permissions catalogue; then it is the role's id. An id is percent-encoded and cut to 64 characters with a ... marker.

Line Level Text What to do
KitRolesNoActor Warning The roles seam refused {Method}: the principal carries no {ClaimType} claim on a signed-in identity, so it names no acting user; nothing was read. Check that the page requires a signed-in user. If the user is signed in, check that the signed-in identity carries the claim ClaimType names, or set IdentityOptions.ClaimsIdentity.UserIdClaimType to the claim it does carry.
KitRolesFailed Error The roles seam {Method} failed at step {Step}: {ExceptionType}; actor [{ActingUserId}], target [{TargetRoleId}]. Read the step. Read means the role group table could not be read; ActingId means the principal could not be read; Row means a role the framework answered could not be shown; Call means the framework answered done with nothing in it. Check the store, or report the line.

A fault inside the framework's own call is answered Failed by the framework, which writes its own Error under RoleAdministration (see The framework's role lines and counter). The seam writes no second line for it.

The role pages write their audit rows through the user screens' guard, so two of its lines, under Solhigson.Admin.Users.KitUserSeams (see The app's sessions and notices), are the role pages' too: KitUserSeamAuditFailed, an Error, when the app's audit seam throws as a role change is recorded, naming the entity type Role and the role's id, the row not written; and KitUserSeamDoneUnnamed, an Error, when an app's own IKitRoles answers a create done with no role in it, so roles.created is not recorded. A row the audit seam itself fails to write is its own Error, KitAuditFailed or KitAuditUnsaved, and an app whose changes are not recorded gets KitAuditOff once a process (see Recording changes). The four screens write no other line of their own.

The framework's role lines and counter

Each call the seam makes into the framework writes the framework's own lines under RoleAdministration (RoleAdministrationDiagnostics.LoggerCategory), by ids only, never a role's name, a user's name or an email; a create's Information line also names the stored group. Each line names the operation (the counter's method, below), the acting user's id and the role's id, or, before the role is read, roles for a list, role for one role, new for a role not yet created and permissions for the permissions catalogue. An Error is a fault; a Warning an attempt outside reach, or a write refused.

Level Text When What to do
Error Role administration {Operation} refused for actor {ActingUserId} and role {RoleId}: no {Registration} is registered for the user type {UserType} Any call, while the app registers no rules. Register the app's IUserAdministrationRules<TUser, TKey>, the one the user screens need.
Warning Role administration {Operation} refused: actor {ActingUserId} is not a stored, enabled user (role {RoleId}) Any call by a signed-in account that is disabled or no longer stored. The account's session outlived its disable or delete: end its sessions.
Error Role administration {Operation} failed for actor {ActingUserId} and role {RoleId} at step {Step}: {ExceptionType} A step threw: the database, the app's rules (such as step MayCreateRoleAsync), or a delete on an engine other than PostgreSQL, SQL Server or SQLite (step Provider, NotSupportedException). It also follows a save, a removal or a delete whose commit threw, other than by the caller's cancellation, and whose read back found it stored; that write answers as it would have. Read the step and the exception's type; the exception's message is never logged. A write answered Failed may have been stored, and a create's line names the role's id only once the role is known stored, else new: look the role up before doing it again.
Error Role administration {Operation} by actor {ActingUserId} on role {RoleId} refused: the scope's {Context} holds unsaved changes, which the call's save would commit A create, a save, a removal or a delete, while the request's context holds changes of the app's own. Nothing was written. The app's own code left changes unsaved in the request before the screen's call: save or discard them first.
Warning Role administration {Operation} by actor {ActingUserId} refused for role {RoleId}: the app's rules do not let it create a role in the group asked for A create the app's MayCreateRoleAsync refuses. Expected when the rules refuse. When every create is refused, the app has not written MayCreateRoleAsync, which refuses unless written: write it, or leave CanCreate false.
Warning Role administration {Operation} by actor {ActingUserId} on role {RoleId} refused by Identity at step {Step}: {ErrorCodes} A create or a delete Identity refused. Read the codes. ConcurrencyFailure is a write that crossed another: reload and try again. On SQL Server, DuplicateRoleName after a cancelled request may be that request's own create: look the role up.
Warning Role administration {Operation} by actor {ActingUserId} refused: role {RoleId} is outside its grant answer An offer, a save, a removal or a delete of a role outside the viewer's Grant answer. The role page shows no form for such a role, so the post was made by hand, or the viewer's roles changed since the page loaded. Nothing was written.
Warning Role administration {Operation} by actor {ActingUserId} refused: the actor holds role {RoleId} An offer, a save, a removal or a delete of a role the viewer holds. As for a role outside the grant answer.
Warning Role administration {Operation} by actor {ActingUserId} refused for role {RoleId}: {Count} permission ids to add are outside what the actor may give A save adding a permission the viewer may not give. A disabled box posted by hand, or the viewer lost a permission since the page loaded. Nothing was saved.
Warning Role administration {Operation} by actor {ActingUserId} rolled back: role {RoleId} is outside its grant answer once its permissions are written A save that would move the role out of the viewer's reach. Nothing was saved. Expected where the app's rules rank roles by their grants: such a role's permissions are set by an administrator whose Grant answer holds it.
Information Role administration {Operation} by actor {ActingUserId}: role {RoleId} created in group {GroupName} A create done. Nothing.
Information Role administration {Operation} by actor {ActingUserId}: role {RoleId} granted {GrantedCount} and revoked {RevokedCount} permissions; cache confirmed {CacheConfirmed} A save done. CacheConfirmed false: the app's other instances may honour the old permissions until their cache recovers. No value: the app runs no EF Core cache.
Information Role administration {Operation} by actor {ActingUserId}: role {RoleId} revoked {RevokedCount} permissions outside its group's offer; cache confirmed {CacheConfirmed} A removal done; the count holds the grants naming no stored permission too. As for a save.
Information Role administration {Operation} by actor {ActingUserId}: role {RoleId} deleted with {GrantCount} grants; cache confirmed {CacheConfirmed} A delete done. As for a save.

A list, a lookup, a grants read, an offer answered, the permissions catalogue, a role not found, a name not valid, a group not found, a name taken, InTransaction, a stale page, a save or removal that changed nothing, a role in use and the caller's cancellation write no line. The XML documentation of RoleAdministrationDiagnostics lists every line.

A save also writes the permission manager's own Warnings, under Solhigson.Framework.PermissionGroups, when it posts an id the role's group is not offered, such as from a page opened before a declaration changed: "Permission group: {Posted} ({Permission}) was not granted to role {Role} of group {Group}: {Reason}", one for each of the first twenty such ids, then "Permission group: and {Count} more posted ids were not granted to role {Role} of group {Group}". These name the role and the permission by name, and are written only by a manager given a logger factory. The page's alert counts the same ids, "1 permission sent was not given". Nothing was granted for those ids and the rest of the save stands; a line now and then is a page opened before a declaration changed, or a post made by hand.

The page's own check of the manage or create permission, made through IAuthorizationService as the new-role page below makes it, writes the framework's Warning "Permission refused: {Permissions} on {Route} for user {UserId}" under Solhigson.Framework.Web.Authorization.PermissionHandler each time it refuses a signed-in viewer, as a refused [Permission] does. For a viewer without the permission that line is expected: CanManage or CanCreate is then false.

Each call the framework answers adds one to the counter role_administration on the meter Solhigson.Framework.Identity, which the app adds to its metrics pipeline (AddMeter("Solhigson.Framework.Identity")), tagged method (list, get, held_permissions, offered_permissions, set_permissions) and outcome, such as done, actor_refused, no_rules, failed or cancelled; a removal is tagged remove_grants_outside_offer, a create create, a delete delete and a permissions catalogue permissions. A call the seam refuses because the principal names no acting user never reaches the framework, so the counter does not count it: KitRolesNoActor is the count of those. A rise in failed or no_rules: read the framework's line under RoleAdministration. A rise in actor_refused, role_out_of_reach, not_own or permission_out_of_reach: accounts that may not change a role, or not that way, are trying.

The roles screen

KitRolesList lists every stored role through IKitRoles.ListAsync, ordered by group, then name. A component cannot be given a route, so the app writes the page:

@page "/admin/roles"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("roles.view")]

<KitRolesList DetailHref="~/admin/roles/{name}" CreateHref="~/admin/new-role" UsersHref="~/admin/users?role={role}" />
Parameter Required What it does
DetailHref yes The address of a role's page: a path on this site that holds {name}. KitRoleLinks.For builds each row's link. A DetailHref without {name}, or one KitHref.Local refuses with a name in place, throws when the screen renders.
CreateHref no The address of the page that creates a role (see The new-role screen). Without it the screen offers no "New role".
UsersHref no The users list filtered by a role: a path on this site that holds {role}, such as ~/admin/users?role={role}. KitRoleLinks.For builds each link. A UsersHref without {role}, or one KitHref.Local refuses, throws when the screen renders. Without it no row links to its users.

The app must call AddSolhigsonAdmin (see Roles) and register its IUserAdministrationRules. The page must require a signed-in user, since the screen passes the request's HttpContext.User. The screen writes no log line; the seam's lines are in The roles seam's log lines.

The screen has these parts, in this order:

  1. The header, "Roles", with "New role" as its primary link when CreateHref is set and a role exists.
  2. The filter by group, a GET form, so a filtered list has an address a user can keep. Its field is group, and its values are GroupNamesAsync's names. It shows only when a role exists and the names can be read.
  3. The table, with four columns:
    • Role: the name links to the role's page. Under it, in plain muted text, "Yours" marks a role the signed-in user holds, else "View only" marks one they may not change. A role they may change carries nothing.
    • Group: not shown while the filter is set, since every row would show the same group.
    • Users: the number of users holding the role, in every tenant, as plain text. With UsersHref and at least one holder, a separate "See the ones you manage" link sits under it. The users list shows only the users within the viewer's reach, so the number is never the link.
    • Permissions: the role's stored grants.

The two counts sit at the column's end in tabular figures. Users and Permissions are hidden in a narrow table. No role carries a pill: nothing on this screen needs attention. An app has tens of roles, so there is no search and no paging.

A group in the address that is not one of the names, in letter case too, is ignored. When the names cannot be read, the filter does not show and a group in the address is ignored.

A role's page receives the name as its route value; pass it to IKitRoles.GetAsync as it is (see Links to a role). A name holding a literal %2F under a path's {name} shows as text with no link. Its users link, in the query, carries it exact.

Empty states and refusals of the roles screen

With no role, the screen shows "No roles yet", with "New role" as its action when CreateHref is set. With the filter set and no role in the group, it shows "No roles match", with a "Clear filter" link to the list.

When the seam answers NoRules, ActorRefused or Failed, the screen shows a Danger alert, "Roles could not be listed", with the seam's Message. It then shows no filter, no table and no empty state.

The permissions screen

KitPermissionsList lists every stored permission through IKitRoles.PermissionsAsync, in the role editor's order, with the groups that may hold it and the roles that do. It is read-only: a permission is declared by the app's code, so the screen has no action. The app writes the page:

@page "/admin/permissions"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("roles.view")]

<KitPermissionsList RoleHref="~/admin/roles/{name}" />
Parameter Required What it does
RoleHref no The address of a role's page: a path on this site that holds {name}. KitRoleLinks.For builds each role's link. A RoleHref without {name}, or one KitHref.Local refuses with a name in place, throws when the screen renders. Without it every role is its name as text.

The app must call AddSolhigsonAdmin (see Roles) and register its IUserAdministrationRules. The page must require a signed-in user. The screen writes no log line; the seam's lines are in The roles seam's log lines.

The screen has these parts, in this order:

  1. The header, "Permissions". Its line gives the count, "12 permissions". With permission groups registered and a permission offered to no group, the line also holds "3 are offered to no group", a quiet link to that filter, marked the current page (aria-current="page", in the text colour with no underline) while the filter is on.
  2. The filter, a GET form, so a filtered list has an address a user can keep; a permission's name is not personal data. Its fields are search, text matched against the name and the description in any letter case, and, with permission groups registered, no-group, "Offered to no group". Both set, a row matches both. A blank search filters nothing. It shows only when a permission exists.
  3. The table, with four columns:
    • Permission: the description, with the name under it in the mono face; the name alone, in the mono face, when there is no description.
    • Parent: the parent's description, else its name in the mono face. It is empty for no parent, or a parent that is not stored.
    • Groups: the groups the permission's declaration allows, or a Warn pill "Offered to no group" for a permission with no declaration, or one naming no group: no role group may hold it.
    • Roles: the roles holding it, each linking to its page with RoleHref; "None", muted, when no role does.

Parent and Roles are hidden in a narrow table. With permission groups not registered, the Groups column and its filter do not show, and a no-group in the address is ignored. An app with hundreds of permissions gets one long page: the screen does not page, and the filter is the way in. A role name holding a literal %2F shows as text with no link (see Links to a role), as does a role stored with no name, shown by its id.

Empty states and refusals of the permissions screen

With no permission, the screen shows "No permissions yet": permissions appear when the app starts and finds its protected pages. With a filter set and no match, it shows "No permissions match", its line saying which filter found nothing: "No permission holds these words in its name or description." for the search, "Every permission is offered to a group." for "Offered to no group", and "No permission offered to no group holds these words in its name or description." for both. Its link back to the list, as the filter's own, says "Clear search" when the search is the only filter set, else "Clear filters".

When the seam answers NoRules, ActorRefused or Failed, the screen shows a Danger alert, "Permissions could not be listed", with the seam's Message. It then shows no count, no filter, no table and no empty state.

The role page

KitRoleDetail shows one role through IKitRoles.GetAsync. It says first whether the viewer can change the role, and if not, why. The app writes the page, with the role's name in its route:

@page "/admin/roles/{Name}"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("roles.view")]

<KitRoleDetail RoleName="@Name" ListHref="~/admin/roles" UsersHref="~/admin/users?role={role}"
               HistoryHref="~/admin/audit" />

@code {
    [Parameter]
    public string? Name { get; set; }
}
Parameter Required What it does
RoleName yes The name of the role to show, as the route gives it. Never decode it again (see Links to a role).
ListHref yes The address of the roles list, a path on this site. The header's "All roles" link and the not-found page's way back go to it. A ListHref that KitHref.Local refuses throws when the page renders.
UsersHref no The users list filtered by a role, a path on this site holding {role}. Without it the Users section links nowhere. An address with no {role}, or one KitHref.Local refuses, throws when the page renders.
HistoryHref no The audit page's path on this site, alone, with no query or fragment (see The audit screen). With it, the header's line ends with a quiet "History" link to ?type=Role&id=<the role's id>, each value escaped, with no day, so the list reads the role's whole history. "History" reads the role's records by the type Role and its id: the role screens' records, not the rows audit capture may write for the app's role class under that class's name. The page after a delete keeps it, since the role's records are the one place its permissions are still named. A refusal's header has none. Without it no link renders; a value KitHref.Local refuses, or one holding a query or a fragment, throws when the page renders.
CanManage no Whether the viewer holds the permission to change roles. False unless set. With it, a role the viewer may edit gets the permissions form (see Changing a role's permissions), the removal of its grants outside its group's offer (see Removing grants outside the group's offer), and its delete (see Deleting a role). Set it from the app's own check of the manage permission; the framework still decides each change.

The page must not use stream rendering: no @attribute [StreamRendering] on it or on a layout around it. A page that streams sends its status before the lookup returns, so a role not found is answered with 200, not 404. That page shows the header "Roles" and the empty state "Role not found", with "All roles" as its action. As on the user page, ASP.NET Core 10 sends a page that sets 404 with no body; add the app's status code pages.

The app must call AddSolhigsonAdmin (see Users) and register its IUserAdministrationRules. The page must require a signed-in user, since the page passes the request's HttpContext.User.

The page refuses framing, so no other site can lay the form that changes a role's permissions under a decoy. The app must send X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on this page, as on the settings page; the framework and the template send neither, and the component sets no header.

What the page shows depends on the seam's outcome, on the page's own read; after a save, see Changing a role's permissions, and after a delete, Deleting a role:

Outcome Status The page
Done 200 The role, as below.
RoleNotFound 404 No body (see above), on the page's own read; after a save or a delete not done, 200 and its alert above "Role not found".
NoRules, ActorRefused, Failed 200 The header "Roles", "All roles" in its line, and a Danger alert, "The role could not be shown", with the seam's Message. Nothing of the role is shown. After a save or a delete, its alert comes first.

A role found has these parts, in this order:

  1. The header: the role's name as its title; in its line, "Group:" and the role's group, then "All roles", a quiet link back to the list.

  2. One sentence, the first that applies:

    • "You hold this role, so another administrator changes it"
    • "This role is outside what you may grant", when the role is outside the viewer's grant answer
    • "You can view this role; changing it needs the manage permission", when CanManage is false
    • "You can change this role"
  3. A Warn alert, "Changes here leave no audit record", when CanManage is set and the app's IKitAudit does not record (see Recording changes).

  4. Permissions (id permissions). A Warn alert first when the role's group is not a declared permission group: the role can be given nothing until the app declares the group in code. Then what the role holds (IKitRoles.HeldPermissionsAsync), shown to every viewer: read-only, unless the permissions form takes the place of the grants its group offers (see Changing a role's permissions). The grants its group offers come in one block for each top permission, in the editor's order. A block's top, when the role holds it, heads the block; else, when every grant in the block hangs from that top, the top's name heads it, muted. Each grant is labelled by its description, or by its name in the mono face where the description is empty. Under "Not offered to this role's group" follow the grants outside the offer, each with its class in words:

    • "Declared for other groups, not this role's" (OutsideGroup)
    • "Offered to no group: no declaration names it" (NoDeclaration)
    • "This role's group is not declared, so it is offered nothing" (UnknownGroup)
    • "Its permission no longer exists, so it gives no access" (Missing), labelled by the id the grant names
    • "Not offered, for a reason this version of the admin package does not know", for a class a later framework adds

    Where the viewer may change the role, "Remove these 3" follows the list (see Removing grants outside the group's offer), and each grant listed that the removal keeps has a second muted line, "Kept when the others are removed", so the grants without it are the 3.

    A role holding nothing says "This role holds no permission"; one holding only grants outside the offer says "This role holds nothing its group offers". When the role's group is not declared, its alert says why, so the second line does not show and no UnknownGroup grant repeats it; a role holding nothing still says so. When the grants cannot be read, the section shows a Danger alert, "The role's permissions could not be read", with the seam's Message.

  5. Users (id users): "No user holds this role", or "Held by 12 users in all", every tenant counted. When UsersHref is set and a user holds the role, a quiet link, "See the ones you manage", opens the users list filtered by the role, which shows only the users within the viewer's reach. The section ends in a region for its action: "Delete role" where the viewer may delete the role and no user holds it (see Deleting a role), else empty.

The page writes no log line of its own.

Changing a role's permissions

With CanManage set, a role the viewer may edit (CanEdit, and not held by the viewer), and a page address that KitHref.Local accepts, the Permissions section reads IKitRoles.OfferedPermissionsAsync and shows one form, role-permissions, in place of the read-only list of offered grants. The grants outside the offer still follow it. The form posts to the page's own address with #permissions, and holds:

  • the ids of the offered permissions the role holds, as rendered, one hidden loaded field each;
  • "Greyed-out permissions are ones you do not hold; you can give only what you hold.", when any box is disabled;
  • one fieldset for each top permission, in the editor's order. Its legend holds the top's own box; under it is a box for each permission below it, grandchildren included. A permission whose parent is not offered is a top of its own, in a fieldset of its own. Each box posts its permission's id as permission, is labelled as the read-only list labels it, with no id shown, and is ticked when the role holds it;
  • a box disabled, never ticked, when the viewer may not give the permission and the role does not hold it. Held, it can be unticked, and says "You cannot give this permission back once it is removed.";
  • "Save permissions", the primary button.

When the group offers nothing, the section says "This role's group offers no permissions to give; the app declares in code which permissions each group offers" and shows no form. A refused or failed offer shows "The role's permissions could not be read" with the seam's Message, and no form. Without the form, a post naming it gets the framework's 400.

The handler checks the same conditions again. It reads the ticked ids and the loaded ids from the request's form, never bound as a collection. A post carries two values for each permission the role holds, so the form's value count limit, FormOptions.ValueCountLimit (1024 unless the app sets it), bounds the grants one save can carry: a post over it is answered 400 before the page runs, and nothing is saved. That limit is the one an app raises for a role that holds more than about 500 permissions. The handler calls IKitRoles.SetPermissionsAsync for the route's role, by the name GetAsync answered. The outcome is one alert at the top of the section:

Outcome The alert Then
Done "Permissions saved: added 2, removed 1", the names added and removed under it, then each clause that applies: "1 permission sent was not given, as this role's group does not offer it"; that the change reaches this instance at once and the app's other instances when they are told, so until then they may still honour the old permissions (CacheConfirmed false); "this change was not recorded". Success, or Warn when any clause applies. The audit row roles.permissions-changed, its payload the names granted and revoked; then the role, its grants and its offer read again.
Stale Warn: "Permissions changed since this page was opened; nothing was saved. The boxes now show the permissions the role holds." The last sentence shows only when the read after the save renders the boxes. The role read again, so the boxes show the stored grants.
Failed Danger, "Permissions may not have been saved": "The save failed, but it may have been stored before it failed. The boxes now show the permissions the role holds. If it was stored, no record says who changed it." The boxes sentence shows only when the read after the save renders them; the record sentence only when the app's IKitAudit records. A fault after the commit is answered Failed too, and no audit row is written. The role read again, so the boxes show what is stored.
Unchanged Neutral: "This role already holds these permissions; nothing changed". When an id sent was not given, "Nothing changed", then that clause, in Warn. Nothing read again.
Any other Danger, "Permissions not saved", with the seam's Message, such as PermissionOutOfReach for a disabled box posted by hand. The boxes keep the ticks posted and the loaded ids posted; a disabled box stays unticked.

The audit row is written with no cancellation, since the change is not undone. The read after a save never sets 404: a role it does not find, or a read it is refused, shows the save's alert above the empty state or the refusal, so the page still says whether the save landed.

Removing grants outside the group's offer

The permissions form cannot take away a grant its role's group may not hold, since it lists only the offer. Under the form's conditions (CanManage, a role the viewer may edit, a page address KitHref.Local accepts), the Permissions section renders one KitConfirm, role-clear-outside, posting to the page's own address with #permissions. It renders whatever the role holds, so a post from a page another administrator made stale is answered, not refused.

Its opener, "Remove these 3" ("Remove 1 permission" for one, the confirm button's words), a Default button, follows the "Not offered to this role's group" list when the role's group is a declared group and the count is above zero. The count is the grants listed that the framework's removal would take, those HeldPermissionsAsync marks Removable. Two kinds of NoDeclaration grant are listed but kept, so never counted: an undeclared menu root, which the menu needs, and a name the database's collation matches to a declaration allowing the group, which the permission check honours. For a role whose group is not declared, the opener does not show; the section's alert says the fix is the declaration, as for a group that was only renamed. While the opener shows, each grant listed that the removal keeps has a second line under its class, muted: "Kept when the others are removed". The grants without that line are the ones the count names.

The confirm says the permissions are not ones the role's group may hold, that users holding the role lose them at once where they still gave access, and that the audit record keeps their names, or, when the app's IKitAudit does not record, that no record will; for one grant its title, body and button are in the singular. It lists the grants it removes by the list's own labels: the description, else the name in the mono face, else the id the grant names. Its button, the one Danger, reads "Remove 3 permissions". Without the form's conditions no confirm renders, and a post naming it gets the framework's 400.

The handler checks the same conditions again and calls IKitRoles.RemoveGrantsOutsideOfferAsync for the route's role, by the name GetAsync answered. The outcome is one alert at the top of the section:

Outcome The alert Then
Done "Removed 3 permissions this role's group may not hold", the names and missing ids removed under it. The count is the framework's: Revoked and RemovedMissingIds together. Then each clause that applies: that the other instances may still honour the old permissions (CacheConfirmed false); "this change was not recorded". Success, or Warn when a clause applies. The audit row roles.outside-grants-removed, its payload Revoked and RemovedMissingIds; then the role read again.
Unchanged Neutral: "Nothing was removed: this role now holds no permission outside its group's offer that can be removed." The grants changed since the page was opened. The role read again.
Failed Danger, "Permissions may not have been removed": "The removal failed, but it may have been stored before it failed. The list now shows the permissions the role holds. If it was stored, no record says who removed them." The role is read first: the second sentence shows only when that read renders the list of grants outside the offer, and the last only when the app's IKitAudit records. No audit row is written. The role read again.
GroupNotFound Warn, with the seam's Message: "Nothing was removed: this role's group is not a declared permission group." Nothing read again.
Any other Danger, "Permissions not removed", with the seam's Message. Nothing read again.

As after a save, the read after a removal never sets 404, and the audit row is written with no cancellation.

Deleting a role

With CanManage set and a role the viewer may edit (CanEdit, and not held by the viewer), the Users section renders one KitConfirm, role-delete, posting to the page's own address with #users. It renders whether or not a user holds the role, so a delete posted from a page opened before the role gained a user is answered in words.

With no holder, the section's action region holds its opener, "Delete role", a Default button. With holders, the section's line says how to make deleting possible, "Held by 12 users in all; remove the role from them before deleting it" ("from that user" for one), and no opener shows. The count is every holder in every tenant, so the users list may show fewer.

The confirm, titled "Delete Clerk?", says the role and its 3 permissions are removed, that this cannot be undone from here, and that the audit record keeps their names, or, when the app's IKitAudit does not record, that no record will; for one permission it is in the singular, and a role holding none says so. Its button, the one Danger, reads "Delete role". Without CanManage, or for a role the viewer may not edit, no confirm renders, and a post naming it gets the framework's 400.

The handler checks the same conditions again and calls IKitRoles.DeleteAsync for the route's role, by the name GetAsync answered, so a route naming the role in another letter case deletes the stored role. The outcome is one alert:

Outcome The alert Then
Done "Role Clerk deleted", the names and missing ids removed under it, then each clause that applies: that the other instances may still honour the role's permissions (CacheConfirmed false); "this change was not recorded", when the row was not written or the app's IKitAudit does not record. Success, or Warn when a clause applies. The audit row roles.deleted, its payload the role's group, RemovedPermissionNames and RemovedMissingIds. The role is not read again: the page answers 200 with only its header, the role's name as its title and "All roles" in its line, then "History" with a HistoryHref, and the alert.
Failed Danger, chosen by what the read after the delete found. The role, by its id: "Role not deleted", "The delete failed; the role is still stored, as this section shows.", with "You can delete it again." while the opener shows. No role, or a role of another id under the name: "Role no longer stored", "The role is gone, though the delete reported a fault.", then "The role shown here is a new one under its name." when there is one, and "No record says who deleted it." when the app's IKitAudit records. A read refused: "Role may not have been deleted", "The delete failed, but it may have been stored before it failed.", then "If it was stored, no record says who deleted it." when the app's IKitAudit records. No audit row is written. The role read again first; a role no longer found shows the alert above "Role not found", with 200.
Any other Danger, "Role not deleted", with the seam's Message; for RoleInUse: "At least one user holds this role, in this tenant or another, so it was not deleted." The role read again.

Except after Done, the alert sits at the top of the Users section; when the read after the delete finds no role or is refused, it follows the header, above "Role not found" or the refusal. The audit row is written with no cancellation, since the delete is not undone.

A deleted role's name can come back with grants. Once a role of the name exists again, whether the app's seed or an administrator creates it, the framework's permission seed gives it, each time the seed runs (an app runs it at start-up), every grant whose permission names it in AllowedRoles and that its group may hold; remove the name from those declarations too. The delete ends no session: a role created again under the name gives its grants to any open session whose role claims still carry the name, until that session's stamp is next checked. An app that does not end sessions on a role change lets that interval pass before reusing a name.

The new-role screen

KitRoleCreate creates a role through IKitRoles.CreateAsync. The app writes the page; its route is the roles list's CreateHref:

@page "/admin/new-role"
@using Microsoft.AspNetCore.Authorization
@using Solhigson.Framework.Web.Attributes
@using Solhigson.Framework.Web.Authorization
@attribute [Permission("roles.view")]
@inject IAuthorizationService Authorization

@if (canCreate is bool create)
{
    <KitRoleCreate ListHref="~/admin/roles" DetailHref="~/admin/roles/{name}" CanCreate="@create" />
}

@code {
    private bool? canCreate;

    [CascadingParameter]
    private HttpContext? HttpContext { get; set; }

    protected override async Task OnInitializedAsync()
    {
        var decision = await Authorization.AuthorizeAsync(HttpContext!.User, PermissionPolicy.For("roles.create"));
        canCreate = decision.Succeeded;
    }
}

The screen renders once canCreate is decided, so the form a post names is there when the post is handled.

Put the page at an address no role's page can have. A literal segment outranks a route value, so a page at /admin/roles/new would take the place of the page of a role named "new".

The page refuses framing, as the role page does, so no other site can lay the form that creates a role under a decoy: the app sends X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on it, since the component sets no header.

Parameter Required What it does
ListHref Yes The roles list, a path on this site: the header's "All roles" link. A ListHref that KitHref.Local refuses, or none, throws when the screen renders.
DetailHref Yes A role's page, a path on this site holding {name}, as the list's DetailHref. KitRoleLinks.For builds the link to the new role's page. A DetailHref without {name}, or one KitHref.Local refuses with a name in place, throws when the screen renders.
CanCreate No Whether the viewer may create roles. False unless set. Gate it with the app's own permission check, as CanManage on the role page.

The header is "New role", with "All roles" in its line. Without CanCreate, a Danger alert says the viewer may not create roles, the groups are not read, and no form renders. With it, the screen reads every stored group (GroupNamesAsync). A refusal of that read is its Danger alert. With no stored group, an alert says "Roles need a group, and this app has none yet; the app's setup adds them." Neither renders a form. Otherwise the screen holds one form, role-create, which posts to the page's own address, its query kept:

  1. "Name", required, with maxlength the framework's MaxRoleNameLength, 64.
  2. "Group", a required select of every stored group. It opens on an empty "Choose a group" option, so no group is chosen by its place in the list. Under it: "This screen cannot change the group later."
  3. "Create role", a Primary submit.

Where no form renders, a post to it answers the framework's 400 and calls nothing. The select lists every group, not only the ones the viewer may create in: whether they may is the framework's answer, from the app's rules' MayCreateRoleAsync, and its refusal shows beside the group. An app whose rules never allow a create shows a form that always refuses; leave CanCreate false there.

The post handler checks CanCreate and a stored group itself, before any call, so a path to it that is not the form creates nothing. A post of the empty option shows "Choose a group for the role." beside the group, with no call.

A new role holds no permission. After a create done, the screen records roles.created when IKitAudit records, with no cancellation: the row is keyed by the role's id and named by its name, and its payload is GroupName, the group as stored. It then shows one alert above the form, now empty:

The new role The alert
Inside the viewer's own Grant answer (CanEdit), in a declared group Success: "Role Ops created.", with "Set its permissions", a link to the role's page.
Outside that answer Warn: "Role Ops created; an administrator who may grant this role must set its permissions." There is no link, since the viewer may not set them.
In a group the app does not declare (GroupKnown false) Warn: "Role Ops created; its group is not a declared permission group, so it can be given no permission until the app declares the group." Outside the viewer's Grant answer too, it adds "; an administrator who may grant this role must set its permissions" after that. There is no link, since the role page offers it nothing.

When the audit row was not written, the alert adds "this change was not recorded" and is Warn. A name that holds a literal %2F, with {name} in the address's path, gets no link, as on the roles list. A seam of the app's own that answers Done with no Row gets a Warn alert that the role was created and not recorded, since no id keys the row, and the guard writes the Error KitUserSeamDoneUnnamed (see The app's sessions and notices). The framework answers Done for a role it stored even when the request is cancelled after the save, so the row is written.

Each refusal is said in its place:

Outcome Where
InvalidName, RoleExists Beside the name.
GroupNotFound, GroupOutOfReach Beside the group. GroupOutOfReach says "You may not create a role in this group; choose another."
Failed A Danger alert above the form, "The role may have been created": "Something went wrong as it was saved. Look for it in the roles list before you create it again." When the app's IKitAudit records, it adds "If it is there, no record says who created it."
IdentityFailed, InTransaction, NoRules, ActorRefused and any other A Danger alert above the form, "Role not created".

Each keeps the typed name and the chosen group. Nothing is recorded. The screen writes no log line of its own but the guard's above; the seam's lines are in The roles seam's log lines.

The users screen

KitUsersList lists the users the signed-in user may administer, one page at a time, through IKitUsers.SearchAsync. A component cannot be given a route, so the app writes the page:

@page "/admin/users"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("users.view")]

<KitUsersList DetailHref="~/admin/users/{id}" CreateHref="~/admin/users/new" TimeZone="@AppZone" />
Parameter Required What it does
DetailHref yes The address of a user's page: a path on this site that holds {id}. Each row's id replaces {id}, url-encoded, and the link then goes through KitHref.Local. A DetailHref without {id}, or one KitHref.Local refuses with an id in place (another site, //, .., white space), throws when the screen renders. An id that KitHref refuses, such as .., shows the name as text with no link.
CreateHref no The address of the page that creates a user. Without it the screen offers no "New user".
TimeZone no The zone the last sign-in is shown in; UTC when not set. The column's title names the zone's id.

The app must call AddSolhigsonAdmin (see Users) and register its IUserAdministrationRules. The page must require a signed-in user, since the screen passes the request's HttpContext.User. The "not signed in for" filter counts from the registered TimeProvider, else from the system clock.

The page refuses framing, so no other site can lay its search form under a decoy. The app must send X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on this page, as on the settings page; the framework and the template send neither, and the component sets no header.

The user's page receives the id already decoded: an id team/ada is linked as .../team%2Fada, and the route parameter {Id} of @page "/admin/users/{Id}" holds team/ada. Pass it to IKitUsers.GetAsync as it is.

One id cannot reach a route parameter exact: an id holding the text %2F, in either case. ASP.NET Core decodes the request's path except %2F, and the Blazor router decodes %2F after, so team%2Fada, linked as .../team%252Fada, would arrive as team/ada, another user's id. Under a {id} in the path, before its first ? or #, such an id shows its name as text with no link. An app whose ids may hold %2F puts {id} in the query, which is decoded once: DetailHref="~/admin/users/detail?id={id}", read with [SupplyParameterFromQuery(Name = "id")].

The screen has these parts, in this order:

  1. The header, "Users", with "New user" as its primary link when CreateHref is set and the page has rows.
  2. One band: the search first, then the filters.
  3. The table: the user (the name links to its page, the email under it), the roles, the status, two-factor ("On" or nothing) and the last sign-in. Two-factor and the last sign-in are hidden in a narrow table.
  4. The pager. While a search is active it is the search's own "Next page" (see below).

The status column gives colour only to what needs attention. "Enabled" is muted text. "Disabled" is a Neutral pill, and "Locked out" a Warn pill; a user who is both shows "Disabled". "No password" follows as plain text. The last sign-in is a date, with the time for today and yesterday, or "Never".

The filters are a GET form, so a filtered list has an address a user can keep:

Filter Field Values Search
Role role A name from RoleNamesAsync. When the names cannot be read the filter is not offered and a role in the address is ignored. Role
Status status enabled, locked-out, disabled enabled: enabled and not locked out. locked-out: enabled and locked out. disabled: disabled, locked out or not.
Two-factor two-factor on, off. Shown only when TwoFactorAvailable. TwoFactorEnabled
Not signed in for not-signed-in 30, 90, 180 (days) NotSignedInSince: that many days before now, in UTC.
No password no-password true HasPassword false

A value the screen does not offer is ignored. A cursor that does not parse serves the first page.

The search keeps the searched text private

A searched email or name is personal data. The search is a posted form (users-search, id kit-users-search) with the antiforgery token. Its text is never put in a link, a form's action, the address or a redirect, so it stays out of the access log and the browser's history. The post is answered on the page. The form carries the filters in force as hidden fields. While a search is active:

  • The field shows the search, with "Clear search", a link to the list under the same filters.
  • The form carries the search in force as the hidden field searched.
  • "Next page" stands under the table, where the pager does. It is a submit button of the search's form (form="kit-users-search"); its value is the next page's cursor. A posted cursor pages the searched search, so text edited into the field since is not paged; Search searches it.
  • Enter in the field presses the form's own "Search", so it searches and never pages.
  • Applying a filter is a GET, so it ends the search.

A posted search cannot be bookmarked. The screen writes no log line.

Empty states and refusals

With no rows and nothing narrowing the list, the screen shows "No users yet", with "New user" as its action when CreateHref is set. With a search or a filter in force, it shows "No users match", with a link that clears them. With a cursor alone it says "No users on this page.", with a link to the first page.

When the seam answers NoRules, ActorRefused or Failed, the screen shows a Danger alert, "Users could not be listed", with the seam's Message, and no table. The role filter is then not offered.

The user page

KitUserDetail shows one user through IKitUsers.GetAsync. It answers one question first: can this user sign in, and if not, why. The app writes the page, with the user's id in its route:

@page "/admin/users/{Id}"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("users.view")]

<KitUserDetail UserId="@Id" ListHref="~/admin/users" HistoryHref="~/admin/audit" TimeZone="@AppZone" />

@code {
    [Parameter]
    public string? Id { get; set; }
}
Parameter Required What it does
UserId yes The id of the user to show, as the route gives it.
ListHref yes The address of the users list, a path on this site. The header's "All users" link and the not-found page's way back go to it. A ListHref that KitHref.Local refuses (another site, //, .., white space) throws when the page renders.
HistoryHref no The audit page's path on this site, alone, with no query or fragment (see The audit screen). With it, the header's line ends with two quiet links, a gap apart, each value escaped and with no day, so the list reads all time. "History" reads the user's records by their id alone, with no type: ?id=<the user's id>, since audit capture stamps a row of the app's user class with that class's name, such as AppUser, while this page records under User, and an id-only read finds both. With an id that is not unique across types, the history also holds other subjects stored under the same id, each shown with its type. "Activity by this person" reads what they did, by their id as the actor: ?actor=<the user's id>. A refusal's header has neither. Without it no link renders; a value KitHref.Local refuses, or one holding a query or a fragment, throws when the page renders.
TimeZone no The zone the page's times show in; UTC when not set. Each time names the zone's id.
CanManageAccess no Whether the viewer may change the user's access: enable, disable, unlock, reset. False unless set.
CanConfigure no Whether the viewer may change the user's roles and email. False unless set.

The page must not use stream rendering: no @attribute [StreamRendering] on it or on a layout around it. A page that streams sends its status before the lookup returns, so a user not found is answered with 200, not 404. That page shows the header "Users" and the empty state "User not found", with "All users" as its action.

ASP.NET Core 10 sends a page that sets 404 with no body: it leaves the answer to the app's status code pages. Add them, such as app.UseStatusCodePagesWithReExecute("/not-found"), or the browser shows an empty page.

The app must call AddSolhigsonAdmin (see Users) and register its IUserAdministrationRules. The page must require a signed-in user, since the page passes the request's HttpContext.User. Times count from the registered TimeProvider, else from the system clock.

The page refuses framing, so no other site can lay the forms that change a user under a decoy. The app must send X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on this page, as on the settings page; the framework and the template send neither, and the component sets no header.

What the page shows depends on the seam's outcome:

Outcome Status The page
Done 200 The user, as below.
NotFound 404 No body (see above). A user who does not exist and one outside the viewer's reach give the same answer, so an id cannot be probed.
NoRules, ActorRefused, Failed 200 The header "Users", "All users" in its line, and a Danger alert, "The user could not be shown", with the seam's Message. Nothing of the user is shown.

A user found has these parts, in this order:

  1. The header: the user's name as its title; in its line, the email when the name is not the email, then "All users", a quiet link back to the list, then, with HistoryHref, "History" and "Activity by this person".

  2. A Warn alert, "Changes here leave no audit record", when CanManageAccess or CanConfigure is set and the app's IKitAudit does not record (see Recording changes).

  3. A Neutral alert, "This is your own account", when the user is the viewer: "Another administrator makes changes to it; you cannot change your own access here."

  4. Access (id access). One sentence, the first that applies:

    • "Disabled: cannot sign in until someone enables the account"
    • "Locked out until 17 Nov 2026, 14:20 UTC", or "Locked out until unlocked" for Identity's permanent lock (an end after the year 9000)
    • "No password set: cannot sign in until they choose one"
    • "Can sign in"

    Under it, the facts: the last sign-in (a date, with the time for today and yesterday, or "Never"), the password ("Set" or "Not set") and the email ("Confirmed", "Not confirmed" or "None"). Under the facts, when another account holds the user's email (KitUserRow.EmailShared), a Warn alert: "Another account holds this email, so a password reset they ask for sends no link. Give one of the two accounts a different email to lift this." Only the user's own forgot-password request is refused: the framework's reset request sends no link to an address two accounts hold, while the forgot-password page still says a reset link is on its way, so without the alert only the framework's shared-address Warning says why none arrives. A link an administrator sends from this page ("Send password link") still reaches the address with the package's default notices, or an app's own that issues the link by id (IssuePasswordResetAsync). The other account is any stored user, one outside the viewer's reach included; the page names neither the account nor its reach. Changing one of the two addresses lifts it; disabling one account does not, since the reset request counts a disabled account as a holder too. Where the viewer may change the email, the section ends in "Change email", folded. Where the page offers no "Change email" for the address to change (the app has not set AllowEmailChange, the viewer may not configure, the account is the viewer's own, or the address to change is the other account's, outside the viewer's reach), it is changed on the app's own pages.

  5. Two-factor (id two-factor), only when TwoFactorAvailable: "On." or "Off."

  6. Roles (id roles): the role names, or "No role". Where the viewer may change them, the roles form takes the list's place.

Access ends in the email change, when the app allows it and the viewer may make it (see Changing a user's email). Two-factor ends in its reset, when the viewer may reset (see Resetting two-factor). Roles is the roles form when the viewer may change them (see Changing a user's roles). The page shows none of the app's own profile fields; an app adds its own section beside the component. The page writes no log line of its own; the app's seams and the audit seam write theirs (see The app's sessions and notices).

Enabling and disabling a user

The access section ends in the form user-access when all of these hold:

  • CanManageAccess is set.
  • The user was found (Done).
  • The user is not the viewer.

The form posts to the page's own address, its query kept, with #access, so the answer opens at the section. Its first button depends on the user's state:

  • A disabled user: "Enable", a submit (op=enable).
  • An enabled user: "Disable", which opens the confirm user-disable.

Two more buttons follow when they apply (see Ending a lockout and sending a password link).

Both buttons are the Default variant. The confirm's own button, "Disable user", is its one Danger button; no button outside a confirm is Danger. The confirm's text depends on the app's IKitSessions.Ends:

  • True: "They are signed out at once, and cannot sign in until someone enables the account."
  • False: "They cannot sign in until someone enables the account. A session they have open ends within 30 minutes."

How long the session lasts comes from two settings the app configured: Identity's SecurityStampValidatorOptions.ValidationInterval, and the application cookie's options (IdentityConstants.ApplicationScheme). The validator checks a session once the interval has passed since its cookie was issued. The page says the first of these that applies, a span in words ("1 hour 30 minutes"):

Settings The session
An interval of zero or less: Identity validates every request "ends at its next request"
A sliding cookie, the interval more than half its lifetime "is not cut short: it lasts until it expires or they sign out"
A sliding cookie, the interval at most half its lifetime ends within the interval
A cookie that does not slide, the interval at least its lifetime ends within the lifetime, when the cookie expires
A cookie that does not slide, the interval shorter ends within the interval
Cookie options that cannot be read, or name no lifetime ends within the interval

A sliding cookie is reissued once more than half its lifetime has passed. So with Identity's defaults, 30 minutes and a 14-day sliding cookie, the session ends within 30 minutes. With a 7-day interval it ends within 7 days, since the request that reissues it is past the interval too. With an 8-day interval a session in use is reissued before the check comes due, so it is not cut short. A session left idle past the interval is still checked at its next request.

A span of more than 365 days, TimeSpan.MaxValue included, bounds no real session, so it too "is not cut short".

Opening the confirm needs the kit's script, as every confirm does.

Where no form renders, a post to either form answers the framework's 400, and nothing is called. This holds for a viewer without CanManageAccess, for the viewer's own account and for a user out of reach. Each handler acts on the route's UserId alone, never on an id the post carries. The seam's SetEnabledAsync checks reach again.

After a change done (Done), the page does these steps in order:

  1. It calls IKitSessions.EndAsync when the result says EndSessions.
  2. It calls IKitUserNotices.PasswordLinkNeededAsync when the result says NeedsPasswordLink.
  3. It records users.enabled or users.disabled when IKitAudit records. The payload is Enabled, SessionsEnded and PasswordLinkSent.

Each call goes with no cancellation, since the change is not undone. The page then reads the user again and shows one alert at the top of the access section. The alert says what was done, then each clause that applies:

Clause When Tone
"Ada Okoro is enabled" or "Ada Okoro is disabled" Always. Success
"and signed out" The app ended the sessions. Success
"their open session lasts up to 30 minutes" A disable whose sessions the app did not end. Warn
"they have no password; send them a password link" An enable of a user with no password, and the app sent no link. Warn
"they have no password, and were sent a link to set one" The app sent the link. Success
"this change was not recorded" The audit row was not written. The audit seam writes an Error with the action and the user's id. Warn

The alert takes the tone of its most serious clause, for example "Ada Okoro is disabled; their open session lasts up to 30 minutes; this change was not recorded." in Warn. When IKitAudit does not record at all, no row is asked for and the alert adds no clause, since the page's own Warn alert says so.

Other outcomes show other alerts:

  • Unchanged: a Neutral note, such as "Ada Okoro is already disabled; nothing changed." A disable answered Unchanged still calls EndAsync. When it ends the sessions, the note says "and now signed out"; when it does not, the note adds how long the open session lasts. The note stays Neutral, and nothing is recorded.
  • Any refusal: a Danger alert, "Ada Okoro was not disabled", with the seam's Message.
  • An op the form never renders: a Warn alert, and nothing changes.

The user-access form shows two more buttons, under the same conditions as "Enable". Each is a submit of the Default variant, after "Enable" or "Disable":

Button op Shown while
"End lockout" unlock The user is locked out (LockedOutUntil is set), until a time or until unlocked. A lockout by wrong authenticator codes is Identity's lockout end, so the one button ends both kinds.
"Send password link" password-link The user has no password (HasPassword is false). Such a user cannot sign in, and the link sent when the account was made or enabled can be lost.

"End lockout" calls IKitUsers.UnlockAsync for the route's UserId, then reads the user again. It shows one alert at the top of the access section:

Outcome Alert Recorded
Done Success: "Lockout ended for Ada Okoro." users.unlocked, its payload LockedOutUntil, the lockout's end as the page read it.
Done, the row not written Warn: "Lockout ended for Ada Okoro; this change was not recorded." The audit seam writes an Error.
Unchanged Neutral: "Ada Okoro was not locked out; nothing changed." Another administrator ended it first. Nothing.
A refusal Danger, titled "Lockout not ended for Ada Okoro", with the seam's Message. Nothing.

"Send password link" calls IKitUserNotices.PasswordLinkNeededAsync for the user's id, as the lookup for the route answered it, never an id the post carries. It writes nothing to the user, so the page does not read the user again:

Answer Alert Recorded
Sent Success: "Password link sent to Ada Okoro." users.password-link-sent, with an empty payload.
Sent, the row not written Warn: "Password link sent to Ada Okoro; this was not recorded." The audit seam writes an Error.
Not sent: the app registers neither IKitUserNotices nor IKitAccountMail Warn: "No password link was sent: this app sends none from here. Ada Okoro has no password and cannot sign in until someone sends them a link to set one." Nothing, since nothing was sent.
Not sent: the app's seam answered false, threw, or could not be resolved Warn: "No password link was sent: the app could not send it; its log says why. Ada Okoro has no password and cannot sign in until someone sends them a link to set one." Nothing. A seam that threw writes the guard's Error.
The user has a password by the time the post arrives Neutral: "Ada Okoro has a password now; no link was sent." The seam is not called. Nothing.

An app that registers no IKitUserNotices but an IKitAccountMail sends the reset link the forgot-password page sends: the framework issues a token for the user, and the app's mail seam mails the link. A link not sent then is the app's: no PublicOrigin, a user with no address, or a mail seam that answered false or threw, each with its line. An app that registers neither shows the button and the not-sent alert every time. The alert says why, and the default seam writes its Warning once a process. When IKitAudit does not record at all, neither action asks for a row, and the page's own Warn alert says changes leave no record.

Where no form renders, a post with either op answers the framework's 400 and calls nothing, as for "Enable". An op the form never renders, such as Unlock or password_link, is a Warn alert, and nothing is called.

Resetting two-factor

An administrator resets the two-factor of a user who lost their authenticator. The host needs these, as the framework's AddSolhigsonTwoFactor and TwoFactorManager documentation describes them:

  • AddSolhigsonTwoFactor on the identity registration. Without it, TwoFactorAvailable is false and no confirm renders.
  • Identity's EF UserStore, saving through the app's context with AutoSaveChanges on. Without it, every reset answers Failed, with an Error at step Reset.
  • The counter store AddSolhigsonTwoFactor registers: the framework's Redis store, unless the app registers its own ICounterStore. Building the Redis store needs an IHostEnvironment, which every ASP.NET Core and generic host has. A hand-built container without one fails every reset before anything is written, with the framework's Error at its step TwoFactorCodeCap. With no Redis reachable, a reset still lands. The store answers unavailable and writes its outage's start line once, and the user's code counters are left to run out by themselves.

The two-factor section ends in the confirm user-two-factor-reset when all of these hold:

  • CanManageAccess is set.
  • TwoFactorAvailable is true.
  • The user was found (Done).
  • The user is not the viewer.

The confirm renders whatever the user's state. "Reset two-factor", a Default button, opens it only while the user is enrolled. The confirm posts to the page's own address, its query kept, with #two-factor. Its title is "Reset two-factor for Ada Okoro?", and its own button, "Reset two-factor", is its Danger. Its text depends on the password and on the app's IKitSessions.Ends:

The user Ends The confirm says
Has a password True "Their authenticator and their password are removed, and they are signed out at once. They set a new password from a password link, then enrol again."
Has no password True "Their authenticator is removed, and they are signed out at once. They set a password from a password link, then enrol again."
Has a password False "Their authenticator and their password are removed. They set a new password from a password link, then enrol again. A session they have open ends within 30 minutes."
Has no password False "Their authenticator is removed. They set a password from a password link, then enrol again. A session they have open ends within 30 minutes."

The framework removes the password with the factor, and ends any lockout. How long the session lasts is worked out as for a disable.

The page calls IKitUsers.ResetTwoFactorAsync for the route's UserId, never an id the post carries. The seam checks reach again, and the acting user's id comes from the principal. After a reset done (Done), the page does these steps in order, each with no cancellation:

  1. It calls IKitSessions.EndAsync, since the reset rotated the security stamp.
  2. It calls IKitUserNotices.TwoFactorResetAsync with whether a password was removed. The notice carries the link to set a password, then to enrol again.
  3. It records users.two-factor-reset when IKitAudit records. The payload is PasswordRemoved, SessionsEnded and PasswordLinkSent.

The page then reads the user again and shows one alert at the top of the two-factor section, above its heading. The alert says "Two-factor reset for Ada Okoro", then each clause that applies, in the tone of the most serious:

Clause When Tone
"they are signed out" The app ended the sessions. Success
"their open session lasts up to 30 minutes" The app did not end them. Warn
"they have no password, and were sent a link to set one" The app sent the notice. Success
"they have no password; send them a password link" The app sent none: it registers no IKitUserNotices, or its seam answered false or threw. The user cannot sign in until someone sends the link; "Send password link" on the access section does. Warn
"this change was not recorded" The audit row was not written. Warn

For example: "Two-factor reset for Ada Okoro; they are signed out; they have no password, and were sent a link to set one." in Success.

Every other outcome shows its sentence in one Danger alert at the top of the section, titled "Two-factor not reset for Ada Okoro". Nothing follows: no session ends, no notice is sent and nothing is recorded.

Outcome When
Unchanged (NotEnrolled) The user is not enrolled, such as when another administrator reset them first.
Unchanged (TwoFactorOff) The framework's two-factor is switched off.
NotOwn The user is the acting user's own account, by any form of its id.
A reach refusal, such as NotFound The user is out of reach or gone.
Failed The reset could not be written; the framework's log says why.

Where no confirm renders, a post to it answers the framework's 400 and calls nothing. This holds without CanManageAccess, on a host with no two-factor, for the viewer's own account and for a user out of reach.

Changing a user's roles

The roles section shows the form user-roles in place of the role list when all of these hold:

  • CanConfigure is set.
  • The user was found (Done).
  • The user is not the viewer.

The form posts to the page's own address, its query kept, with #roles. It holds these parts, in order:

  1. One hidden loaded field for each role the user held when the page was rendered.
  2. One fieldset whose legend is "Roles". The legend is for a screen reader; on screen, the section's heading names the group. The fieldset holds a checkbox named role for each role IKitUsers.GrantableRolesAsync offers and each role the user holds, ordered by name, ticked when held.
  3. When RoleChangeDisables is on, the user is enabled and the fieldset holds at least one box, the line "Saving a change disables Ada Okoro until someone enables the account.", in the text colour at the body size, not an alert, directly above the button, which it describes (aria-describedby).
  4. When the fieldset holds at least one box, "Save roles", a submit of the Default variant.

The form offers only what the framework accepts. A grant needs the acting user's grant answer; a revoke needs the reach alone. So a role the user holds that the viewer may not grant is a box like any other, and it can be unticked. Its note says "You cannot grant this role back once it is removed." When GrantableRolesAsync is refused, its sentence shows under the legend, and only the roles held are boxes. A user who holds no role, shown to a viewer who may grant none, shows "There is no role you may grant, and the user holds none." and no button.

The option is the framework's UserAdministrationOptions.RoleChangeDisables, true unless the app sets it:

services.Configure<UserAdministrationOptions>(options => options.RoleChangeDisables = false);

With it on, a role change also disables the user, until anyone who reaches the user enables them. The page reads it through IOptions<UserAdministrationOptions>, as the framework does. The framework registers none, so the default applies until the app configures it.

The page calls IKitUsers.SetRolesAsync for the route's UserId, never an id the post carries, with the boxes ticked and the loaded set as posted. After a change done (Done), the page does these steps in order, each with no cancellation:

  1. It calls IKitSessions.EndAsync, since the change rotated the security stamp.
  2. It calls IKitUserNotices.AccessChangedAsync with the names granted and revoked and whether the user was disabled.
  3. It records users.roles-changed when IKitAudit records. The payload is Granted, Revoked, Disabled, SessionsEnded and NoticeSent.

The page then reads the user again and shows one alert at the top of the roles section. The alert says "Roles saved: added Admin, removed Auditor", naming only what applies, then each clause that applies, in the tone of the most serious:

Clause When Tone
". Ada Okoro is disabled until someone enables the account" The change disabled the user, who stays disabled until someone acts. Warn
"they are signed out" The app ended the sessions. Success
"their open session lasts up to 30 minutes" The app did not end them. Warn
"no notice was sent: this app sends none from here" The app registers no IKitUserNotices. Warn
"no notice was sent: the app could not send it, and its log says why" The app's seam answered false or threw. Warn
"this change was not recorded" The audit row was not written. Warn

For example: "Roles saved: added Admin, removed Auditor. Ada Okoro is disabled until someone enables the account; they are signed out." in Warn. With RoleChangeDisables off and every step followed, the alert is Success: "Roles saved: added Admin, removed Auditor; they are signed out."

Other outcomes:

Outcome The page
Stale A Warn alert at the top of the section: "Roles changed since this page was opened; nothing was saved. The boxes now show the roles Ada Okoro holds." The page reads the user again, so the boxes and the loaded set are as stored.
Unchanged A Neutral note: "Ada Okoro already holds these roles; nothing changed."
Any other Its sentence under the legend, with the boxes ticked as posted and the loaded set as posted. Such as EmptyRoleSet for no box ticked, RoleOutOfReach for a role posted by hand that the viewer may not grant, RoleNotFound, a reach refusal, Failed, and RoleSetRefused, which shows the app's own reason.

Nothing follows a refusal: no session ends, no notice is sent and nothing is recorded. Where no form renders, a post to it answers the framework's 400 and calls nothing. This holds without CanConfigure, for the viewer's own account and for a user out of reach.

Changing a user's email

An administrator changes another user's email here. A user's change of their own email is the app's own flow. The change is off unless the app turns it on, with the framework's UserAdministrationOptions.AllowEmailChange:

services.Configure<UserAdministrationOptions>(options => options.AllowEmailChange = true);

The page and the framework read it through IOptions<UserAdministrationOptions>, so one line turns on both. The access section ends in a native details whose summary is "Change email" when all of these hold:

  • The option is on.
  • CanConfigure is set: an email change is gated with the roles.
  • The user was found (Done).
  • The user is not the viewer.

The details is folded until the administrator opens it. It holds the form user-email, which posts to the page's own address, its query kept, with #access. The form holds one email field, "New email address", empty, then "Change email", a submit of the Default variant. The field's hint says the new address starts unconfirmed. When IKitUsers.SignInNeedsConfirmedEmail is true, the line "They cannot sign in until the app's own flow confirms the new address." sits directly above the button, which it describes (aria-describedby), in the text colour, not an alert.

The page calls IKitUsers.ChangeEmailAsync for the route's UserId, never an id the post carries, with the address as typed. The framework trims it, refuses it or stores it, unconfirmed, and rotates the security stamp. When the user's user name was their address, the user name follows the new address, so they sign in with it. The framework also refuses a user who holds a role the viewer may not grant: reach alone is not enough to move a higher user's address. After a change done (Done), the page does these steps in order, each with no cancellation:

  1. It calls IKitSessions.EndAsync, since the change rotated the security stamp.
  2. It calls IKitUserNotices.EmailChangedAsync with the previous address, so the user hears of it where they read their mail before. A user who had no address is sent no notice, and the alert asks nothing about one.
  3. It records users.email-changed when IKitAudit records. The payload is PreviousEmail, SessionsEnded and NoticeSent. It never holds the new address, which is on the user's row.

The page then reads the user again, folds the details and shows one alert at the top of the access section. The alert says "Email changed for Ada Okoro", by the name read before the change, then each clause that applies, in the tone of the most serious:

Clause When Tone
"they are signed out" The app ended the sessions. Success
"their open session lasts up to 30 minutes" The app did not end them. Warn
"no notice was sent: this app sends none from here; tell them at both addresses" The user had an address, and the app registers no IKitUserNotices. Warn
"no notice was sent: the app could not send it, and its log says why; tell them at both addresses" The user had an address, and the app's seam answered false or threw. Warn
"the new address is not confirmed" Always. Success
"the new address is not confirmed, so they cannot sign in until it is" In place of the clause above, when SignInNeedsConfirmedEmail is true. Warn
"this change was not recorded" The audit row was not written. Warn

For example: "Email changed for Ada Okoro; they are signed out; the new address is not confirmed." in Success.

Other outcomes:

Outcome The page
Unchanged A Neutral note at the top of the section: "Ada Okoro already has this address; nothing changed."
Failed A Danger alert at the top of the section, "Email not changed for Ada Okoro", with the seam's sentence.
Any other Its sentence under the field. Such as InvalidEmail, EmailInUse, RoleOutOfReach ("You may not change this user's email: they hold a role you may not grant."), IdentityFailed, EmailChangeOff and a reach refusal.

Each outcome but Done keeps the address as typed in the field and the details open. Nothing follows: no session ends, no notice is sent and nothing is recorded. Where no form renders, a post to it answers the framework's 400 and calls nothing. This holds with the option off, without CanConfigure, for the viewer's own account and for a user out of reach. Neither address goes in a log line the package writes.

With the option on, one administrator who holds both CanConfigure and CanManageAccess can take over any account within reach whose roles they may grant: move its address to one they read, then send a password link to a user with no password, or reset an enrolled user's two-factor, which removes the password, so the link the app sends reaches the new address. Where the app's own sign-in sends a password reset to an address it has not confirmed, the address change alone is enough for a user without two-factor, needing CanConfigure only; a user enrolled in two-factor still needs the second factor after the reset while the app's two-factor is on, and CanManageAccess as well removes that limit, since the two-factor reset removes the factor. Only keeping AllowEmailChange off guards that path. Giving the two permissions to different roles does not, and neither does a reset that asks for a confirmed address: an email change leaves the new address unconfirmed, but whoever reads it can confirm it through a confirmation the app sends without the user's own sign-in (Identity's default UI has an anonymous ResendEmailConfirmation page), or through an external sign-in that matches accounts by address. Where the app's sign-in sends no password reset by email and no external sign-in matches accounts by address, an app guards by giving the two permissions to different roles. Registering IKitUserNotices tells the previous address, after the fact; the audit row users.email-changed keeps it.

The app's sessions and notices

The package defines two seams an app registers for the user screens. AddSolhigsonAdmin registers neither, so register yours before or after it:

services.AddScoped<IKitSessions, AppSessions>();
services.AddScoped<IKitUserNotices, AppUserNotices>();
Seam Member What it does
IKitSessions Ends True when EndAsync signs a user out at once, such as by revoking the user's refresh tokens or server-side sessions. The confirm reads it.
IKitSessions EndAsync(userId, ct) Ends the user's sessions. Answers true when they were ended.
IKitUserNotices PasswordLinkNeededAsync(userId, ct) Sends a user with no password a link to set one. Answers true when it was sent. An enable of such a user, "Send password link" and "Create user" call it. With no IKitUserNotices of the app's, the default sends the package's reset link through IKitAccountMail when the app registers one (see The reset link and the account mail).
IKitUserNotices AccessChangedAsync(userId, granted, revoked, disabled, ct) Tells the user their roles changed, by name, and whether the change disabled them. Answers true when it was sent. "Save roles" calls it.
IKitUserNotices TwoFactorResetAsync(userId, hadPassword, ct) Tells the user their two-factor was reset, with a link to set a password, then to enrol again. Answers true when it was sent. "Reset two-factor" calls it.
IKitUserNotices EmailChangedAsync(userId, previousEmail, ct) Tells the user their email changed, at the previous address. Answers true when it was sent. "Change email" calls it.

Without a registration, the package's default answers false: no session ends at once, and no notice is sent. The screens then say what the administrator must do. The one exception is PasswordLinkNeededAsync, which an app with IKitAccountMail and no IKitUserNotices gets sent. Each screen calls it only once the framework has answered the administrator's reach on the user, so the link goes to no user the administrator cannot administer. The administrator never sees the link or the token. An app that registered its own IKitUserNotices sees no change: its seam is called, and the mail seam is not. A seam that throws is caught and counts as false. The page calls each with no cancellation.

The guard writes these lines under Solhigson.Admin.Users.KitUserSeams. A line carries the user's id only, shaped as the users seam's lines shape it, never an email or an exception's message; an audit write's line carries the event's entity type and id instead, since the role page writes its rows through the same guard, and the line of a change done that names nothing carries no id at all:

Line Level Text What to do
KitUserSeamDefault Warning {Seam} is not registered, so the package's default answers false: {Consequence} Register the app's own. Logged once per process. Register the app's own seam, or accept what the line says follows. For IKitAccountMail, no user who asks for a reset link gets one.
KitUserSeamFailed Error The app's {Seam}.{Member} threw {ExceptionType} for {Action} on user [{UserId}]; it counts as false. Read the app's own log for the exception.
KitUserSeamAuditFailed Error The app's {Seam}.{Member} threw {ExceptionType} for {Action} on {EntityType} [{EntityId}]; it counts as false. The app's audit seam broke its contract, which forbids a throw. Read the app's own log for the exception; the row was not written.
KitUserSeamDoneUnnamed Error The app's {Seam}.{Member} answered Done with no {EntityType} in it, so {Action} was not recorded. The app's own seam, registered in place of the package's, answered a change done without naming what it changed, so the screen has no id to key the audit row by. Fix the seam to answer the row; find the change in the list meanwhile.

The new-user screen

KitUserCreate creates a user through IKitUsers.CreateAsync. The app writes the page; its route is the users list's CreateHref:

@page "/admin/users/new"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("users.view")]

<KitUserCreate ListHref="~/admin/users" DetailHref="~/admin/users/{id}" CanCreate="@CanCreate" />
Parameter Required What it does
ListHref Yes The users list, a path on this site: the header's "All users" link.
DetailHref Yes A user's page, a path on this site holding {id}, as the list's DetailHref. The new user's id replaces it, url-encoded, before the link goes through KitHref.Local.
CanCreate No Whether the viewer may create users. False unless set. Gate it with the app's own permission check, as CanConfigure on the user page.
ExtraFields No The app's own fields, a RenderFragment<IFormCollection>, rendered after the roles. It is given the app's fields as the form posted them, so it writes back what was typed after a refusal; the form is empty on a first view and after a create.

The header is "New user", with "All users" in its line. Without CanCreate, a Danger alert says the viewer may not create users, and no form renders. With it, the screen reads the roles the viewer may grant (GrantableRolesAsync). A refusal of that read is its Danger alert. No role to grant is an alert that a user must hold one. Neither renders a form. Otherwise the screen holds one form, user-create, which posts to the page's own address, its query kept:

  1. "Email address", required.
  2. "Phone number", a text field with the telephone keypad.
  3. The fieldset "Roles", its legend carrying the required mark, with a box for each role the viewer may grant.
  4. ExtraFields.
  5. "No password is set here; the user chooses one from a password link."
  6. "The user starts disabled, and cannot sign in until someone enables the account.", when the framework's UserAdministrationOptions.NewUserStartsDisabled is on. It is on unless the app turns it off.
  7. "Create user", a Primary submit, which the two lines above describe.

Where no form renders, a post to it answers the framework's 400 and calls nothing.

The page refuses framing, so no other site can lay the form that creates a user under a decoy. The app must send X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on this page, as on the settings page; the framework and the template send neither, and the component sets no header.

The names email, phone, roles and any name starting with _ are the form's own. Name an app field otherwise: a field so named is never given to the app. The framework creates the user with no password and in one transaction with its roles, then reads it back through the rules' Scope. A new user outside the acting user's reach is rolled back and answers NotFound, with its own sentence: "The new user would be outside your reach, so it was not created. If users here belong to a tenant, the app's user factory must set it."

After a create done, the screen does these steps in order, each with no cancellation:

  1. It calls IKitUserNotices.PasswordLinkNeededAsync for the new id.
  2. It records users.created when IKitAudit records. The payload is Roles (the names given, as stored), Disabled and PasswordLinkSent. It never holds the address or the phone, which are on the user's row.

The screen then shows one alert above the form, now empty: "User created", then each clause that applies, in the tone of the most serious, then "Open" and the address, a link to the new user's page:

Clause When Tone
"they are disabled until someone enables the account" The framework started the user disabled. Warn
"they have no password, and were sent a link to set one" The app's seam sent the link. Success
"they have no password, and no link was sent: this app sends none from here; send them a password link" The app registers no IKitUserNotices. Warn
"they have no password, and no link was sent: the app could not send it, and its log says why; send them a password link" The app's seam answered false or threw. Warn
"this change was not recorded" The audit row was not written. Warn

For example: "User created; they have no password, and were sent a link to set one." in Success. An id that holds a literal %2F, with {id} in the address's path, gets no link, as on the users list, since routing would read it as another id: the alert then shows the address alone.

The post handler checks CanCreate and a role to grant itself, before any call, so a path to it that is not the form creates nothing.

Each refusal is said in its place:

Outcome Where
InvalidEmail, EmailInUse Beside the email field.
EmptyRoleSet, RoleNotFound, RoleOutOfReach, RoleSetRefused Under the roles legend, which the fieldset's description names.
The factory's refusal, NotFound, IdentityFailed, NoRules, ActorRefused, Failed A Danger alert above the form, "User not created".

Each keeps the address, the phone and the ticks as posted, and the app's fields through ExtraFields. No link is asked for and nothing is recorded. Neither the address nor the phone goes in a log line the package writes.

Building the new user

The framework creates the user object it is given. IKitUserFactory<TUser> builds it:

public sealed class TenantUserFactory(ITenantContext tenants) : IKitUserFactory<AppUser>
{
    public ValueTask<KitUserBuild<AppUser>> CreateAsync(string email, string? phone, IFormCollection form, CancellationToken ct) =>
        ValueTask.FromResult(form["tenant"] is { Count: > 0 } tenant && tenants.Allows(tenant.ToString())
            ? KitUserBuild.Of(new AppUser(tenant.ToString()) { Email = email, UserName = email, PhoneNumber = phone })
            : KitUserBuild.Refused<AppUser>("Choose the tenant the user belongs to."));
}

services.AddScoped<IKitUserFactory<AppUser>, TenantUserFactory>();

It is given the address and the phone, trimmed (the phone null when blank), and the app's fields, never the form's own. It answers the user, built and not saved, or a sentence the screen shows above the form. The users seam resolves it from the request's services on each create. AddSolhigsonAdmin registers none.

Without one, the package's default builds the user through its public parameterless constructor. It sets the address as the email and the user name, and the phone as the phone number. It reads none of the app's fields. A user type with no public parameterless constructor is refused, with a sentence naming IKitUserFactory<TUser>.

Whichever builds the user, a string id left null or empty is given a new sequential Guid before the create, so a factory need not set one.

An app whose rules scope users by tenant, or by any field of the user's, must register a factory that sets that field. Without it, every new user is outside the acting user's reach, and every create answers NotFound.

The framework then sets the email, trimmed, whether the user is enabled, and clears the password, the lockout, two-factor and a password change asked for. What the factory sets there does not stand. A factory that throws, or answers no build, is Failed, with one Error at step Build.

KitGallery shows every kit component, in every variant and state, on fixed example data, so a look is judged in both themes (its theme choices switch the page) before a screen uses it. Each section is headed by the component's name and the component tokens the manifest names for it; KitShell is shown once, in an inert frame, so its landmarks and skip link never stand beside the page's own. The KitAuthFrame examples are in inert frames too, so their <h1>s are out of the page's outline. The gallery has no shell of its own, so the app's layout wraps it as any page, and its title is the page's one <h1> outside those frames. An app cannot be given a route by a component, so the app writes the page that hosts it:

@page "/kit-gallery"
@using Solhigson.Framework.Web.Attributes
@attribute [Permission("kit.gallery")]

<KitGallery />

Add it only in development, or behind a permission, as the sample's [Permission] puts it: it shows nothing secret, but it has no purpose in production. An app that wants it in development alone writes that condition in the page in place of the attribute: @inject IWebHostEnvironment Environment, then @if (Environment.IsDevelopment()) { <KitGallery /> }. Every example link and post on it targets the page itself.

KitHref is the one way a kit component takes a url. Blazor encodes an attribute's value but refuses nothing, so javascript:alert(1) or //elsewhere.example written into an href runs or leaves the site. KitHref.Local(value, pathBase) answers a path on this site or null: a path starting with one /, or one starting with ~/, which it joins to the request's path base. It refuses a value holding a control character or white space, and a path part that starts with //, holds a . or .. segment or a backslash, written or percent encoded. KitHref.LocalOrHttps also accepts an absolute https:// address with no user name in it. Each also takes the request itself, KitHref.Local(value, HttpContext) and KitHref.LocalOrHttps(value, HttpContext), and reads its path base. KitHref.LocalOrThrow(value, HttpContext, owner) answers as Local does, or throws naming owner and ending with KitHref.MustPost, "it must post", for a form's action; LocalOrThrow(value, HttpContext, owner, must) ends with must, such as KitHref.MustLink, "it must be a link on this site", for a link a component cannot do without.

A stored menu url starts with ~/, which a Razor component does not resolve. Hand it to KitButton.Href as stored, or resolve it for a link of the app's own with the request's path base, and leave the link out when the answer is null:

@code {
    [CascadingParameter] private HttpContext? HttpContext { get; set; }

    private string? Target(string stored) => KitHref.Local(stored, HttpContext);
}

Light and dark

A page follows the viewer's system theme until the viewer picks one. KitThemeSwitch (Solhigson.Admin.Components) renders the choice, Light, Dark or System, as three ghost buttons in one group, the current one aria-pressed="true". A click switches the page at once, with no round trip: kit.theme.js sets data-theme on the <html> element and keeps the choice a year in the cookie kit-theme (Path=/, SameSite=Lax, Secure on an https page), or, for System, removes data-theme and deletes the cookie.

A click that changes the scheme the page draws fades its colours from the old scheme to the new: before it changes data-theme, kit.theme.js puts kit-theme-fading on the <html> element, under which every element's background, text, border, outline, underline, accent, fill, stroke and shadow colours, and those of its ::before, ::after and ::placeholder, transition over --kit-d-theme (320ms) on --kit-ease-theme, and nothing else moves; the class goes after --kit-d-theme-hold (380ms). A click that leaves the drawn scheme as it was, Dark under a dark system with no choice, fades nothing. The first paint, the page put back in line with the cookie, and a change of the system's own theme under no choice swap at once; under prefers-reduced-motion both tokens are 0ms, so a click swaps at once too. For the hold the fade replaces a kit component's own transition, and a transition an app sets in @layer app wins over the fade.

The server renders the choice, so the first paint is already right. KitTheme.Current(HttpContext) (Solhigson.Admin.Theme) reads the cookie as exactly light or dark, and anything else as no choice; the cookie's text never reaches the page. A component cannot set attributes on the app's <html>, so the app splats KitTheme.HtmlAttributes on it, in its root component:

@using Solhigson.Admin.Theme

<html lang="en" @attributes="KitTheme.HtmlAttributes(HttpContext)">
    <head>
        <KitHead Nonce="@nonce" />
    </head>
    <body>
        <Routes />
    </body>
</html>

@code {
    [CascadingParameter] private HttpContext? HttpContext { get; set; }
}

data-theme on <html> is the kit's attribute: the switch, its script and the stylesheet read and write it. An app that sets its own data-theme there fights the switch; an app that wants a fixed theme sets the tokens instead (see Overriding the kit). After an enhanced navigation, and when the browser shows a page again from its back-forward cache, the script puts the page back in line with the cookie. A page rendered from the cookie differs from one viewer to the next, so it must not sit in a shared cache without Vary: Cookie.

The mark

KitMark renders the package's name and exact version. It belongs on signed-in pages, never an anonymous one: an exact version tells a scanner which advisories apply.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.6.0 69 11/23/2026
10.5.0 69 11/22/2026
10.4.0 75 11/20/2026
10.3.0 67 11/19/2026
10.2.0 68 11/18/2026
10.1.0 71 11/17/2026
10.0.0 71 11/16/2026

10.6.0: the log screens (Solhigson.Admin.Logs, Solhigson.Admin.Components): the application log screen, the application log record page, the API log screen and the API exchange page. The logs seam: IKitLogs, which AddSolhigsonAdmin registers scoped with either overload, keeping one the app registered first, reads the application log through the framework's IAppLogReader and the API exchanges through its IApiLogReader, each resolved from the request's services at its first use; AddSolhigsonLokiReader registers the ones that read Grafana Loki. Every member takes the viewer's principal first, and answers ActorRefused, reading nothing, for one that names no signed-in user. GetSourceAsync (KitLogKind App or Api) answers a KitLogSource: State, a KitLogSourceState (NotRegistered, Off, while the reader's ReadEnabled is false or the host does not export its API exchanges, or Ready), and Newest, a KitLogNewest of a KitLogNewestState and its time At. SearchAppLogsAsync (a KitAppLogSearch: FromDay, ToDay, Since, MinSeverity, RequestId, UserId, Cursor, Zone) and SearchApiLogsAsync (a KitApiLogSearch: FromDay, ToDay, Since, Service, Method, StatusCode, PathContains, RequestId, Cursor, Zone) answer a KitLogPage<T> (Rows, NextCursor, From, To, Offset, Since, ReadAt); GetAppLogAsync answers a KitLogLookup<AppLogRecord>, AppLogsOfRequestAsync a KitLogLookup<KitAppLogsOfRequest> (the request's first 50 records, oldest first, and More), and GetApiLogAsync a KitLogLookup<KitApiExchange>, whose RequestHeaders and ResponseHeaders are each a KitLogHeaders (Entries of KitLogHeader in the stored order, Stored when what is stored is not a JSON object, or None). Each answer carries a KitLogOutcome (Done, NotRegistered, Off, ActorRefused, NotConfigured, Unreachable, Refused, NotFound, Failed) and KitLogMessages' sentence for it, NotConfigured naming the setting's key; after an Unreachable, the request's later reads answer it without calling a reader, and nothing throws but the caller's cancellation. A window is UTC instants, the end exclusive: with days, from the viewer's midnight of the first day, placed at the zone's offset at that midnight, to the midnight after the last, capped at now; with none, the hour before Since or now, ending on a whole second. A request id that is not 32 hexadecimal characters, and a cursor the reader refuses, are dropped. A fault in the seam writes one KitLogsFailed Error naming the method, the step and the exception's type, and a viewer not signed in one KitLogsNoActor Warning; each call adds one to the counter logs and records its seconds on the histogram logs.duration, on the meter Solhigson.Admin (KitLogsDiagnostics), tagged method and outcome. The screens: each is a component on the app's own route, its addresses paths on the site that KitHref.Local accepts, and no value of a record is rendered as markup. KitAppLogList (DetailHref, TimeZone, StaleAfter, 15 minutes by default) lists the application log's records of one window, newest first, a page at a time, under the presets Last hour, Today and Last 7 days and a GET filter bar (from, to, severity, and the request id and user id under More filters), with a Warn alert when the newest record is older than StaleAfter or none came in 24 hours. KitApiLogList (DetailHref, TimeZone, StaleAfter, zero, off, by default) lists the API exchanges the same way, filtering by method, status code (0, or 100 to 599, matched exactly; any other value is ignored), service, path and request id, and, while the host does not export its API exchanges, says This app does not export API exchanges, naming Solhigson:Logs:ApiLogsToLokiEnabled. KitAppLogDetail (Id, ListHref, DetailHref, TimeZone, ApiLogHref, ShowPersonal) shows one record: its message in the kit's code block, its source, machine and request id, linked with ApiLogHref to the API exchanges of that request, each further property, the exception and its stack, and the request's first 50 records with this one marked; the user id, the address and the further properties that name a person show only with ShowPersonal, while the message, the exception and its stack are shown as written. KitApiLogDetail (Id, ListHref, TimeZone, AppLogHref) shows one exchange: its method and path, its facts, its request id, linked with AppLogHref to the application log of that request, and each side's headers and body as exported, with protected values already removed; the end user's id is not shown. Both record pages write Cache-Control: no-cache, no-store and answer a record not found with 404 and Record not found, which a page that streams answers with 200, so they must not stream. KitLogList, KitLogListBase<TRecord> and KitLogRecordPage<TValue> are the public abstract bases the four components derive from; their constructors are private protected, so an app derives nothing from them. kit.manifest.json gains the kit-logs and kit-code components, the classes kit-logs, kit-logs-current, kit-logs-message, kit-logs-method, kit-logs-muted, kit-logs-text and kit-code, and the token --kit-code-height, and loses none. To adopt: add the four pages, each with its route and a [Permission] held only by operators, since logs are one store for the whole app and each screen checks only that the viewer is signed in; keep stream rendering off the record pages; call AddSolhigsonLokiReader, naming its ServiceNames, and set Solhigson:Logs:LokiReadEnabled, Solhigson:Logs:LokiUrl, Solhigson:Logs:LokiUser and Solhigson:Logs:LokiToken, the token a read-only one (logs read alone, never the export's write credential), limited where the store allows to the app's own services and environment; for the API screen, call AddSolhigsonLogExport with its logs exporting (Solhigson:Logs:OtlpExportEnabled and OTEL_EXPORTER_OTLP_ENDPOINT) and Solhigson:Logs:ApiLogsToLokiEnabled; name deployment.environment.name in OTEL_RESOURCE_ATTRIBUTES, which the reader selects on; add the meter Solhigson.Admin to the host's OpenTelemetry set-up. The README lists the lines the log screens cause that an operator acts on (KitLogsFailed, KitLogsNoActor and the framework reader's SolhigsonLokiReadFailed), each with its level and what to do, and the logs instruments. Changes for a 10.5.0 app: AddSolhigsonAdmin also registers IKitLogs, keeping a seam the app registered first; the audit list's presets, More filters and time cells are drawn by the shared parts of KitPageHeader, KitFilterBar and KitTable, with the same output; the audit entry page's payload pre gains the class kit-code beside kit-audit-raw, keeping --kit-audit-raw-height; the stylesheet's .kit-audit, a.kit-audit-scope and .kit-audit-marker rules, and the user and role pages' wrapping header line, also cover the log pages, and .kit-audit-at + .kit-audit-scope now matches only inside .kit-audit. No existing type gains a public member; every type of Solhigson.Admin.Logs, and every component named above but KitPageHeader, KitFilterBar and KitTable, is new. Minor bump. Depends on Solhigson.Framework.Core 10.31.0 or later. 10.5.0: the account pages (Solhigson.Admin.Account, Solhigson.Admin.Components): the sign-in page, the code page, the sign-out page, the forgot-password page, the reset-password page, the change-password page and the two-factor page, the code to scan and the shell's gate. The account seam: IKitAccount, which AddSolhigsonAdmin registers scoped over the framework's identity manager of the same type arguments, and over its two-factor manager where the app calls AddSolhigsonTwoFactor, keeping one the app registered first, is the one seam the pages call (SignInAsync, TwoFactorSignInAsync, SignOutAsync, CurrentAsync, RequestPasswordResetAsync, ResetPasswordAsync, ChangePasswordAsync, BeginEnrolmentAsync, CurrentEnrolmentAsync, ShowEnrolmentAsync, CompleteEnrolmentAsync, DisableTwoFactorAsync); the framework decides every sign-in, and the seam adds no rule. KitSignInResult carries a KitSignInOutcome (the framework's SignInOutcome values by name and number, and Failed), PendingUserId, Next (KitSignInNext: Code, ChangePassword, Enrol or Done, and None for every refusal and fault) and KitAccountMessages' sentence, one sentence for a wrong password, an unknown name and a disabled or locked account; KitAccountView holds UserId, DisplayName, HasPassword, TwoFactorEnabled, MustChangePassword, TwoFactorAvailable, CanEnrol and MustEnrol; KitReturnUrl.Safe sends every return address KitHref.Local refuses to the fallback. KitAccountOptions holds Brand, HomePath, PublicOrigin (the origin an emailed link starts with, never read from a request; null by default, and no reset link is built without it), SignInPath, CodePath, ChangePasswordPath and TwoFactorPath (the last two may be null where the app has no such page: then no page sends a user there and the step is never asked for, with one KitAccountPathNotSet Warning a process), Gate, ResetPath and ForgotPasswordPath; the host does not start on a PublicOrigin that is not an https origin alone (http on a loopback host) or a path KitHref.Local refuses. KitAccountAudit records account.signed-in, account.locked-out (the attempt that locks, at step password, code, change-password, two-factor-on or two-factor-off), account.signed-out, account.reset-requested, account.password-reset, account.password-changed, account.two-factor-enrolled and account.two-factor-disabled as security events, each naming the user as its actor (KitAuditEvent.ActorUserId) but the reset request, which reads "A visitor asked for a password reset link for Jane Doe"; a refused attempt records nothing, and account.locked-out reads "Locked out after wrong passwords or codes". Each call adds one to the counter account on the meter Solhigson.Admin (KitAccountDiagnostics), tagged method and outcome, and a reset request floor. The pages: each is a component on the app's own route, rendered on a request alone with no interactive render mode; each writes Cache-Control: no-cache, no-store before its first await, throws, saying so, under stream rendering, posts to its own path with no data-enhance, and writes no log line of its own. KitSignIn (form sign-in; ReturnUrl, ForgotHref) sends the user on by Next, and a viewer already signed in to the step they owe or to HomePath. KitTwoFactorCode (form two-factor-code; PendingUserId, ReturnUrl) completes a two-factor sign-in, a wrong code told apart from the refusals that end the sign-in. KitSignOut (form KitSignOut.FormName, sign-out) signs this device alone out on a post with a token and sends the user to SignInPath; a GET signs nobody out. KitForgotPassword (form forgot-password) says "If that address has an account, a reset link is on its way." for every address that is one, no sooner than 700 ms after the post, and mails the link KitResetLink builds from PublicOrigin and ResetPath (the query fields userId and token) through the app's IKitAccountMail. KitResetPassword (form reset-password; UserId, Token, ForgotHref) sets a new password from the link, also writing Referrer-Policy: no-referrer, ends the user's sessions through IKitSessions, signs no one in, and shows one frame for every link that does not work. KitChangePassword (form change-password; ReturnUrl, ForgotHref) changes a signed-in user's password with their current one, keeping this device signed in; a lockout signs the device out. KitTwoFactorSetup (ReturnUrl) turns two-factor on with an authenticator app, and off. Its set-up (two-factor-begin), show-the-key (two-factor-show), confirm (two-factor-confirm) and start-over (two-factor-restart) forms each ask the current password (the field password) before BeginEnrolmentAsync, ShowEnrolmentAsync or CompleteEnrolmentAsync acts, so a session alone, a stolen one among them, cannot add a device or copy the key: a wrong password counts toward lockout, and the one that locks records account.locked-out at step two-factor-on. A GET begins nothing and shows no key: CurrentEnrolmentAsync answers a pending key as KitEnrolmentOutcome.Pending, its key empty, and the key and its address are drawn only in the answer to a proved set-up, show or start-over, as the code to scan and as text in groups of four. Turning two-factor off (two-factor-disable, folded in a closed details) asks a code from the app, never the password; a wrong code counts toward lockout, and an answer whose EndSessions is set (KitTwoFactorOffResult) ends the user's sessions and signs this device out. A reset, a change, and two-factor turned on or off each records its row and tells the owner through IKitAccountMail.NotifyAsync (KitAccountNotice: PasswordReset, PasswordChanged, TwoFactorTurnedOff, TwoFactorTurnedOn); with no IKitAccountMail registered nothing is mailed, with one KitUserSeamDefault Warning a process. KitAuthFrame is the frame of the sign-in, code, sign-out, forgot-password and reset-password pages: the Brand, one h1 of its Title and the content, in one column no wider than --kit-auth-w, with no brand inside the shell. The code to scan: KitQrCode (Value, Label) draws a QR code at error correction level M as an inline svg of plain rect elements, with role img and Label as its aria-label, in --kit-qr-ink on --kit-qr-paper, black on white in both themes, at --kit-qr-size; a value too long for a code draws the label alone and writes one KitQrCodeTooLong Warning naming its length, never the value. Its encoder is QRCoder (MIT), the package's new dependency, at 1.6.0 or later, its module matrix alone. The shell's gate: before it renders anything, KitShell reads the viewer (IKitAccount.CurrentAsync) on every page it wraps, and sends a signed-in user whose password must change to ChangePasswordPath, else one who must enrol to TwoFactorPath, a post included, carrying the page's path without its query, kept out of every cache; it holds no one on those two pages or the sign-out page, for a visitor, with no request, on a re-executed error page, or for a step whose path is null; a read that throws lets the page render with one KitShellGateFailed Error; it covers the pages inside the shell only, and KitAccountOptions.Gate = false turns it off. The shared email: KitUserRow.EmailShared, which IKitUsers.GetAsync reads in one more query, says another stored account holds the user's email, so a reset the user asks for sends no link, and KitUserDetail then shows a Warn alert under its facts naming neither account. To adopt: add the seven pages, the sign-in, code, sign-out, forgot-password and reset-password pages anonymous and the change-password and two-factor pages with [Authorize]; set KitAccountOptions, its paths and PublicOrigin; rate-limit the sign-in, code, forgot-password and reset-password routes, and the sign-out, change-password and two-factor routes, and register a counter store for the framework's reset-link cap; keep the reset route's query out of request logging, and the account routes out of inbound tracing (README, Keeping the account routes out of tracing); register IKitAccountMail, queuing each mail and answering once it is queued, and IKitSessions; point the shell's SignOutAction at the sign-out page with SignOutFormName KitSignOut.FormName and no OnSignOut; guard pages outside the shell yourself; call AddSolhigsonTwoFactor and register root encryption (AddRootEncryption) for the two-factor page; an app's own IKitAccount proves the password argument in BeginEnrolmentAsync, ShowEnrolmentAsync and CompleteEnrolmentAsync and answers a pending key from CurrentEnrolmentAsync with no key; the package has no page that creates the first administrator. The README lists the log lines an operator acts on: the account seam's (KitAccountFailed, KitAccountNoOrigin, KitAccountNoResetToken), the shell's gate's (KitShellGateFailed, KitAccountPathNotSet), KitQrCodeTooLong and those the pages cause under KitUserSeams, KitAudit and the framework's Identity, Identity.Password, Identity.TwoFactor, Identity.AuthenticatorStep and Identity.AuthenticatorKey categories, the counter store's outages among them, each with its level and what to do. kit.manifest.json gains the kit-auth and kit-qr components and their classes, and the tokens --kit-auth-w, --kit-qr-ink, --kit-qr-paper and --kit-qr-size, and loses none. Changes for a 10.4.0 app: AddSolhigsonAdmin also registers IKitAccount and validates KitAccountOptions at start, keeping a seam the app registered first; KitShell's gate is on by default, so the shell reads the viewer on every page it wraps, each read one current call on the account counter, renders nothing until the gate has answered, and sends a user whose RequirePasswordChange is set, or who must enrol, to ~/account/change-password or ~/account/two-factor: an app without those pages adds them, sets ChangePasswordPath or TwoFactorPath to null, or sets Gate to false, and a layout with [StreamRendering] around the shell throws for a user the gate holds; with OnSignOut unset, the shell's sign-out form posts elsewhere (KitMenuForm.PostsElsewhere), writing its _handler field and registering no form name on the page it wraps; KitAuditOptions.ResolvedSubjectActions also holds the account.* actions by default, and KitAuditLabels words them; an app's own IKitAudit records KitAuditEvent.ActorUserId, when set, as the row's actor; with no IKitUserNotices of the app's but an IKitAccountMail, the default PasswordLinkNeededAsync (an enable of a user with no password, Send password link, Create user) sends the package's reset link where it answered false; IKitUsers.GetAsync makes one more read, the last, and a fault in it answers Failed with KitUsersFailed at step EmailShared; KitAlert lands any attribute it does not own on the alert, refusing a url; and KitField reads an inputmode or a maxlength attribute as its new parameter, so one on a kind that takes none, or one not valid, now throws, as does one in an Attributes dictionary passed whole. Of the existing types, KitAlert gains TakesFocus and Attributes, KitField gains InputMode and MaxLength, KitMenuForm gains PostsElsewhere, KitAuditEvent gains ActorUserId and KitUserRow gains EmailShared; every other type and member is new. Minor bump. Depends on Solhigson.Framework.Core 10.31.0 or later. 10.4.0: the audit trail screens (Solhigson.Admin.Components, Solhigson.Admin.Auditing). The reader seam: IKitAuditReader, which AddSolhigsonAdmin registers scoped over the framework's IAuditTrailReader<TContext> for the context it is given, as it registers IKitAudit, is how the audit screens read the audit trail (Available; SearchAsync of a KitAuditSearch, answering a KitAuditPage of KitAuditRow; GetAsync of a record's id and created key, answering a KitAuditLookup of a KitAuditRecord; each answer carrying a KitAuditOutcome, Done, NotAvailable, ActorRefused, NotFound or Failed, and KitAuditMessages.For's sentence). It refuses a viewer who is not signed in before anything is read, reads the time once from the registered TimeProvider and resolves one window from the viewer's days in their zone through the framework's AuditTrailWindow, passes every filter and the cursor, answers NotAvailable with no query when no reader resolves or the context does not map AuditTrail, and throws nothing but the caller's cancellation; a fault's line names the filters set, never their values. A row's Linkable, ActorLinkable and ActorAttempted say whether a link may carry its entity id or its actor id, so text a sign-in caller typed never reaches a link, and a name a caller gave on a security event is marked as attempted. People are named for the viewer: a name a row stores shows to every viewer; an id it stores with no name is looked up in one UserAdministration.ResolveDisplayNamesAsync call a page or a record, and shows as the user's name only when the viewer's scope admits the user, else as a fragment of the id; a subject is looked up only on a user's entity type under an allow-listed action, KitAuditOptions' UserEntityTypes (User by default, beside the identity's own user class) and ResolvedSubjectActions (the users.* actions by default); a record about a user the viewer may not reach is Restricted and carries no changes, no snapshot and no address, a record's address is withheld unless the lookup names its actor for the viewer, while a record with no actor id keeps its address, which ShowIp shows to every viewer unless the record is Restricted, and a failed lookup sets NamesUnavailable. With no user-administration rules registered nothing is looked up or restricted, so the audit page's permission belongs only to roles that may see every user. KitAuditLabels gives the package's 15 audit actions a label and a verb phrase (For, Sentence, TypeInWords), so a record reads "Ada Obi changed the roles of Jane Doe", and any other action reads as the framework's AuditDisplay labels it; KitAuditEvent.SettingEntityType names the settings screen's entity type. The audit list: KitAuditList, which an app places on its own page with DetailHref (holding {id} and {created}) and an optional TimeZone, lists the records of one window newest first, a page at a time: the header says the window in the viewer's zone, with Today, Last 7 days and Last 30 days; a GET filter bar holds the days and the category, and behind More filters the action, the subject type, the subject id and the person (the query names from, to, category, action, type, id, actor and cursor), each matched exactly as stored; the table shows when, what (the action's label, linking to the record), the subject and the person, a subject linking to its history and a person to their activity only where the row allows it; a search naming a subject or a person and no day reads all time. The audit entry page: KitAuditDetail, on a page with the record's id and created key in its route, taking Id, Created, ListHref, an optional UserHref and TimeZone, and ShowIp (false unless set), shows one record: its sentence as the title, when it was written in the viewer's zone, the facts (the category, the action, the subject, the person, the source and, with ShowIp, the address), What changed and Recorded values, a masked value reading Hidden and a payload not in the stored shape shown as text in a block that scrolls inside itself; nothing in a record is ever markup; a record not found answers 404, and the page must not stream. The history links: KitSettingsEditor, KitUserDetail and KitRoleDetail gain HistoryHref, the audit page's path, with which each setting's row ends with a History link, the user page's header gains History and Activity by this person, and the role page's header gains History, kept after a delete, each to the audit list with no day; a HistoryHref that KitHref.Local refuses, or that holds ? or #, throws before any read, and with none set nothing renders. To adopt: add two pages (the audit list, a record by id and created key), each with its route and [Permission]; the record page must not stream; map AuditTrail in the context passed to AddSolhigsonAdmin; the audit trail is one trail for the whole app, so the permission decides who reads it; a name is looked up only for users the viewer's scope admits, while a name stored on a record shows to every viewer; a record about a user the viewer may not reach shows no values; an app that captures its user class adds "securitystamp" to AuditCaptureOptions.AdditionalSensitiveNamePatterns, through a pre-populated AuditCaptureOptions singleton the framework's registration leaves in place, since the defaults do not mask SecurityStamp, which the record page would show ("securitystamp" masks the secret and nothing else, where a plain "stamp" would also mask any Timestamp column); rows captured before the pattern keep the raw stamp, so an app that has captured its user class adds the pattern, then rotates every user's security stamp (UserManager.UpdateSecurityStampAsync) before it grants the audit permission, which ends every open session at the next stamp check; an app never opts Identity's user-token, user-login or user-claim types into capture, since their values are credentials no pattern masks and their records are not restricted; add any other user class name, beside the identity's own, to KitAuditOptions.UserEntityTypes and its own safe user actions to ResolvedSubjectActions; pass TimeZone; ShowIp is off by default; pass HistoryHref to the settings, user and role pages. The README lists each log line the reader seam writes (KitAuditReaderNoActor, KitAuditReaderSearchFailed, KitAuditReaderGetFailed, KitAuditReaderUnresolved) and each line the screens' reads cause under AuditTrailReader, UserAdministration and the users seam, its level and what to do; the screens write no line of their own. The kit: KitNotice, given a KitNoticeMessage (KitNoticeMessage.Landed or NotLanded, a blank text or step throwing), says a post's answer in one message at the foot of the screen that rises in, stays (--kit-notice-dwell, --kit-notice-long-dwell) and leaves on its own, in CSS alone, and is drawn only inside KitShell, which tells it to a screen reader through two live regions that kit.notice.js fills; KitButton gains Answer (KitButtonAnswer: None, Landed, a ring in the success colour, or Failed, a sideways nudge), drawn on the render that answers a post, changing neither the button's colour, text nor size, and still under reduced motion; kit.forms.js removes every notice and both answer classes as it marks a post's submitter busy, so the next answer plays; KitFilterBar gains Enhance, true unless set, false for a bar holding a field named after a form's own member, such as action, which then submits as a plain form; kit-facts is the facts list the audit record page and the user page share; kit.manifest.json gains the kit-audit, kit-facts and kit-notice names, the kit-btn-landed, kit-btn-nudged, kit-gallery-notices, kit-role-history and kit-user-history classes, the component token --kit-audit-raw-height (the raw payload block's height, the measure unless set) and the tokens --kit-d-flash, --kit-flash-spread, --kit-flash-ring, --kit-flash-ring-end, --kit-d-nudge, --kit-nudge-1, --kit-nudge-2, --kit-nudge-3, --kit-d-notice, --kit-d-notice-leave, --kit-notice-rise, --kit-notice-dwell, --kit-notice-long-dwell, --kit-z-skip and --kit-z-float, and loses none; every new duration token is 0ms under reduced motion. Changes for a 10.3.0 app: AddSolhigsonAdmin also registers IKitAuditReader and, when the app registers no TimeProvider, TimeProvider.System, each kept when the app registered it first; KitHead also links kit.notice.js, with the page's nonce as its other scripts; KitShell renders two empty, visually hidden live regions, a status and an alert, after its main region on every page; the user page's facts list also carries the kit-facts class, its kit-user-facts class kept; and the header line of the user and role pages, and of the new-user and new-role screens, is a flex row that wraps, spaced by its gap, so a back link after a wrapped email or group takes its own line. Minor bump: every type and member is new but for those changes. Depends on Solhigson.Framework.Core 10.29.0 or later. 10.3.0: the role and permission screens (Solhigson.Admin.Components, Solhigson.Admin.Roles). The roles seam: IKitRoles, which AddSolhigsonAdmin registers scoped over the framework's RoleAdministration as it registers IKitUsers, is how the role screens read and change roles (ListAsync, GetAsync, HeldPermissionsAsync, OfferedPermissionsAsync, SetPermissionsAsync, RemoveGrantsOutsideOfferAsync, CreateAsync, DeleteAsync, PermissionsAsync, GroupNamesAsync; with KitRolePage, KitRoleLookup, KitRoleRow, KitHeldPermissions, KitOfferedPermissions, KitPermissionPage, KitRoleResult and KitRoleAudit's roles.* actions, GroupNamesAsync answering the 10.2.0 KitRoleNames); it reads the acting user by the users seam's rule, adds no rule of its own and throws nothing but the caller's cancellation. KitRoleLinks.For builds every link to a role from the app's template, and a role's page passes its route value as given, never decoded again. The roles list: KitRolesList, which an app places on its own page with DetailHref (holding {name}) and an optional CreateHref and UsersHref (holding {role}), lists every stored role by group, then name, with a GET filter by group: the name linking to the role's page, marked Yours or View only, the group, the users holding it in every tenant with a link to the ones the viewer manages, and its grants. The role page: KitRoleDetail, on a page with the role's name in its route, taking RoleName, ListHref, an optional UsersHref and CanManage, says first whether the viewer can change the role and why not, then shows what the role holds, the grants its group offers by top permission and those outside the offer with their class in words, and how many users hold it; a role not found answers 404, and the page must not stream. With CanManage, for a role the viewer may edit and does not hold: the permission editor, one form with a box for each permission the role's group offers, a box disabled where the viewer may not give the permission and the role does not hold it, so a viewer adds only permissions it holds unless the app's rules answer its Grant with All, saving through SetPermissionsAsync, refused as stale when the role's grants changed since the page loaded, and recorded as roles.permissions-changed; the clearing of out-of-group grants, a confirm that removes the grants the group may not hold that the framework marks removable (HeldPermission.Removable), recorded as roles.outside-grants-removed; and delete, a confirm opened only while no user in any tenant holds the role, answered RoleInUse otherwise, removing the role and its grants, recorded as roles.deleted. A save, a removal or a delete answered Failed may have been stored: the page reads the role again and says what it found, and no audit row is written. A post carries two values for each permission the role holds, so FormOptions.ValueCountLimit (1024 unless the app sets it) bounds a save at about 500 held grants, a longer post answered 400 with nothing saved. Role creation: KitRoleCreate, with ListHref, DetailHref and CanCreate (false unless set), creates a role holding no permission, its name of at most 64 characters, in the stored group the viewer chooses, where the app's rules' MayCreateRoleAsync allows it, which refuses unless the app writes it; it records roles.created and links to the new role's page, or says that an administrator who may grant the role must set its permissions, or that its group is not declared; a Failed create says the role may have been created, so look it up before creating it again. The permissions list: KitPermissionsList, with an optional RoleHref, lists every stored permission in the role editor's order, with its parent, the groups its declaration allows (a Warn pill for one offered to no group) and the roles holding it, with a GET search and, with permission groups registered, an offered-to-no-group filter. The role page and the new-role page refuse framing: the app sends X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' on them, and the components set no header. A deleted role's name can be created again, and that role then gets the seed's AllowedRoles grants that its group may hold and matches any open session still carrying the role claim until its stamp is next checked; a role the app seeds leaves the seed before it is deleted. The README lists each log line the role screens write (the seam's KitRolesNoActor and KitRolesFailed, the guard's KitUserSeamAuditFailed and KitUserSeamDoneUnnamed, the audit seam's, and the framework's lines under RoleAdministration and Solhigson.Framework.PermissionGroups that the screens cause), its level and what to do, beside the role_administration counter on the meter Solhigson.Framework.Identity. The kit: KitButton gains BusyText, the doing word a submit button reads with three working dots while its post is out, and kit.forms.js now holds a form whose kit button is busy, so a second submit of it is not sent until the answer is on the page or --kit-btn-busy-dwell (20s) passes; a theme pick cross-fades the colours (--kit-d-theme, --kit-d-theme-hold); a page change inside KitShell slides in from the side it came from (kit.nav.js and kit.core.js, which KitHead links with the page's nonce; --kit-d-enter); the rail's marker glides to the current item where the browser can anchor it (--kit-d-glide); every such motion stops under reduced motion; kit.manifest.json gains the kit-role, kit-roles, kit-permissions, kit-enter, kit-rail-marker and kit-theme-fading names and the new tokens, and loses none. Changes for a 10.2.0 app: an audit seam that throws now writes KitUserSeamAuditFailed (event id 3), naming the event's entity type and id, in place of KitUserSeamFailed (event id 2), so an alert on the old line stops seeing audit throws; AddSolhigsonAdmin also registers IKitRoles, kept when the app registered it first; a # in the users list's DetailHref now ends its path as a ? does; and the email change's limits no longer offer gating a reset on a confirmed address, since whoever reads the new address can confirm it through a confirmation sent without the user's sign-in (the anonymous ResendEmailConfirmation page of Identity's default UI) or an external sign-in matching accounts by address: where the app's sign-in sends a reset to an address it has not confirmed, only keeping AllowEmailChange off guards an address takeover, so an app that relied on that gate turns AllowEmailChange off. Minor bump: every type and member is new but for those changes. Depends on Solhigson.Framework.Core 10.29.0 or later.