-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
saml2aws: init module #8134
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
base: master
Are you sure you want to change the base?
saml2aws: init module #8134
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -381,6 +381,18 @@ | |
| github = "mipmip"; | ||
| githubId = 658612; | ||
| }; | ||
| mokrinsky = { | ||
| name = "mokrinsky"; | ||
| email = "[email protected]"; | ||
| github = "mokrinsky"; | ||
| githubId = 463907; | ||
| keys = [ | ||
| { | ||
| longkeyid = "rsa4096/0x73CC011921471A15"; | ||
| fingerprint = "EA54 E892 D96C 779E 1FA6 4E0A 73CC 0119 2147 1A15"; | ||
| } | ||
| ]; | ||
| }; | ||
| msfjarvis = { | ||
| email = "[email protected]"; | ||
| github = "msfjarvis"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| time = "2025-11-05T12:54:50+00:00"; | ||
| condition = true; | ||
| message = '' | ||
| A new module is available: 'programs.saml2aws'. | ||
|
|
||
| saml2aws is a CLI tool which enables you to login and retrieve AWS temporary credentials using a SAML IDP. It support a bunch of SAML providers, from cloud ones like Akamai, Okta or OneLogin, to corporate or self-hosted like Authentik, KeyCloak or ADFS. | ||
| ''; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,94 @@ | ||||
| { | ||||
| config, | ||||
| lib, | ||||
| pkgs, | ||||
| ... | ||||
| }: | ||||
|
|
||||
| let | ||||
| cfg = config.programs.saml2aws; | ||||
| iniFormat = pkgs.formats.ini { }; | ||||
| inherit (lib) mkIf mkOption types; | ||||
| in | ||||
| { | ||||
| meta.maintainers = [ lib.hm.maintainers.mokrinsky ]; | ||||
|
|
||||
| options.programs.saml2aws = { | ||||
| enable = lib.mkEnableOption "saml2aws CLI tool"; | ||||
|
|
||||
| package = lib.mkPackageOption pkgs "saml2aws" { | ||||
| default = "saml2aws"; | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| nullable = true; | ||||
| }; | ||||
|
|
||||
| enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { | ||||
| inherit config; | ||||
| extraDescription = ''If enabled, this will install autocompletion for bash.''; | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the completions are the only benefit of the integration, aren't the shell completions already installed https://github.com/NixOS/nixpkgs/blob/c4e9b72d0bf394509a3b2aff27be35b7e3c99b85/pkgs/by-name/sa/saml2aws/package.nix#L33-L37 |
||||
| }; | ||||
|
|
||||
| enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { | ||||
| inherit config; | ||||
| extraDescription = ''If enabled, this will install autocompletion for zsh.''; | ||||
| }; | ||||
|
|
||||
| configLocation = mkOption { | ||||
| default = "${config.home.homeDirectory}/.saml2aws"; | ||||
| defaultText = lib.literalExpression ''"''${config.home.homeDirectory}/.saml2aws"''; | ||||
| type = types.str; | ||||
| example = lib.literalExpression ''"''${config.home.homeDirectory}/.config/.saml2aws"''; | ||||
| description = '' | ||||
| Environment variable to specify the location of saml2aws configuration. | ||||
| ''; | ||||
| }; | ||||
|
|
||||
| credentials = mkOption { | ||||
| type = types.submodule { freeformType = iniFormat.type; }; | ||||
| default = { }; | ||||
| example = lib.literalExpression '' | ||||
| { | ||||
| aws = { | ||||
| name = "aws"; | ||||
| url = "https://domain.tld/uri/of/your/auth/endpoint"; | ||||
| username = "username"; | ||||
| provider = "Authentik"; | ||||
| mfa = "Auto"; | ||||
| skip_verify = false; | ||||
| timeout = 0; | ||||
| aws_urn = "urn:amazon:webservices"; | ||||
| aws_session_duration = 3600; | ||||
| aws_profile = "123456789000"; | ||||
| saml_cache = false; | ||||
| disable_remember_device = false; | ||||
| disable_sessions = false; | ||||
| download_browser_driver = false; | ||||
| headless = false; | ||||
| }; | ||||
| } | ||||
| ''; | ||||
| description = '' | ||||
| Configuration written to {file}`$HOME/.saml2aws` or config.programs.saml2aws.configLocation. | ||||
| ''; | ||||
| }; | ||||
| }; | ||||
|
|
||||
| config = mkIf cfg.enable { | ||||
| home = { | ||||
| packages = mkIf (cfg.package != null) [ cfg.package ]; | ||||
|
|
||||
| sessionVariables.SAML2AWS_CONFIGFILE = cfg.configLocation; | ||||
|
|
||||
| file."${cfg.configLocation}" = mkIf (cfg.credentials != { }) { | ||||
| source = iniFormat.generate "saml2aws-credentials-${config.home.username}" cfg.credentials; | ||||
| }; | ||||
| }; | ||||
|
|
||||
| programs.bash.initExtra = mkIf cfg.enableBashIntegration '' | ||||
| eval "$(${lib.getExe cfg.package} --completion-script-bash)" | ||||
| ''; | ||||
|
|
||||
| programs.zsh.initContent = mkIf cfg.enableZshIntegration '' | ||||
| eval "$(${lib.getExe cfg.package} --completion-script-zsh)" | ||||
| ''; | ||||
|
|
||||
| }; | ||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| saml2aws = ./saml2aws.nix; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [aws] | ||
| aws_profile=123456789000 | ||
| aws_session_duration=3600 | ||
| aws_urn=urn:amazon:webservices | ||
| disable_remember_device=false | ||
| disable_sessions=false | ||
| download_browser_driver=false | ||
| headless=false | ||
| mfa=Auto | ||
| name=aws | ||
| provider=Authentik | ||
| saml_cache=false | ||
| skip_verify=false | ||
| timeout=0 | ||
| url=https://domain.tld/uri/of/your/auth/endpoint | ||
| username=username |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| programs = { | ||
| saml2aws = { | ||
| enable = true; | ||
| credentials = { | ||
| aws = { | ||
| name = "aws"; | ||
| url = "https://domain.tld/uri/of/your/auth/endpoint"; | ||
| username = "username"; | ||
| provider = "Authentik"; | ||
| mfa = "Auto"; | ||
| skip_verify = false; | ||
| timeout = 0; | ||
| aws_urn = "urn:amazon:webservices"; | ||
| aws_session_duration = 3600; | ||
| aws_profile = "123456789000"; | ||
| saml_cache = false; | ||
| disable_remember_device = false; | ||
| disable_sessions = false; | ||
| download_browser_driver = false; | ||
| headless = false; | ||
| }; | ||
|
|
||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| nmt.script = '' | ||
| assertFileExists home-files/.saml2aws | ||
| assertFileContent home-files/.saml2aws \ | ||
| ${./saml2aws.conf} | ||
| ''; | ||
| } |
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.
Separate commit before module addition, please.