Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from brandwe/master
PHP Pull request for Azure Active Directory
- Loading branch information
Showing
28 changed files
with
1,550 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
################# | ||
## Eclipse | ||
################# | ||
|
||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
|
||
################# | ||
## Visual Studio | ||
################# | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Rr]elease/ | ||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.vspscc | ||
.builds | ||
*.dotCover | ||
|
||
## TODO: If you have NuGet Package Restore enabled, uncomment this | ||
#packages/ | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper* | ||
|
||
# Installshield output folder | ||
[Ee]xpress | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish | ||
|
||
# Others | ||
[Bb]in | ||
[Oo]bj | ||
sql | ||
TestResults | ||
*.Cache | ||
ClientBin | ||
stylecop.* | ||
~$* | ||
*.dbmdl | ||
Generated_Code #added for RIA/Silverlight projects | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
|
||
|
||
|
||
############ | ||
## Windows | ||
############ | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
|
||
############# | ||
## Python | ||
############# | ||
|
||
*.py[co] | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Translations | ||
*.mo | ||
|
||
#Mr Developer | ||
.mr.developer.cfg | ||
|
||
# Mac crap | ||
.DS_Store |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
| ||
PRE-REQUISITES BEFORE USING THIS SAMPLE | ||
|
||
************************************************* | ||
|
||
Step 1: Create the Microsoft.Samples.Waad.PS.dll | ||
|
||
************************************************* | ||
|
||
In order to use the PowerShell cmdlets provided under the %ROOT%/php/scripts/ directory, you will need to build the DLL that provides the WAAD functionality. | ||
|
||
We have included the source for building this DLL in this code for your convenience. It is located at: | ||
|
||
%ROOT%/csharp/code/libraries/powershell/Microsoft.Samples.Waad.PS/ | ||
|
||
You have two options to build this DLL: | ||
|
||
1. Build using VS 2010 Tools Command Line and included batch file | ||
|
||
You can build this DLL easily by running: | ||
|
||
%ROOT%/csharp/code/libraries/powershell/Microsoft.Samples.Waad.PS/buildWaadPS.bat | ||
|
||
This will build the DLL and copy the DLL to the correct location under %ROOT%/php/scripts/ | ||
|
||
2. Load the .csproj file and build under Visual Studio 2010 or higher | ||
|
||
This is located under %ROOT%/csharp/code/libraries/powershell/Microsoft.Samples.Waad.PS. You will need to ensure that the Microsoft.Samples.Waad.PS.dll file is moved to the correct location under %ROOT%/csharp/scripts/ | ||
|
||
|
||
The rest of the setup instructions and walk-through are located at: | ||
|
||
http://www.windowsazure.com/en-us/develop/php/how-to-guides/web-sso/ | ||
|
||
|
||
******************************************************************** | ||
|
||
STEP 2: Download the simpleSAMLphp library | ||
|
||
******************************************************************** | ||
|
||
SimpleSAMLphp is an award-winning application written in native PHP that deals with authentication. The project is led by UNINETT, has a large user base, a helpful user community and a large set of external contributors. | ||
|
||
SimpleSAMLphp is having a main focus on providing support for: | ||
•SAML 2.0 as a Service Provider. | ||
•SAML 2.0 as a Identity Provider. | ||
|
||
But also supports some other identity protocols, such as Shibboleth 1.3, A-Select, CAS, OpenID, WS-Federation and OAuth. | ||
|
||
You can download this by going to: http://simplesamlphp.org/ | ||
|
||
and including the base install underneath the root directory such as: | ||
|
||
%ROOT/simplesamlphp | ||
|
||
|
||
|
||
Enjoy! | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
azure-sdk-for-php-samples | ||
========================= | ||
|
||
PHP Sample for articles on windowsazure.com |
61 changes: 61 additions & 0 deletions
61
WAAD.WebSSO.PHP/csharp/code/libraries/powershell/Microsoft.Samples.Waad.PS/GetOrgIdSPN.cs
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace Microsoft.Samples.Waad.PS | ||
{ | ||
using System; | ||
using System.Management.Automation; | ||
using System.Xml; | ||
|
||
[Cmdlet(VerbsCommon.Get, "OrgIdConfig")] | ||
public class GetOrgIdSpn : PSCmdlet | ||
{ | ||
private const string FederationMetadata = "https://accounts.accesscontrol.windows.net/FederationMetadata/2007-06/FederationMetadata.xml?realm={0}"; | ||
private const string EntityDescriptor = "EntityDescriptor"; | ||
private const string EntityId = "entityID"; | ||
|
||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "default", HelpMessage = "The Application Principal Identifier returned when registering a new principal.")] | ||
[ValidateNotNullOrEmpty] | ||
public string AppPrincipalId { get; set; } | ||
|
||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "default", HelpMessage = "The Application Domain used when registering a new principal.")] | ||
[ValidateNotNullOrEmpty] | ||
public string ApplicationDomain { get; set; } | ||
|
||
protected override void ProcessRecord() | ||
{ | ||
try | ||
{ | ||
base.ProcessRecord(); | ||
|
||
var result = this.GetSpn(); | ||
|
||
Console.Write("\nAdd the following issuer entry to the XML file"); | ||
Console.Write("\n=============================================="); | ||
Console.Write('\n' + result.ToString() + "\n\n"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null)); | ||
} | ||
} | ||
|
||
private GetOrgIdSpnResult GetSpn() | ||
{ | ||
string entityDescriptor = string.Empty; | ||
Guid idpIdentifier = Guid.Empty; | ||
|
||
using (var reader = new XmlTextReader(string.Format(FederationMetadata, this.ApplicationDomain))) | ||
{ | ||
var xml = new XmlDocument(); | ||
xml.Load(reader); | ||
var descriptor = xml.GetElementsByTagName(EntityDescriptor); | ||
|
||
if ((descriptor != null) && (descriptor.Count > 0)) | ||
{ | ||
entityDescriptor = descriptor[0].Attributes[EntityId].Value; | ||
idpIdentifier = new Guid(entityDescriptor.Split('@')[1]); | ||
} | ||
|
||
return new GetOrgIdSpnResult(new Guid(this.AppPrincipalId), this.ApplicationDomain, idpIdentifier, entityDescriptor); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ebSSO.PHP/csharp/code/libraries/powershell/Microsoft.Samples.Waad.PS/GetOrgIdSPNResult.cs
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace Microsoft.Samples.Waad.PS | ||
{ | ||
using System; | ||
using System.Globalization; | ||
|
||
public class GetOrgIdSpnResult | ||
{ | ||
private const string Display = "<issuer name=\"{0}\" displayName=\"{0}\" realm=\"{1}\" />"; | ||
|
||
public GetOrgIdSpnResult(Guid appId, string appDomain, Guid idpId, string entityId) | ||
{ | ||
this.ApplicationId = appId; | ||
this.ApplicationDomain = appDomain; | ||
this.Spn = string.Format("spn:{0}@{1}", appId, idpId); | ||
} | ||
|
||
public Guid ApplicationId { get; internal set; } | ||
|
||
public string ApplicationDomain { get; internal set; } | ||
|
||
public string Spn { get; internal set; } | ||
|
||
public override string ToString() | ||
{ | ||
return string.Format(CultureInfo.InvariantCulture, Display, this.ApplicationDomain, this.Spn); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...PHP/csharp/code/libraries/powershell/Microsoft.Samples.Waad.PS/Properties/AssemblyInfo.cs
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Microsoft.Samples.Waad.PS")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Microsoft.Samples.Waad.PS")] | ||
[assembly: AssemblyCopyright("Copyright © 2012")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("08dbf7c3-adc5-4c47-9124-5321a7b7c999")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.