Publish curated ITWorx_MCP_Hub source from e1fd00a3172eaaec29bf8f1e6e47f96d175c31ff
This commit is contained in:
1 parent
cb5be898ea
commit
5ff5c807d3
5 files changed
+140
-140
No files matched your search
@@ -1,33 +1,33 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidatePattern('^[a-z0-9][a-z0-9-]*$')]
|
||||
[string]$Project,
|
||||
[string]$OutputDirectory = (Join-Path $env:LOCALAPPDATA 'ITWorx\MCP Hub\credentials'),
|
||||
[switch]$Rotate
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
New-Item -ItemType Directory -Path $OutputDirectory -Force | Out-Null
|
||||
$path = Join-Path $OutputDirectory "$Project.credential"
|
||||
if ((Test-Path -LiteralPath $path) -and -not $Rotate) {
|
||||
throw "Credential already exists at $path. Use -Rotate only for an intentional rotation."
|
||||
}
|
||||
$bytes = New-Object byte[] 48
|
||||
[System.Security.Cryptography.RandomNumberGenerator]::Fill($bytes)
|
||||
$value = [Convert]::ToBase64String($bytes).TrimEnd('=').Replace('+', '-').Replace('/', '_')
|
||||
[System.IO.File]::WriteAllText($path, $value, [System.Text.UTF8Encoding]::new($false))
|
||||
|
||||
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
||||
$acl = New-Object System.Security.AccessControl.FileSecurity
|
||||
$acl.SetOwner([System.Security.Principal.NTAccount]::new($identity))
|
||||
$acl.SetAccessRuleProtection($true, $false)
|
||||
$acl.AddAccessRule([System.Security.AccessControl.FileSystemAccessRule]::new(
|
||||
$identity,
|
||||
[System.Security.AccessControl.FileSystemRights]::FullControl,
|
||||
[System.Security.AccessControl.AccessControlType]::Allow
|
||||
))
|
||||
Set-Acl -LiteralPath $path -AclObject $acl
|
||||
[Array]::Clear($bytes, 0, $bytes.Length)
|
||||
$value = $null
|
||||
Write-Output $path
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidatePattern('^[a-z0-9][a-z0-9-]*$')]
|
||||
[string]$Project,
|
||||
[string]$OutputDirectory = (Join-Path $env:LOCALAPPDATA 'ITWorx\MCP Hub\credentials'),
|
||||
[switch]$Rotate
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
New-Item -ItemType Directory -Path $OutputDirectory -Force | Out-Null
|
||||
$path = Join-Path $OutputDirectory "$Project.credential"
|
||||
if ((Test-Path -LiteralPath $path) -and -not $Rotate) {
|
||||
throw "Credential already exists at $path. Use -Rotate only for an intentional rotation."
|
||||
}
|
||||
$bytes = New-Object byte[] 48
|
||||
[System.Security.Cryptography.RandomNumberGenerator]::Fill($bytes)
|
||||
$value = [Convert]::ToBase64String($bytes).TrimEnd('=').Replace('+', '-').Replace('/', '_')
|
||||
[System.IO.File]::WriteAllText($path, $value, [System.Text.UTF8Encoding]::new($false))
|
||||
|
||||
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
||||
$acl = New-Object System.Security.AccessControl.FileSecurity
|
||||
$acl.SetOwner([System.Security.Principal.NTAccount]::new($identity))
|
||||
$acl.SetAccessRuleProtection($true, $false)
|
||||
$acl.AddAccessRule([System.Security.AccessControl.FileSystemAccessRule]::new(
|
||||
$identity,
|
||||
[System.Security.AccessControl.FileSystemRights]::FullControl,
|
||||
[System.Security.AccessControl.AccessControlType]::Allow
|
||||
))
|
||||
Set-Acl -LiteralPath $path -AclObject $acl
|
||||
[Array]::Clear($bytes, 0, $bytes.Length)
|
||||
$value = $null
|
||||
Write-Output $path
|
||||
Reference in new issue
Block a user