diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-10-09 17:50:12 +1100 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2023-10-09 17:50:12 +1100 |
| commit | ea89ec0c1b05ac246f2ffd5907daace27564100b (patch) | |
| tree | 39d870b5167e0cab112a85dadcd8d8e67785b446 /Services | |
| parent | 36757ad31901cce4bb55f4911a28bb63ee1dee7a (diff) | |
| parent | 299e58db28202be8706dee1c570c382e1489213b (diff) | |
Merge branch 'security' of gitlab.com:plasmicplexus/HyperBooru-Server into security
Diffstat (limited to 'Services')
| -rw-r--r-- | Services/SecurityService.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Services/SecurityService.cs b/Services/SecurityService.cs index e365266..2d23a58 100644 --- a/Services/SecurityService.cs +++ b/Services/SecurityService.cs @@ -5,6 +5,15 @@ using System.Data; namespace HyperBooru.Services; public interface ISecurityService { + public IPrincipal[]? SearchPrincipals(string name); + public IPrincipal? GetPrincipal(string name); + public IUser? GetUser(string name); + public IGroup? GetGroup(string name); + public bool ValidatePassword(IUser user, string password); + + public SecurityIdentifier? TranslateName(string name); + public string TranslateName(SecurityIdentifier sid); + public IEnumerable<HBObject> Filter( IEnumerable<HBObject> objects, IPrincipal principal, @@ -51,6 +60,37 @@ public class SecurityService : ISecurityService { }; } + public IPrincipal[]? SearchPrincipals(string name) => + principalProvider.SearchPrincipals(name); + + public IPrincipal? GetPrincipal(string name) => + principalProvider.GetPrincipal(name); + + public IUser? GetUser(string name) => + principalProvider.GetUser(name); + + public IGroup? GetGroup(string name) => + principalProvider.GetGroup(name); + + public bool ValidatePassword(IUser user, string password) => + principalProvider.ValidatePassword(user, password); + + public string TranslateName(SecurityIdentifier sid) { + var wellKnownSid = WellKnownSid.TranslateName(sid); + if(wellKnownSid is not null) + return wellKnownSid; + + return sid.SddlForm; + } + + public SecurityIdentifier? TranslateName(string name) { + var wellKnownSid = WellKnownSid.TranslateName(name); + if(wellKnownSid is not null) + return wellKnownSid; + + throw new NotImplementedException(); + } + public IEnumerable<HBObject> Filter( IEnumerable<HBObject> objects, IPrincipal principal, |
