File tree Expand file tree Collapse file tree 7 files changed +39
-17
lines changed
Expand file tree Collapse file tree 7 files changed +39
-17
lines changed Original file line number Diff line number Diff line change 11# Description: This script is used to make a GET request to an API endpoint with basic authentication.
22# Usage: powershell -File api-script.ps1
33
4- $username = " admin "
5- $password = " password "
4+ $username = $ env: API_USERNAME
5+ $password = $ env: API_PASSWORD
66$credentials = " {$username }:{$password }"
77$credentialBytes = [System.Text.Encoding ]::ASCII.GetBytes($credentials )
88$base64AuthInfo = [Convert ]::ToBase64String($credentialBytes )
Original file line number Diff line number Diff line change 11# Description: This script is used to make a GET request to an API endpoint with basic authentication.
22# Usage: powershell -File api-script.ps1
33
4- $username = " admin "
5- $password = " password "
4+ $username = $ env: API_USERNAME
5+ $password = $ env: API_PASSWORD
66$credentials = " {$username }:{$password }"
77$credentialBytes = [System.Text.Encoding ]::ASCII.GetBytes($credentials )
88$base64AuthInfo = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes($credentialBytes ))
@@ -15,5 +15,4 @@ $headers = @{
1515 Authorization = $basicAuthHeader
1616 " Content-Type" = " application/json"
1717}
18-
19- Invoke-RestMethod - Uri " $urlbase /" - Headers $headers - Method Get
18+ Invoke-RestMethod - Uri " $urlbase /" - Headers $headers - Method Get
Original file line number Diff line number Diff line change 1111
1212# The code below is used to authenticate with the EVE Online API using OAuth2
1313# The code is based on the example provided in the EVE Online documentation: https://esi.evetech.net/ui/?version=latest#/Character/get_characters_character_id
14- $clientID = " 539efdfedabe4ca19575d01b6ae5ba8e "
15- $clientSecret = " xBMQMOOZVxfQI8RQPSjKEKXvqsdJKybv8UceDZjY "
14+ $clientID = $ env: EVE_CLIENT_ID
15+ $clientSecret = $ env: EVE_CLIENT_SECRET
1616# $credentials = "{$username}:{$password}"
1717# $credentialBytes = [System.Text.Encoding]::ASCII.GetBytes($credentials)
1818# $base64AuthInfo = [Convert]::ToBase64String(($credentialBytes))
@@ -27,7 +27,7 @@ $assetsUrl = "https://esi.evetech.net/latest/characters/95282689/assets/"
2727$encodedAssets = [System.Web.HttpUtility ]::UrlEncode($assetsUrl )
2828Write-Host " Please visit this URL to authenticate: $authUrl "
2929
30- $authorizationCode = " ZaazFJl76kSX_87Z0GQJ1A "
30+ $authorizationCode = $ env: EVE_AUTH_CODE
3131
3232$body = @ {
3333 grant_type = " authorization_code"
@@ -52,5 +52,4 @@ $uri = "https://esi.evetech.net/latest/characters/95282689/"
5252$characterInfo = Invoke-RestMethod - Uri $uri - Headers $headers - Method Get
5353$characterInfo
5454
55- $assetResponse = Invoke-RestMethod - Uri " $encodedAssets " - Headers $headers - Method Get
56- $assetResponse
55+ $assetResponse = Invoke-RestMethod - Uri " $encodedAssets " - Headers $headers - Method Get$assetResponse
Original file line number Diff line number Diff line change 11[CmdletBinding ()]
22param (
3- [string ]$ClientID = " 539efdfedabe4ca19575d01b6ae5ba8e " ,
4- [string ]$ClientSecret = " xBMQMOOZVxfQI8RQPSjKEKXvqsdJKybv8UceDZjY " ,
3+ [string ]$ClientID = $ env: EVE_CLIENT_ID ,
4+ [string ]$ClientSecret = $ env: EVE_CLIENT_SECRET ,
55 [string ]$RedirectUri = " ???" , # Wondereing what to use for an end point because localhost:port is not an option - perhaps cloud run?
66 [string ]$Scopes = " publicData esi-assets.read_assets.v1"
77)
Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ Start-Process ".\response.html"
2929
3030$uri = " https://halo.tsg.com/status"
3131$body = @ {
32- email = " test@example.com "
33- password = " SuperSecret123 "
32+ email = $ env: TEST_EMAIL
33+ password = $ env: TEST_PASSWORD
3434} | ConvertTo-Json
3535
3636$response = Invoke-RestMethod - Uri $uri - Method Post - Body $body - ContentType ' application/json' - ErrorAction Stop
Original file line number Diff line number Diff line change 1+ # The Script Lab
2+
3+ This repository contains various PowerShell scripts for API testing, tooling and development experiments.
4+
5+ ## Providing Credentials
6+
7+ Some scripts require credentials. To avoid hard coding sensitive values, these scripts read their credentials from environment variables:
8+
9+ - ` API_USERNAME ` and ` API_PASSWORD ` for scripts in the ` API ` folder.
10+ - ` EVE_CLIENT_ID ` and ` EVE_CLIENT_SECRET ` for EVE Online authentication scripts.
11+ - ` EVE_AUTH_CODE ` for ` Development/eve-auth-api-test.ps1 ` .
12+ - ` TEST_EMAIL ` and ` TEST_PASSWORD ` for ` Pen-Test/payload.ps1 ` .
13+ - ` ELASTIC_USERNAME ` and ` ELASTIC_PASSWORD ` for ` Tooling/elastic-rule-report.ps1 ` .
14+
15+ Before running a script, export the required variables in your shell:
16+
17+ ``` powershell
18+ $env:API_USERNAME = 'myuser'
19+ $env:API_PASSWORD = 'mypassword'
20+ # set other variables as needed
21+ ```
22+
23+ Use your preferred secrets management solution to supply these values securely.
24+
Original file line number Diff line number Diff line change 88$ODS = Read-Host - Prompt " Please enter your ODS to search (ensure in CAPS e.g. 'RCU')"
99
1010$outputFile = " $env: USERPROFILE \Desktop\Generated-Rule-Report1.csv"
11- $Username = " synanetics-system "
12- $Password = " Kc1cmCxYDG^bP@cMDP5u "
11+ $Username = $ env: ELASTIC_USERNAME
12+ $Password = $ env: ELASTIC_PASSWORD
1313$credentials = " $ ( $Username ) :$ ( $Password ) "
1414$credentialBytes = [System.Text.Encoding ]::ASCII.GetBytes($credentials )
1515$EncodedCredentials = [System.Convert ]::ToBase64String($credentialBytes )
You can’t perform that action at this time.
0 commit comments