Don(t block the administration
Some checks failed
Dotnet build and test / build (pull_request) Failing after 15s
Some checks failed
Dotnet build and test / build (pull_request) Failing after 15s
This commit is contained in:
parent
30bcb070d9
commit
2ff595a3ef
11 changed files with 61 additions and 7 deletions
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
|
|
@ -56,7 +56,6 @@
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"projectPath": "${workspaceFolder}/src/Yavsc.Blogs/Yavsc.Blogs.csproj"
|
"projectPath": "${workspaceFolder}/src/Yavsc.Blogs/Yavsc.Blogs.csproj"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Test PostIt.Android launch (Xamarin.UITest)",
|
"name": "Test PostIt.Android launch (Xamarin.UITest)",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
|
|
|
||||||
17
.vscode/tasks.json
vendored
17
.vscode/tasks.json
vendored
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"isRoot": true,
|
"isRoot": true,
|
||||||
|
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "build-debug-android",
|
"label": "build-debug-android",
|
||||||
|
|
@ -136,6 +135,22 @@
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build"
|
"kind": "build"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "build-postit-browser",
|
||||||
|
"type": "process",
|
||||||
|
"problemMatcher": ["$msCompile"],
|
||||||
|
"isBuildCommand": true,
|
||||||
|
"isTestCommand": false,
|
||||||
|
"isBackground": true,
|
||||||
|
"command": "dotnet",
|
||||||
|
"args": ["build", "/property:GenerateFullPaths=true"],
|
||||||
|
"options": {
|
||||||
|
"cwd": "src/PostIt/PostIt.Browser"
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "build"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
* [Resource usage] Let users with the `Administrator` role continue making requests after reaching their consumption quota, while still recording their usage.
|
||||||
|
|
||||||
* [PostIt.Android/Podcasts] Add an optional persisted background blur for camera preview and broadcasting. Run the bundled PPHumanSeg model locally with ONNX Runtime and composite with OpenGL before encoding; preserve the unfiltered pipeline for calls and OBS.
|
* [PostIt.Android/Podcasts] Add an optional persisted background blur for camera preview and broadcasting. Run the bundled PPHumanSeg model locally with ONNX Runtime and composite with OpenGL before encoding; preserve the unfiltered pipeline for calls and OBS.
|
||||||
|
|
||||||
* [Podcasts/OBS/PostIt] Replace the MediaMTX relay with direct encrypted SRT ingestion managed by [FFmpeg.NET](https://github.com/cmxl/FFmpeg.NET). Reserve bounded UDP listeners on activation, display a secret SRT URL with an empty OBS stream-key field, start on received media, preserve revocation/expiry/quotas and authenticated replay, and invalidate in-memory activations after restart. Remove relay configuration and its authentication endpoint; update deployment, privacy and real-media regressions. Use separate request connections to the shared SQLite test database for reliable concurrent podcast requests.
|
* [Podcasts/OBS/PostIt] Replace the MediaMTX relay with direct encrypted SRT ingestion managed by [FFmpeg.NET](https://github.com/cmxl/FFmpeg.NET). Reserve bounded UDP listeners on activation, display a secret SRT URL with an empty OBS stream-key field, start on received media, preserve revocation/expiry/quotas and authenticated replay, and invalidate in-memory activations after restart. Remove relay configuration and its authentication endpoint; update deployment, privacy and real-media regressions. Use separate request connections to the shared SQLite test database for reliable concurrent podcast requests.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@
|
||||||
"ApiUrl": "https://preprod-api.$DOMAIN",
|
"ApiUrl": "https://preprod-api.$DOMAIN",
|
||||||
"CorsAllowedOrigins": [
|
"CorsAllowedOrigins": [
|
||||||
"https://preprod-blogs.$DOMAIN",
|
"https://preprod-blogs.$DOMAIN",
|
||||||
"https://preprod-api.$DOMAIN"
|
"https://preprod-api.$DOMAIN",
|
||||||
|
"https://postit.$DOMAIN"
|
||||||
],
|
],
|
||||||
"Banner": "/images/banner-dewang.jpg",
|
"Banner": "/images/banner-dewang.jpg",
|
||||||
"Owner": {
|
"Owner": {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<FileVersion>1.1.0.0</FileVersion>
|
<FileVersion>1.1.0.0</FileVersion>
|
||||||
<InformationalVersion>1.1.0-feat-calls.1+472.Branch.feat-calls.Sha.d8200cb98ddef152313ef1f102b866c50f107cbd</InformationalVersion>
|
<InformationalVersion>1.1.0-feat-calls.1+472.Branch.feat-calls.Sha.d8200cb98ddef152313ef1f102b866c50f107cbd</InformationalVersion>
|
||||||
<Version>1.1.0-feat-calls.1</Version>
|
<Version>1.1.0-feat-calls.1</Version>
|
||||||
|
<PublishTrimmed>false</PublishTrimmed>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia.Browser" />
|
<PackageReference Include="Avalonia.Browser" />
|
||||||
|
|
@ -15,4 +16,4 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PostIt\PostIt.csproj" />
|
<ProjectReference Include="..\PostIt\PostIt.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ sealed class Program
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Platform.IsPodcastSupported = true;
|
Platform.IsPodcastSupported = true;
|
||||||
|
Platform.CreateBrowser = () => new CustomSchemeBrowser("postit://callback");
|
||||||
|
|
||||||
CLIOptionHandler.HandleArgs(args);
|
CLIOptionHandler.HandleArgs(args);
|
||||||
|
|
||||||
// Short-circuit 2nd-instance launches (OS handing us the
|
// Short-circuit 2nd-instance launches (OS handing us the
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public static class Platform
|
||||||
/// <c>LoginAsync</c> will surface a clear error.
|
/// <c>LoginAsync</c> will surface a clear error.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static System.Func<IBrowser?>? CreateBrowser { get; set; } =
|
public static System.Func<IBrowser?>? CreateBrowser { get; set; } =
|
||||||
() => new CustomSchemeBrowser(CustomScheme);
|
() => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional platform hook used by the shared billing form to request a
|
/// Optional platform hook used by the shared billing form to request a
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ public partial class AuthenticationSettings : ObservableObject
|
||||||
/// in <c>PostIt.Android/Properties/AndroidManifest.xml</c> must match.
|
/// in <c>PostIt.Android/Properties/AndroidManifest.xml</c> must match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AndroidRedirectUri = "android://postit-signin";
|
public const string AndroidRedirectUri = "android://postit-signin";
|
||||||
|
public const string BrowserRedirectUri = "https://postit.pschneider.fr/callback";
|
||||||
|
|
||||||
|
|
||||||
public const string DefaultAuthority = "https://yavsc.pschneider.fr";
|
public const string DefaultAuthority = "https://yavsc.pschneider.fr";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ public partial class Settings : ViewModelBase
|
||||||
this.Authentication.ClientId = string.IsNullOrWhiteSpace(settings.Authentication.ClientId) ?
|
this.Authentication.ClientId = string.IsNullOrWhiteSpace(settings.Authentication.ClientId) ?
|
||||||
AuthenticationSettings.DefaultClientId : settings.Authentication.ClientId;
|
AuthenticationSettings.DefaultClientId : settings.Authentication.ClientId;
|
||||||
this.Authentication.RedirectUri = string.IsNullOrWhiteSpace(settings.Authentication.RedirectUri) ?
|
this.Authentication.RedirectUri = string.IsNullOrWhiteSpace(settings.Authentication.RedirectUri) ?
|
||||||
AuthenticationSettings.DesktopRedirectUri : settings.Authentication.RedirectUri;
|
AuthenticationSettings.BrowserRedirectUri : settings.Authentication.RedirectUri;
|
||||||
if (settings.Authentication.Scopes is null || settings.Authentication.Scopes.Length == 0)
|
if (settings.Authentication.Scopes is null || settings.Authentication.Scopes.Length == 0)
|
||||||
{
|
{
|
||||||
this.Authentication.Scopes = AuthenticationSettings.DefaultScopes;
|
this.Authentication.Scopes = AuthenticationSettings.DefaultScopes;
|
||||||
|
|
@ -513,7 +513,7 @@ public partial class Settings : ViewModelBase
|
||||||
{
|
{
|
||||||
Authority = AuthenticationSettings.DefaultAuthority,
|
Authority = AuthenticationSettings.DefaultAuthority,
|
||||||
ClientId = AuthenticationSettings.DefaultClientId,
|
ClientId = AuthenticationSettings.DefaultClientId,
|
||||||
RedirectUri = AuthenticationSettings.DesktopRedirectUri,
|
RedirectUri = AuthenticationSettings.BrowserRedirectUri,
|
||||||
Scopes = AuthenticationSettings.DefaultScopes
|
Scopes = AuthenticationSettings.DefaultScopes
|
||||||
};
|
};
|
||||||
this.DarkMode = false;
|
this.DarkMode = false;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,13 @@ public sealed class ResourceUsageTelemetryMiddleware(
|
||||||
await ResourceUsageTracker.RecordAsync(admissionScope.ServiceProvider.GetRequiredService<ApplicationDbContext>(),
|
await ResourceUsageTracker.RecordAsync(admissionScope.ServiceProvider.GetRequiredService<ApplicationDbContext>(),
|
||||||
userId, userName, apiCalls: 1m, bandwidthMb: ToMb(requestBytes), actorUserId: userId);
|
userId, userName, apiCalls: 1m, bandwidthMb: ToMb(requestBytes), actorUserId: userId);
|
||||||
}
|
}
|
||||||
|
else if (context.User.IsInMsRole("Administrator"))
|
||||||
|
{
|
||||||
|
using var admissionScope = scopeFactory.CreateScope();
|
||||||
|
await ResourceUsageTracker.RecordAsync(admissionScope.ServiceProvider.GetRequiredService<ApplicationDbContext>(),
|
||||||
|
userId, userName, apiCalls: 1m, bandwidthMb: ToMb(requestBytes), actorUserId: userId,
|
||||||
|
cancellationToken: context.RequestAborted);
|
||||||
|
}
|
||||||
else if (!await usage.TryAdmitAsync(userId, userName, 1m, ToMb(requestBytes), 0,
|
else if (!await usage.TryAdmitAsync(userId, userName, 1m, ToMb(requestBytes), 0,
|
||||||
context.RequestAborted))
|
context.RequestAborted))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,31 @@ public sealed class ResourceUsageTests
|
||||||
.ResourceUsageRecords.ToListAsync(TestContext.Current.CancellationToken));
|
.ResourceUsageRecords.ToListAsync(TestContext.Current.CancellationToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Administrator_request_bypasses_quota_rejection_and_remains_accounted()
|
||||||
|
{
|
||||||
|
using var provider = NewProvider(o => o.DefaultLimit = 0.01m);
|
||||||
|
using var scope = provider.CreateScope();
|
||||||
|
var context = NewContext(scope.ServiceProvider);
|
||||||
|
context.User.AddIdentity(new ClaimsIdentity([
|
||||||
|
new Claim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", "Administrator")
|
||||||
|
], "Bearer"));
|
||||||
|
var ran = false;
|
||||||
|
var middleware = new ResourceUsageTelemetryMiddleware(
|
||||||
|
_ => { ran = true; return Task.CompletedTask; },
|
||||||
|
provider.GetRequiredService<IServiceScopeFactory>(),
|
||||||
|
NullLogger<ResourceUsageTelemetryMiddleware>.Instance);
|
||||||
|
|
||||||
|
await middleware.InvokeAsync(context, scope.ServiceProvider.GetRequiredService<IResourceUsageService>());
|
||||||
|
|
||||||
|
Assert.True(ran);
|
||||||
|
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
|
||||||
|
var summary = await scope.ServiceProvider.GetRequiredService<IResourceUsageService>()
|
||||||
|
.GetCurrentAsync("alice", "alice", TestContext.Current.CancellationToken);
|
||||||
|
Assert.Equal(1m, summary.ApiCalls);
|
||||||
|
Assert.True(summary.IsQuotaReached);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Tracked_storage_replacement_and_deletion_refund_only_their_original_volume()
|
public async Task Tracked_storage_replacement_and_deletion_refund_only_their_original_volume()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue