forked from theRainbird/CoreRemoting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added generic OS authentication provider
- Loading branch information
1 parent
a004fb9
commit ff9e563
Showing
10 changed files
with
96 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...entication.GenericOsAuthProvider/CoreRemoting.Authentication.GenericOsAuthProvider.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<RootNamespace>CoreRemoting.Authentication</RootNamespace> | ||
<AssemblyName>CoreRemoting.Authentication.GenericOsAuthProvider</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CoreRemoting.Authentication.LinuxPamAuthProvider\CoreRemoting.Authentication.LinuxPamAuthProvider.csproj" /> | ||
<ProjectReference Include="..\CoreRemoting.Authentication.WindowsAuthProvider\CoreRemoting.Authentication.WindowsAuthProvider.csproj" /> | ||
<ProjectReference Include="..\CoreRemoting\CoreRemoting.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
40 changes: 40 additions & 0 deletions
40
CoreRemoting.Authentication.GenericOsAuthProvider/GenericOsAuthProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace CoreRemoting.Authentication | ||
{ | ||
/// <summary> | ||
/// Authentication provider to check credentials against local operationg system user accounts. | ||
/// Works with Windows user accounts (local or domain) an local linux user accounts (passwd). | ||
/// </summary> | ||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] | ||
public class GenericOsAuthProvider : IAuthenticationProvider | ||
{ | ||
public const string CREDENTIAL_TYPE_USERNAME = "username"; | ||
public const string CREDENTIAL_TYPE_PASSWORD = "password"; | ||
|
||
/// <summary> | ||
/// Authenticates the provided credentials and returns the authenticated identity, if successful. | ||
/// </summary> | ||
/// <param name="credentials">Array of credentials ("username", "password" and optional "domain" [Windows AD only])</param> | ||
/// <param name="authenticatedIdentity">Authenticated Identity</param> | ||
/// <returns>Indicates whether the authentication was successful.</returns> | ||
public bool Authenticate(Credential[] credentials, out RemotingIdentity authenticatedIdentity) | ||
{ | ||
authenticatedIdentity = null; | ||
|
||
IAuthenticationProvider authProvider = null; | ||
|
||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
authProvider = new WindowsAuthProvider(); | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
authProvider = new LinuxPamAuthProvider(); | ||
|
||
if (authProvider == null) | ||
throw new PlatformNotSupportedException(); | ||
|
||
return authProvider.Authenticate(credentials, out authenticatedIdentity); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.