aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Essentials.Accounts.Admin/Helpers/LocalNetworkProtectedEndpoint.cs
diff options
context:
space:
mode:
Diffstat (limited to 'VNLib.Plugins.Essentials.Accounts.Admin/Helpers/LocalNetworkProtectedEndpoint.cs')
-rw-r--r--VNLib.Plugins.Essentials.Accounts.Admin/Helpers/LocalNetworkProtectedEndpoint.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/VNLib.Plugins.Essentials.Accounts.Admin/Helpers/LocalNetworkProtectedEndpoint.cs b/VNLib.Plugins.Essentials.Accounts.Admin/Helpers/LocalNetworkProtectedEndpoint.cs
new file mode 100644
index 0000000..3812337
--- /dev/null
+++ b/VNLib.Plugins.Essentials.Accounts.Admin/Helpers/LocalNetworkProtectedEndpoint.cs
@@ -0,0 +1,30 @@
+using System;
+
+using VNLib.Utils;
+using VNLib.Plugins.Essentials.Endpoints;
+
+namespace VNLib.Plugins.Essentials.Accounts.Admin.Helpers
+{
+ /// <summary>
+ /// Provides an endpoint that provides optional protection against requests outside the local network
+ /// </summary>
+ internal abstract class LocalNetworkProtectedEndpoint : ProtectedWebEndpoint
+ {
+ private bool _localOnly;
+
+ /// <summary>
+ /// Specifies if requests outside of the local network are allowed.
+ /// </summary>
+ protected bool LocalOnly
+ {
+ get => _localOnly;
+ set => _localOnly = value;
+ }
+
+ protected override ERRNO PreProccess(HttpEntity entity)
+ {
+ return (!_localOnly || entity.IsLocalConnection) && base.PreProccess(entity);
+ }
+
+ }
+}