Osirion.Blazor.Cms.Infrastructure
4.4.2
Prefix Reserved
dotnet add package Osirion.Blazor.Cms.Infrastructure --version 4.4.2
NuGet\Install-Package Osirion.Blazor.Cms.Infrastructure -Version 4.4.2
<PackageReference Include="Osirion.Blazor.Cms.Infrastructure" Version="4.4.2" />
<PackageVersion Include="Osirion.Blazor.Cms.Infrastructure" Version="4.4.2" />
<PackageReference Include="Osirion.Blazor.Cms.Infrastructure" />
paket add Osirion.Blazor.Cms.Infrastructure --version 4.4.2
#r "nuget: Osirion.Blazor.Cms.Infrastructure, 4.4.2"
#:package Osirion.Blazor.Cms.Infrastructure@4.4.2
#addin nuget:?package=Osirion.Blazor.Cms.Infrastructure&version=4.4.2
#tool nuget:?package=Osirion.Blazor.Cms.Infrastructure&version=4.4.2
Osirion.Blazor.Cms.Infrastructure
Infrastructure layer for the Osirion.Blazor CMS ecosystem, implementing repositories, external service integrations, and infrastructure concerns.
Overview
The Infrastructure project implements the Infrastructure layer in the Clean Architecture pattern, providing concrete implementations of the interfaces defined in the Domain and Application layers. It includes repositories, API clients, storage implementations, and external service integrations.
Features
- GitHub Provider: Content provider and repositories that read and write through the GitHub API (
GitHubContentProvider,GitHubContentRepository) - File System Provider: Local file system content repository (
FileSystemContentRepository). Withoutlast_modifiedin a file's front matter, an item is last modified when it was created; setFileSystemOptions.UseFileWriteTimeAsLastModifiedto use the file's write time instead - Caching Integration: In-memory, stale-while-revalidate caching of repository results, configured with
CacheOptions - HTTP Clients: Typed HTTP clients for the GitHub API (
GitHubApiClient,GitHubTokenProvider) - Local Storage:
LocalStorageService, anIStateStorageServiceimplementation backed by Blazored.LocalStorage - Dependency Injection: Service registration extensions in
Osirion.Blazor.Cms.Infrastructure.DependencyInjection - Category and tag queries: A
CategoryorTagquery matches by name (ignoring case) or by slug, exactly
Registration
using Osirion.Blazor.Cms.Infrastructure.DependencyInjection;
builder.Services.AddCms(builder.Configuration, cms => cms
.AddGitHub()
.AddFileSystem(options => options.BasePath = "content"));
AddCms(IConfiguration, Action<OsirionCmsBuilder>?) registers the core services. Without the delegate it registers a provider for each configuration section it finds under Osirion:Cms (GitHub and FileSystem). AddGitHubContentProvider, AddFileSystemContentProvider, AddCustomContentProvider<TProvider> and AddOsirionCqrs are available as separate IServiceCollection extensions.
Configuration Options
Both option classes derive from ContentProviderOptions (namespace Osirion.Blazor.Cms.Domain.Options), which adds ProviderId, IsDefault, ContentPath, EnableLocalization, DefaultLocale, SupportedLocales, SupportedExtensions and ValidateContent.
GitHubOptions binds from Osirion:Cms:GitHub. A named provider (AddGitHubContentProvider(configuration, "Blog")) binds from Osirion:Cms:Web:GitHub:{name}, or Osirion:Cms:Admin:GitHub:{name} when that section is absent:
public class GitHubOptions : ContentProviderOptions
{
public string Owner { get; set; } = string.Empty;
public string Repository { get; set; } = string.Empty;
public string Branch { get; set; } = "main";
public string ApiToken { get; set; } = string.Empty;
public string? ApiUrl { get; set; } = "https://api.github.com";
public string? WebhookSecret { get; set; }
public bool EnablePolling { get; set; } = false;
public int PollingIntervalSeconds { get; set; } = 86400;
public bool UseBackgroundCacheUpdate { get; set; } = true;
public List<string> ExcludePatterns { get; set; } = new() { ".*", "_*" };
// Authentication and inherited properties
}
FileSystemOptions binds from Osirion:Cms:Web:FileSystem, or from Osirion:Cms:FileSystem:Web when the first section is absent:
public class FileSystemOptions : ContentProviderOptions
{
public string BasePath { get; set; } = string.Empty;
public bool WatchForChanges { get; set; } = true;
public int PollingIntervalMs { get; set; } = 30000;
public bool IncludeSubdirectories { get; set; } = true;
public bool CreateDirectoriesIfNotExist { get; set; } = false;
public List<string> IncludePatterns { get; set; } = new() { "**/*.md", "**/*.markdown" };
public List<string> ExcludePatterns { get; set; } = new() { "**/node_modules/**", "**/bin/**", "**/obj/**" };
public string? ContentRoot { get; set; }
public bool UseFileWriteTimeAsLastModified { get; set; }
}
ExcludePatterns skips files whose path under BasePath matches a glob, such as **/drafts/**. ContentRoot is the prefix removed when URLs are built, and the inherited ContentPath stands in for it when ContentRoot is empty. PollingIntervalMs and IncludePatterns are obsolete because nothing reads them: use WatchForChanges to refresh content, and SupportedExtensions to choose the file types. GitHubOptions.ExcludePatterns is obsolete for the same reason: use ContentPath and SupportedExtensions.
CacheOptions binds from Osirion:Cms:Cache and is obsolete: the providers keep their own content caches, and the options only configure IContentCacheService and CacheDecoratorFactory, which no CMS component uses. Remove the section; the type goes in the next major version.
GitHub API Clients and Credentials
IGitHubApiClientFactory.GetClient(name)andGetDefaultClient()return a newGitHubApiClienton every call. The caller owns it:SetRepository,SetBranchandSetAccessTokenchange that instance only and never another caller's client.- A client sends
Accept,User-AgentandAuthorizationon each request message and never changesHttpClient.DefaultRequestHeaders. AnAcceptorUser-Agentheader you configure on theHttpClientis kept. - Factory clients take a short-lived
HttpClientnamedGitHub_{ProviderName}fromIHttpClientFactoryfor every operation. Configure it withservices.AddHttpClient("GitHub_Blog"). - Cookies are turned off on the primary handler of the
GitHub_*,IGitHubApiClient,IGitHubTokenProviderandIAuthenticationServiceclients, because a pooled handler is shared by every user. The policy runs after all handler configuration, so a primary handler you configure (throughConfigureHttpClientDefaultsor the named client, before or after the Osirion registration) is kept with cookies turned off. In the browser it does nothing, because the fetch API owns cookies there. - Repository paths, branch names, owner and repository are percent-encoded per segment. A backslash in a repository path is read as a
/separator. A path or branch name with an empty,.or..segment is rejected with anArgumentExceptionbefore any request is sent. URLs built from letters, digits,-,_,.,~and/are unchanged. IAuthenticationServiceandIGitHubAdminServiceare registered as scoped, one per circuit or request, replacing any earlier registration. The admin service never uses a content provider'sApiToken: it uses the signed-in user's token, orCmsAdminOptions.Authentication.PersonalAccessTokenwhen one is configured. Without either, repository operations send no request;DeleteFileAsync, for example, throwsInvalidOperationExceptioninstead of sending an unauthenticated delete. Signing out drops the user's token from the admin service of the same scope.AuthenticationServicekeeps the user's token in memory only. It never writes the token toIStateStorageService(which stores plain text) and never signs anyone in with the configuredPersonalAccessToken.InitializeAsyncand sign-out remove agithub_auth_tokenvalue that earlier versions left in browser storage. The admin module keeps a signed-in user's token between page loads in encrypted, user-bound protected browser storage instead.GitHubTokenProviderrequestsAccept: application/json, sends theredirect_uriand PKCEcode_verifierit is given, treats anerrorfield in a 200 response as a rejected exchange, and honours itsCancellationToken. The originalExchangeCodeForTokenAsync(code, clientId, clientSecret)overload still works and sends neither value.
Dependencies
The infrastructure layer has the following dependencies:
- Osirion.Blazor.Cms.Domain: For domain entities and interfaces
- Osirion.Blazor.Cms.Application: For application services and interfaces
- Osirion.Blazor.Core: For shared Osirion components and services
- Blazored.LocalStorage: For browser local storage access
- Scrutor: For assembly scanning in
AddOsirionCqrs - System.IO.Abstractions: For file system access in the file system provider
- Microsoft.AspNetCore.App: Shared framework reference
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- AngleSharp (>= 1.8.5)
- Blazored.LocalStorage (>= 4.5.0)
- BlazorJSComponents (>= 1.0.0)
- FluentValidation (>= 12.2.0)
- HtmlSanitizer (>= 9.2.1039)
- Markdig (>= 1.4.1)
- Octokit (>= 14.0.0)
- Osirion.Blazor.Cms.Application (>= 4.4.2)
- Osirion.Blazor.Cms.Domain (>= 4.4.2)
- Osirion.Blazor.Core (>= 4.4.2)
- Scrutor (>= 7.0.0)
- System.IO.Abstractions (>= 22.3.0)
- YamlDotNet (>= 18.1.0)
-
net9.0
- AngleSharp (>= 1.8.5)
- Blazored.LocalStorage (>= 4.5.0)
- BlazorJSComponents (>= 1.0.0)
- FluentValidation (>= 12.2.0)
- HtmlSanitizer (>= 9.2.1039)
- Markdig (>= 1.4.1)
- Octokit (>= 14.0.0)
- Osirion.Blazor.Cms.Application (>= 4.4.2)
- Osirion.Blazor.Cms.Domain (>= 4.4.2)
- Osirion.Blazor.Core (>= 4.4.2)
- Scrutor (>= 7.0.0)
- System.IO.Abstractions (>= 22.3.0)
- YamlDotNet (>= 18.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Osirion.Blazor.Cms.Infrastructure:
| Package | Downloads |
|---|---|
|
Osirion.Blazor.Cms.Core
Core CMS module for Osirion.Blazor - Provides cms management with provider pattern. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.4.2 | 252 | 10/29/2026 |
| 4.4.1 | 175 | 10/29/2026 |
| 4.4.0 | 173 | 10/29/2026 |
| 4.3.0 | 175 | 10/29/2026 |
| 4.2.0 | 296 | 10/18/2026 |
| 4.1.0 | 259 | 10/17/2026 |
| 4.0.0 | 173 | 10/12/2026 |
| 3.0.1 | 280 | 9/24/2026 |
| 3.0.0 | 210 | 8/5/2026 |
| 2.1.18 | 320 | 12/14/2025 |
| 2.1.17 | 306 | 12/14/2025 |
| 2.1.16 | 288 | 12/14/2025 |
| 2.1.15 | 271 | 12/12/2025 |
| 2.1.14 | 550 | 12/11/2025 |
| 2.1.13 | 564 | 12/11/2025 |
| 2.1.12 | 377 | 9/4/2025 |
| 2.1.11 | 325 | 8/31/2025 |
| 2.1.10 | 362 | 8/29/2025 |
| 2.1.9 | 375 | 8/29/2025 |
| 2.1.8 | 366 | 8/27/2025 |