Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leastprivilege committed Mar 20, 2012
0 parents commit 18bf6eb
Show file tree
Hide file tree
Showing 334 changed files with 97,855 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
bin/
obj/
packages/
TestResults/
build/
DefaultConfiguration/
Documentation/
csx/
Profiles/

ServiceConfiguration.Cloud.cscfg
ServiceConfiguration.Local.cscfg
ServiceDefinition.build.csdef
testimpactdata.sdf
Packages.dgml
*.suo
*.user
6 changes: 6 additions & 0 deletions Azure/.nuget/NuGet.Config
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added Azure/.nuget/NuGet.exe
Binary file not shown.
52 changes: 52 additions & 0 deletions Azure/.nuget/NuGet.targets
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<PackageSources>""</PackageSources>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>

<!-- Commands -->
<RestoreCommand>"$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
<BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true" />
</Target>
</Project>
65 changes: 65 additions & 0 deletions Azure/Azure Scripts/Add-Claims.ps1
@@ -0,0 +1,65 @@
<#
.SYNOPSIS
Adds claims to an IdentityServer table storage user
.DESCRIPTION
Adds claims to an IdentityServer table storage user
.PARAMETER claims
One or multiple claim type/value pairs separated by % (see examples)
.PARAMETER username
Logon name of the user
.PARAMETER connectionString
Connection string to table storage
.EXAMPLE
Add-Claims -username alice -connectionString 'connectionstring to storage' -claims claimtype1%value1, claimtype2%value2
#>

[CmdletBinding()]
param(
[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$username,

[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string[]]$claims,

[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$connectionString
)

begin {
$wif = $env:ProgramFiles + "\Reference Assemblies\Microsoft\Windows Identity Foundation\v3.5\Microsoft.IdentityModel.dll"

Add-Type -Path "Thinktecture.IdentityServer.WindowsAzure.dll"
Add-Type -Path $wif
}

process {

$claimsList = New-Object System.Collections.Generic.List[Microsoft.IdentityModel.Claims.Claim]

foreach ($claim in $claims) {
$items = $claim.split("%")
$wifClaim = New-Object Microsoft.IdentityModel.Claims.Claim -ArgumentList $items[0], $items[1]

$claimsList.Add($wifClaim)
}

try {
$context = New-Object Thinktecture.IdentityServer.Repositories.WindowsAzure.TableStorageContext -arg $connectionString
$context.AddUserClaims($username, $claimsList)
}
catch {
Write-Error $_.Exception.ToString()
}
}
69 changes: 69 additions & 0 deletions Azure/Azure Scripts/Add-User.ps1
@@ -0,0 +1,69 @@
<#
.SYNOPSIS
Adds a user to the IdentityServer table storage
.DESCRIPTION
Adds a user to the IdentityServer table storage
.PARAMETER username
Logon name of the user
.PARAMETER password
password of the user
.PARAMETER isAdmin
Specifies whether the user should be able to administrate IdentityServer
.PARAMETER connectionString
Connection string to table storage
#>

[CmdletBinding()]
param(
[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$username,

[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[ValidateLength(7,255)]
[string]$password,

[Parameter(
Mandatory=$False,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[switch]$isAdmin = $false,

[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$connectionString
)

begin {
Add-Type -Path "Thinktecture.IdentityServer.WindowsAzure.dll"

try {
[Thinktecture.IdentityServer.Repositories.WindowsAzure.TableStorageContext]::SetupTables($connectionString)
}
catch {
Write-Error $_.Exception.ToString()
exit
}
}

process {
try {
$context = New-Object Thinktecture.IdentityServer.Repositories.WindowsAzure.TableStorageContext -arg $connectionString
$context.AddUserAccount($username, $password, $isAdmin)
}
catch {
Write-Error $_.Exception.ToString()
}
}

42 changes: 42 additions & 0 deletions Azure/Azure Scripts/Delete-User.ps1
@@ -0,0 +1,42 @@
<#
.SYNOPSIS
Deletes a user from the IdentityServer table storage
.DESCRIPTION
Deletes a user from the IdentityServer table storage
.PARAMETER username
Logon name of the user
.PARAMETER connectionString
Connection string to table storage
#>

[CmdletBinding()]
param(
[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$username,

[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$connectionString
)

begin {
Add-Type -Path "Thinktecture.IdentityServer.WindowsAzure.dll"
}

process {
try {
$context = New-Object Thinktecture.IdentityServer.Repositories.WindowsAzure.TableStorageContext -arg $connectionString

$context.DeleteUserAccount($username)
}
catch {
Write-Error $_.Exception.ToString()
}
}
86 changes: 86 additions & 0 deletions Azure/Azure Scripts/Enable-DotNet4Access.ps1
@@ -0,0 +1,86 @@
<#
.SYNOPSIS
Enables PowerShell access to the .NET 4.0 framework by creating a configuration file.
.DESCRIPTION
Enables PowerShell access to the .NET 4.0 framework by creating a configuration file. You will need to
restart PowerShell in order for this to take effect. In a default installation of PowerShell V2, these
files do not exist.
.PARAMETER Computername
Name of computer to enable .NET 4 for PowerShell against.
.PARAMETER Console
Apply configuration change for console only
.PARAMETER ISE
Apply configuration change to ISE only
.NOTES
Name: Enable-DotNet4Access
Author: Boe Prox
DateCreated: 10JAN2012
.LINK
https://learn-powershell.net
.EXAMPLE
Enable-DotNet4Access -Console -ISE
Description
-----------
Enables .NET 4.0 access for PowerShell on console and ISE
#>

[cmdletbinding(
SupportsShouldProcess = $True
)]
Param (
[parameter(Position='0',ValueFromPipeLine = $True,ValueFromPipelineByPropertyName=$True)]
[Alias('__Server','Computer','Server','CN')]
[string[]]$Computername,
[parameter(Position='1')]
[switch]$Console,
[parameter(Position='2')]
[switch]$ISE
)
Begin {
Write-Verbose ("Creating file data")
$file = @'
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
'@
}
Process {
If (-Not $PSBoundParameters['Computername']) {
Write-Warning ("No computername given! Using {0} as computername." -f $Env:Computername)
$Computername = $Env:Computername
}
ForEach ($Computer in $computername) {
If ($PSBoundParameters['Console']) {
If ($pscmdlet.ShouldProcess("Console","Enable .NET 4.0 Access")) {
Try {
$file | Out-file "\\$computer\C$\Windows\System32\WindowsPowerShell\v1.0\PowerShell.Exe.Config" -Force
Write-Host ("{0}: Console must be restarted before changes will take effect!" -f $Computer) -fore Green -Back Black
} Catch {
Write-Warning ("{0}: {1}" -f $computer,$_.Exception.Message)
}
}
}
If ($PSBoundParameters['ISE']) {
If ($pscmdlet.ShouldProcess("ISE","Enable .NET 4.0 Access")) {
Try {
$file | Out-file "\\$computer\C$\Windows\System32\WindowsPowerShell\v1.0\PowerShell_ISE.Exe.Config" -Force
Write-Host ("{0}: ISE must be restarted before changes will take effect!" -f $Computer) -fore Green -Back Black
} Catch {
Write-Warning ("{0}: {1}" -f $computer,$_.Exception.Message)
}
}
}
}
}
48 changes: 48 additions & 0 deletions Azure/Azure Scripts/List-Claims.ps1
@@ -0,0 +1,48 @@
<#
.SYNOPSIS
Lists alls claims for a user from the IdentityServer table storage
.DESCRIPTION
Lists alls claims for a user from the IdentityServer table storage
.PARAMETER username
Logon name of the user
.PARAMETER connectionString
Connection string to table storage
#>

[CmdletBinding()]
param(
[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$username,

[Parameter(
Mandatory=$True,
ValueFromPipeline=$False,
ValueFromPipelineByPropertyName=$True
)]
[string]$connectionString
)

begin {
Add-Type -Path "Thinktecture.IdentityServer.WindowsAzure.dll"
}

process {
try {
$context = New-Object Thinktecture.IdentityServer.Repositories.WindowsAzure.TableStorageContext -arg $connectionString

$claims = $context.GetUserClaims($username)
Write-Host

foreach ($claim in $claims) {
Write-Host $claim.ClaimType
Write-Host " " $claim.Value `n
}
}
catch {
Write-Error $_.Exception.ToString()
}
}

0 comments on commit 18bf6eb

Please sign in to comment.