Npam 1.0.1
See the version list below for details.
dotnet add package Npam --version 1.0.1
NuGet\Install-Package Npam -Version 1.0.1
<PackageReference Include="Npam" Version="1.0.1" />
paket add Npam --version 1.0.1
#r "nuget: Npam, 1.0.1"
// Install Npam as a Cake Addin #addin nuget:?package=Npam&version=1.0.1 // Install Npam as a Cake Tool #tool nuget:?package=Npam&version=1.0.1
Npam
Npam is a dotnet core interface and wrapper around the UNIX Pluggable Authentication Modules (PAM) libraries. Npam also includes dotnet core interfaces into other related library calls for group and account information. Npam is built on Linux-PAM but should easily work with other unix systems.
Table of Contents
Compatibility
Npam has been tested on Ubuntu 16.04 (dotnet core version 3.1). However, PAM is available on most linux and unix systems and this library should work on Mac, BSD and most linux distros. So feel free to give it a try and create a PR or issue if you run into any problems.
Using the Npam Library
Npam prerequisits
Before using the library, you will also need to ensure that the PAM development libraries are installed for your distro.
For Ubuntu:sudo apt-get install libpam0g-dev
and for Fedora: sudo dnf -y install pam-devel
Getting the Npam Library
The best way to make use of the Npam library is to include it as a nuget dependency. Npam is available on nuget at https://www.nuget.org/packages/Npam
As below, you'll need to add a Npam dependency to your app's project.json and run dotnet restore to get the library.
{
"name" : "Npam-sample",
...
"dependencies": { "Npam" : "1.0.1" },
...
}
Calling into the Npam Library
There are 2 interfaces into PAM through this library. NpamUser and NpamSession.
NpamUser
A static class with 3 public methods to call into PAM and related interfaces for group and account information. Useful when the calling application just needs to authenticate users and retrieve assoicated information and does not require more complex interaction with PAM. Only allows for interaction with PAM modules which require a single password response to PAM conversation messages.
For an example app using NpamUser, have a look here: https://github.com/CamW/npam/blob/master/src/Npam.Example.User/Program.cs
NpamSession
A session class which allows the calling application to establish a PAM session and interact with the session. Only destroying the underlying session on disposal of the NpamSession. NpamSession is more powerful than PamUser, allowing for custom PAM conversation handling and by extension, interaction with PAM modules which require more than just a password for authentication.
For an example app using NpamSession, have a look here: https://github.com/CamW/npam/blob/master/src/Npam.Example.Session/Program.cs
Using the Npam source
Below are the commands you would use to get, restore, build and run the Npam library, tests and example applications.
On Ubuntu
Install pam-devel:
sudo apt-get install libpam0g-dev
From your home dir, clone repo:
git clone https://github.com/camw/npam
Run the setup test account script to create a test user. This creates a user with username userxyz and a password of pwd123 which is used in the Npam test suite and can be used with the two example applications too:
~/npam/test/setup_test_account.sh
Restore, build and run the Example.User app:
cd ~/npam/src/Npam.Example.User/
dotnet restore
sudo dotnet run
Restore, build and run the Example.Session app:
cd ~/npam/src/Npam.Example.Session/
dotnet restore
sudo dotnet run
Restore, build and run the Npam test suite:
cd ~/npam/test/Npam.Tests/
dotnet restore
sudo dotnet test
On Fedora
Install pam-devel:
sudo dnf -y install pam-devel
From your home dir, clone repo:
git clone https://github.com/camw/npam
Run the setup test account script to create a test user. This creates a user with username userxyz and a password of pwd123 which is used in the Npam test suite and can be used with the two example applications too:
~/npam/test/setup_test_account.sh
Restore, build and run the Example.User app:
cd ~/npam/src/Npam.Example.User/
dotnet restore
sudo /opt/dotnet/dotnet run
Restore, build and run the Example.Session app:
cd ~/npam/src/Npam.Example.Session/
dotnet restore
sudo /opt/dotnet/dotnet run
Npam test suite has known issues on Fedora 23. Doing a dotnet restore on the project results in the following error:
log : Restoring packages for /root/npam/test/Npam.Tests/project.json...
log : Failed to download package from 'https://api.nuget.org/v3-flatcontainer/system.runtime.handles/4.0.1-rc2-24027/system.runtime.handles.4.0.1-rc2-24027.nupkg'.
log : Response status code does not indicate success: 404 (Not Found).
On Other Systems
PAM is available on most *nix systems and this library should work on Mac, BSD and most linux distros. So feel free to give it a try and create a PR or issue.
Future Plans
Npam only supports a limited subset of what is available ideally this should be expanded on.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.2 is compatible. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.2
- NETStandard.Library (>= 1.6.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Npam:
Package | Downloads |
---|---|
CoreRemoting.Authentication.LinuxPamAuthProvider
Linux user authentication provider for CoreRemoting |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 4,935 | 3/22/2021 |
1.0.1 | 19,884 | 3/2/2020 |
1.0.0 | 11,460 | 8/25/2016 |
1.0.0-beta | 1,108 | 8/19/2016 |