Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
InternalTransferAccess.cs
1using System;
2using System.Threading.Tasks;
6
8{
13 {
18 {
19 }
20
24 public override string DisplayName => "Internal";
25
31 public override string[] GetChallenges(HttpRequest Request)
32 {
33 return Array.Empty<string>();
34 }
35
41 public override Task<IUser> IsAuthenticated(HttpRequest Request)
42 {
43 if (IsInternal(Request))
44 return Task.FromResult<IUser>(new InternalUser());
45 else
46 return Task.FromResult<IUser>(null);
47 }
48
55 public static bool IsInternal(HttpRequest Request)
56 {
57 return IsLocal(Request.LocalEndPoint) && IsLocal(Request.RemoteEndPoint);
58 }
59
60 private static bool IsLocal(string EndPoint)
61 {
62 if (EndPoint == "internal")
63 return true;
64
65 EndPoint = EndPoint.RemovePortNumber();
66
67 if (EndPoint == "127.0.0.1" || EndPoint == "[::1]" || EndPoint == "localhost")
68 return true;
69
70 return false;
71 }
72
73 internal class InternalUser : IUser
74 {
75 public string PasswordHash => string.Empty;
76 public string PasswordHashType => string.Empty;
77 public string UserName => "Internal";
78 public string FederatedUserName => this.UserName;
79 public string FriendlyName => this.UserName;
80
81 public bool HasPrivilege(string Privilege)
82 {
83 return false;
84 }
85 }
86 }
87}
Base class for all HTTP authentication schemes, as defined in RFC-7235: https://datatracker....
Represents an HTTP request.
Definition: HttpRequest.cs:22
string RemoteEndPoint
Remote end-point.
Definition: HttpRequest.cs:243
string LocalEndPoint
Local end-point.
Definition: HttpRequest.cs:248
Access scheme used for internal transfer of files between client and server.
override string[] GetChallenges(HttpRequest Request)
Gets available challenges for the authenticating client to respond to.
static bool IsInternal(HttpRequest Request)
Checks if a request is an internal transfer request, meaning that both the local and remote end point...
InternalTransferAccess()
Access scheme used for internal transfer of files between client and server.
override Task< IUser > IsAuthenticated(HttpRequest Request)
Checks if the request is authorized.
override string DisplayName
Display name for authentication scheme.
Basic interface for a user.
Definition: IUser.cs:7