-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Windows Hello Authentication #83
Draft
nzbr
wants to merge
2
commits into
nix-community:main
Choose a base branch
from
nzbr:windows-hello
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ lib, pkgs, config, ... }: | ||
|
||
with builtins; with lib; | ||
{ | ||
|
||
options.wsl.windowsHello = { | ||
enable = mkEnableOption "Authentication using Windows Hello"; | ||
}; | ||
|
||
config = | ||
let | ||
cfg = config.wsl.windowsHello; | ||
in | ||
mkIf (config.wsl.enable && cfg.enable) { | ||
|
||
security.sudo.wheelNeedsPassword = true; | ||
security.sudo.extraConfig = '' | ||
Defaults rootpw | ||
''; | ||
|
||
# Hijack the pam_usb module, because NixOS does not allow for adding custom PAM modules at the moment | ||
security.pam.usb.enable = true; | ||
nixpkgs.overlays = [ | ||
(self: super: { | ||
pam_usb = | ||
let | ||
authenticator = pkgs.stdenv.mkDerivation { | ||
name = "WindowsHelloAuthenticator.exe"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/nzbr/PAM-WindowsHello/releases/download/v1/WindowsHelloAuthenticator.exe"; | ||
sha256 = "4856a1fefa5c869b78890f9313a560d310e9c11f2a2a212c2868cf292792ff7f"; | ||
}; | ||
dontUnpack = true; | ||
buildCommand = '' | ||
install -m 0755 $src $out | ||
''; | ||
}; | ||
wrapper = pkgs.writeShellScript "wrapper" '' | ||
export PATH=${pkgs.coreutils}/bin # The PAM environment does not include the default PATH | ||
export WSL_INTEROP="/run/WSL/$(ls -tr /run/WSL | tail -n1)" # Find the correct WSL_INTEROP socket to be able to start the EXE | ||
exec ${authenticator} [$PAM_SERVICE] $PAM_RUSER wants to authenticate as $PAM_USER | ||
''; | ||
in | ||
"${pkgs.pam}/lib/security/pam_exec.so ${wrapper} \n# "; | ||
}) | ||
]; | ||
|
||
}; | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make a proper package out of that. Could we build it from source, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it'd be possible to build from source. The program has build-time dependencies against
Windows.winmd
andSystem.Runtime.WindowsRuntime.dll
If there's any way to get those files into the nix store, it might be possible to build with Mono though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are on nuget https://www.nuget.org/packages/Microsoft.Windows.WinMD/ https://www.nuget.org/packages/System.Runtime.WindowsRuntime/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expect that, thanks! I'll look into it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it now (the correct package is https://www.nuget.org/packages/Microsoft.Windows.SDK.Contracts btw. The one above seems to be for parsing WinMD files), however I could not get msbuild on Linux to compile the executable. It always threw an error about a missing assembly reference. I also tried porting the helper to .NET 6, but that wouldn't build on Linux either because
NETSDK1100: Windows is required to build Windows desktop applications
. I had initially meant to build it in .NET 6, but couldn't figure out how to import WinRT then. In retrospect that was fortunate, because now I learned that .NET 6 would require having an additional .dll in the same directory as the .exe, whereas .NET Framework only requires the .exe to be presentTL;DR Unfortunately it looks like there is no way to build the helper on linux