Last active
March 12, 2025 14:26
-
-
Save devorbitus/bb64300ecf1f88179300f55fedafcd5f to your computer and use it in GitHub Desktop.
Revisions
-
devorbitus revised this gist
Mar 12, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Install Nu Shell onto the target system, then run this command within a `nu` she This command will download the script and store it at the `archive.nu` locally and then make it executable. ```nu let archive = (http get https://gist.github.com/devorbitus/bb64300ecf1f88179300f55fedafcd5f/raw/818bdf143757eeeb66858e8250fa8efce935f0e9/akeyless-reference-archive.nu); $archive | save --force archive.nu; chmod +x archive.nu ``` -
devorbitus revised this gist
Mar 12, 2025 . No changes.There are no files selected for viewing
-
devorbitus revised this gist
Mar 12, 2025 . 1 changed file with 78 additions and 36 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,30 +2,90 @@ # Define API endpoint let api_endpoint = "api.akeyless.io" # Define minimum token validity duration let min_token_validity = 10min def validate_akeyless_token [token: string] { let validateToken = (http post --content-type application/json $"https://($api_endpoint)/validate-token" {token: $token}) let is_valid = ($validateToken | get is_valid) if $is_valid { let expirationDateString = ($validateToken | get expiration) let now = (date now) let timeUntilExpiration = ($expirationDateString | into datetime) - $now if $timeUntilExpiration < $min_token_validity { return { is_valid: false, message: $"Token will expire too soon (in ($timeUntilExpiration)). It must be valid for at least ($min_token_validity).", expiration: $expirationDateString, time_until_expiration: $timeUntilExpiration } } else { return { is_valid: true, message: $"Token is valid and will expire in ($timeUntilExpiration).", expiration: $expirationDateString, time_until_expiration: $timeUntilExpiration } } } else { return { is_valid: false, message: "Token is invalid.", expiration: null, time_until_expiration: null } } } def get_akeyless_token [] { mut input_token = "" while true { print $"Please enter your Akeyless token:" let token_input = (input) if ($token_input | is-empty) { print $"(ansi red_bold)Error:(ansi reset) Token cannot be empty" continue } if not ($token_input | str starts-with "t-") { print $"(ansi red_bold)Error:(ansi reset) Token must start with 't-'" continue } # Validate the token let validation_result = (validate_akeyless_token $token_input) if not ($validation_result.is_valid) { print $"(ansi red_bold)Error:(ansi reset) ($validation_result.message)" print "Please try again with a different token." continue } print $"(ansi green_bold)Success:(ansi reset) ($validation_result.message)" $input_token = $token_input break } return $input_token } def check_akeyless_token [] { if "AKEYLESS_TOKEN" in $env { print $"(ansi green_bold)Success:(ansi reset) AKEYLESS_TOKEN environment variable is set" # Validate the existing token let validation_result = (validate_akeyless_token $env.AKEYLESS_TOKEN) if not ($validation_result.is_valid) { print $"(ansi red_bold)Error:(ansi reset) ($validation_result.message)" print $"(ansi yellow)Getting a new token...(ansi reset)" let input_token = (get_akeyless_token) $env.AKEYLESS_TOKEN = $input_token } else { print $"(ansi green_bold)Success:(ansi reset) ($validation_result.message)" } } else { print $"(ansi yellow)AKEYLESS_TOKEN not found in environment(ansi reset)" let input_token = (get_akeyless_token) $env.AKEYLESS_TOKEN = $input_token } } @@ -42,24 +102,6 @@ if ($data_dir | path exists) == false { mkdir $data_dir } # List auth methods let authMethods = (http post --content-type application/json $"https://($api_endpoint)/list-auth-methods" {token: $token} | get auth_methods) -
devorbitus revised this gist
Mar 12, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Install Nu Shell onto the target system, then run this command within a `nu` she This command will download the script and store it at the `archive.nu` locally and then make it executable. ```nu let archive = (http get https://gist.github.com/devorbitus/bb64300ecf1f88179300f55fedafcd5f/raw/e166bcbc551a1234f91671163d5d2e9cd13e8696/akeyless-reference-archive.nu); $archive | save --force archive.nu; chmod +x archive.nu ``` -
devorbitus revised this gist
Mar 12, 2025 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,15 +8,23 @@ def check_akeyless_token [] { print $"(ansi green_bold)Success:(ansi reset) AKEYLESS_TOKEN environment variable is set" } else { print $"(ansi yellow)AKEYLESS_TOKEN not found in environment(ansi reset)" mut input_token = "" while true { print $"Please enter your Akeyless token:" let token_input = (input) if ($token_input | is-empty) { print $"(ansi red_bold)Error:(ansi reset) Token cannot be empty" continue } if not ($token_input | str starts-with "t-") { print $"(ansi red_bold)Error:(ansi reset) Token must start with 't-'" continue } $input_token = $token_input break } $env.AKEYLESS_TOKEN = $input_token } -
devorbitus revised this gist
Mar 12, 2025 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,18 @@ def check_akeyless_token [] { if "AKEYLESS_TOKEN" in $env { print $"(ansi green_bold)Success:(ansi reset) AKEYLESS_TOKEN environment variable is set" } else { print $"(ansi yellow)AKEYLESS_TOKEN not found in environment(ansi reset)" print $"Please enter your Akeyless token:" let input_token = (input) if ($input_token | is-empty) { print $"(ansi red_bold)Error:(ansi reset) Token cannot be empty" exit 1 } if not ($input_token | str starts-with "t-") { print $"(ansi red_bold)Error:(ansi reset) Token must start with 't-'" exit 1 } $env.AKEYLESS_TOKEN = $input_token } } -
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,12 +4,12 @@ let api_endpoint = "api.akeyless.io" def check_akeyless_token [] { if "AKEYLESS_TOKEN" in $env { print $"(ansi green_bold)Success:(ansi reset) AKEYLESS_TOKEN environment variable is set" } else { print $"(ansi red_bold)Error:(ansi reset) AKEYLESS_TOKEN environment variable is not set" print $"Please set the environment variable with: (ansi cyan)export AKEYLESS_TOKEN=your_t_token_value(ansi reset)" exit 1 } } -
devorbitus revised this gist
Mar 11, 2025 . No changes.There are no files selected for viewing
-
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,8 @@ Install Nu Shell onto the target system, then run this command within a `nu` she This command will download the script and store it at the `archive.nu` locally and then make it executable. ```nu let archive = (http get https://gist.github.com/devorbitus/bb64300ecf1f88179300f55fedafcd5f/raw/aba5ac3dfab0e39db5e25c1d34d70235d5fa7b1b/akeyless-reference-archive.nu); $archive | save --force archive.nu; chmod +x archive.nu ``` You can then run the command like so -
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ The script will create a `data`directory and place the JSON files into that dire Install Nu Shell onto the target system, then run this command within a `nu` shell. This command will download the script and store it at the `archive.nu` locally and then make it executable. ```nu let archive = (http get https://gist.github.com/devorbitus/bb64300ecf1f88179300f55fedafcd5f/raw/aba5ac3dfab0e39db5e25c1d34d70235d5fa7b1b/akeyless-reference-archive.nu); $archive | save --force archive.nu; chmod +x archive.nu -
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 17 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,20 @@ The script will create a `data`directory and place the JSON files into that dire ## Prerequisites - Install Nu Shell - Download the script and make it executable - Execute the script ## Installation Install Nu Shell onto the target system, then run this command within a `nu` shell. This command will download the script and store it at the `archive..nu` locally and then make it executable. ```nu let archive = (http get https://gist.github.com/devorbitus/bb64300ecf1f88179300f55fedafcd5f/raw/aba5ac3dfab0e39db5e25c1d34d70235d5fa7b1b/akeyless-reference-archive.nu); $archive | save --force archive.nu; chmod +x archive.nu ``` You can then run the command like so ```nu ./archive.nu ``` -
devorbitus revised this gist
Mar 11, 2025 . No changes.There are no files selected for viewing
-
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ if ($validateToken | get is_valid) != true { if $timeUntilExpiration < 10min { error make {msg: "The AKeyless Token must be valid for at least 10 minutes in the future!"} } else { print $"(ansi green_bold)The Akeyless Token expiration is in the future by (ansi reset)(ansi yellow_bold)($timeUntilExpiration)(ansi reset)(ansi green_bold). All good!(ansi reset)" } } -
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ if ($validateToken | get is_valid) != true { if $timeUntilExpiration < 10min { error make {msg: "The AKeyless Token must be valid for at least 10 minutes in the future!"} } else { print $"(ansi green_bold)The Akeyless Token expiration is in the future by ($timeUntilExpiration). All good!(ansi reset)" } } @@ -97,4 +97,4 @@ let describedItems = ($items | par-each { |item| }) # Save to file $describedItems | save -f (pwd | path join "data" "akeyless-items-archive.json") -
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ This script will use an Akeyless T-Token to authenticate to the API and download account details for reference WITHOUT accessing secret values. The script will create a `data`directory and place the JSON files into that directory. ## Prerequisites - Install Nu Shell - Download the script and make it executable -
devorbitus revised this gist
Mar 11, 2025 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # Akeyless Nu Shell Account Reference Archive This script will use an Akeyless T-Token to authenticate to the API and download account details for reference WITHOUT accessing secret values. ## Prerequisites - Install Nu Shell - Download the script and make it executable -
devorbitus renamed this gist
Mar 11, 2025 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
devorbitus created this gist
Mar 11, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,100 @@ #!/usr/bin/env nu # Define API endpoint let api_endpoint = "api.akeyless.io" def check_akeyless_token [] { if ($env | get -i AKEYLESS_TOKEN) == null { print $"(ansi red_bold)Error:(ansi reset) AKEYLESS_TOKEN environment variable is not set" print $"Please set the environment variable with: (ansi cyan)export AKEYLESS_TOKEN=your_t_token_value(ansi reset)" exit 1 } else { print $"(ansi green_bold)Success:(ansi reset) AKEYLESS_TOKEN environment variable is set" } } # Run the check check_akeyless_token # Get token from environment variable let token = $env.AKEYLESS_TOKEN # Create data directory if it doesn't exist let data_dir = (pwd | path join "data") if ($data_dir | path exists) == false { mkdir $data_dir } # Validate the token and make sure it's valid for at least 10 minutes let now = (date now) let validateToken = (http post --content-type application/json $"https://($api_endpoint)/validate-token" {token: $token}) if ($validateToken | get is_valid) != true { print $"(ansi red_bold)Error:(ansi reset) AKEYLESS_TOKEN is invalid" exit 1 } else { print $"(ansi green_bold)Success:(ansi reset) AKEYLESS_TOKEN is valid" print $"Token expiration: ($validateToken | get expiration)" let expirationDateString = ($validateToken | get expiration) let timeUntilExpiration = ($expirationDateString | into datetime) - $now if $timeUntilExpiration < 10min { error make {msg: "The AKeyless Token must be valid for at least 10 minutes in the future!"} } else { print $"The Akeyless Token expiration is in the future by ($timeUntilExpiration). All good!" } } # List auth methods let authMethods = (http post --content-type application/json $"https://($api_endpoint)/list-auth-methods" {token: $token} | get auth_methods) # Describe each auth method and collect results let authMethods = ($authMethods | each { |method| let name = ($method.auth_method_name | into string) print $"Processing auth method: ($name)" let authMethod = (http post --content-type application/json $"https://($api_endpoint)/get-auth-method" {token: $token, name: $name}) $authMethod }) # Save to file $authMethods | save -f (pwd | path join "data" "akeyless-auth-methods-archive.json") # List roles let roles = (http post --content-type application/json $"https://($api_endpoint)/list-roles" {token: $token} | get roles) # Describe each role and collect results let roles = ($roles | each { |role| let name = ($role.role_name | into string) print $"Processing role: ($name)" let role = (http post --content-type application/json $"https://($api_endpoint)/get-role" {token: $token, name: $name}) $role }) # Save to file $roles | save -f (pwd | path join "data" "akeyless-roles-archive.json") # List Targets let targets = (http post --content-type application/json $"https://($api_endpoint)/list-targets" {token: $token} | get targets) # Describe each target and collect results let targets = ($targets | each { |target| let name = ($target.target_name | into string) print $"Processing target: ($name)" let target = (http post --content-type application/json $"https://($api_endpoint)/get-target" {token: $token, name: $name}) $target }) # Save to file $targets | save -f (pwd | path join "data" "akeyless-targets-archive.json") # List items let items = (http post --content-type application/json $"https://($api_endpoint)/list-items" {token: $token} | get items) # Describe each item and collect results let describedItems = ($items | par-each { |item| let name = ($item.item_name | into string) print $"Processing item: ($name)" # Debug line let describeItem = (http post --content-type application/json $"https://($api_endpoint)/describe-item" {token: $token, name: $name}) $describeItem }) # Save to file $describedItems | save -f (pwd | path join "data" "akeyless-items-archive.json") This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ # Akeyless Nu Shell Account Reference Archive ## Prerequisites - Install Nu Shell - Download the script and make it executable - Execute the script