-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
382 additions
and
2 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
AngularJSAuthentication.ResourceServer/AngularJSAuthentication.ResourceServer.csproj
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,152 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion> | ||
</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{69BC6280-CF91-409C-81BF-28B95417ACBF}</ProjectGuid> | ||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>AngularJSAuthentication.ResourceServer</RootNamespace> | ||
<AssemblyName>AngularJSAuthentication.ResourceServer</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<UseIISExpress>true</UseIISExpress> | ||
<IISExpressSSLPort /> | ||
<IISExpressAnonymousAuthentication /> | ||
<IISExpressWindowsAuthentication /> | ||
<IISExpressUseClassicPipelineMode /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="Microsoft.Owin"> | ||
<HintPath>..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Owin.Cors"> | ||
<HintPath>..\packages\Microsoft.Owin.Cors.3.0.0\lib\net45\Microsoft.Owin.Cors.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Owin.Host.SystemWeb"> | ||
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Owin.Security"> | ||
<HintPath>..\packages\Microsoft.Owin.Security.3.0.0\lib\net45\Microsoft.Owin.Security.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.Owin.Security.OAuth"> | ||
<HintPath>..\packages\Microsoft.Owin.Security.OAuth.3.0.0\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Owin"> | ||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Web.Cors"> | ||
<HintPath>..\packages\Microsoft.AspNet.Cors.5.0.0\lib\net45\System.Web.Cors.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Web.DynamicData" /> | ||
<Reference Include="System.Web.Entity" /> | ||
<Reference Include="System.Web.ApplicationServices" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Web.Extensions" /> | ||
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Web.Http.Owin"> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Web.Http.WebHost, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Web.Services" /> | ||
<Reference Include="System.EnterpriseServices" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="packages.config" /> | ||
<None Include="Properties\PublishProfiles\ngauthenticationResourcesAPI.pubxml" /> | ||
<None Include="Web.Debug.config"> | ||
<DependentUpon>Web.config</DependentUpon> | ||
</None> | ||
<None Include="Web.Release.config"> | ||
<DependentUpon>Web.config</DependentUpon> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Web.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="App_Start\WebApiConfig.cs" /> | ||
<Compile Include="Controllers\ProtectedController.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Startup.cs" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> | ||
<ProjectExtensions> | ||
<VisualStudio> | ||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> | ||
<WebProjectProperties> | ||
<UseIIS>True</UseIIS> | ||
<AutoAssignPort>True</AutoAssignPort> | ||
<DevelopmentServerPort>47039</DevelopmentServerPort> | ||
<DevelopmentServerVPath>/</DevelopmentServerVPath> | ||
<IISUrl>http://localhost:47039/</IISUrl> | ||
<NTLMAuthentication>False</NTLMAuthentication> | ||
<UseCustomServer>False</UseCustomServer> | ||
<CustomServerUrl> | ||
</CustomServerUrl> | ||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> | ||
</WebProjectProperties> | ||
</FlavorProperties> | ||
</VisualStudio> | ||
</ProjectExtensions> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
23 changes: 23 additions & 0 deletions
23
AngularJSAuthentication.ResourceServer/App_Start/WebApiConfig.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,23 @@ | ||
using Microsoft.Owin.Security.OAuth; | ||
using Newtonsoft.Json.Serialization; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http.Formatting; | ||
using System.Web; | ||
using System.Web.Http; | ||
|
||
namespace AngularJSAuthentication.ResourceServer.App_Start | ||
{ | ||
public static class WebApiConfig | ||
{ | ||
public static void Register(HttpConfiguration config) | ||
{ | ||
// Web API routes | ||
config.MapHttpAttributeRoutes(); | ||
|
||
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First(); | ||
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
AngularJSAuthentication.ResourceServer/Controllers/ProtectedController.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,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Security.Claims; | ||
using System.Web.Http; | ||
|
||
namespace AngularJSAuthentication.ResourceServer.Controllers | ||
{ | ||
[Authorize] | ||
[RoutePrefix("api/protected")] | ||
public class ProtectedController : ApiController | ||
{ | ||
[Route("")] | ||
public IEnumerable<object> Get() | ||
{ | ||
var identity = User.Identity as ClaimsIdentity; | ||
|
||
return identity.Claims.Select(c => new | ||
{ | ||
Type = c.Type, | ||
Value = c.Value | ||
}); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
AngularJSAuthentication.ResourceServer/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,35 @@ | ||
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("AngularJSAuthentication.ResourceServer")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("AngularJSAuthentication.ResourceServer")] | ||
[assembly: AssemblyCopyright("Copyright © 2014")] | ||
[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("e9939033-aa8c-4eee-8aba-ed4ba5750bf1")] | ||
|
||
// 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 Revision and Build Numbers | ||
// by using the '*' as shown below: | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
24 changes: 24 additions & 0 deletions
24
...hentication.ResourceServer/Properties/PublishProfiles/ngauthenticationResourcesAPI.pubxml
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
This file is used by the publish/package process of your Web project. You can customize the behavior of this process | ||
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. | ||
--> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<WebPublishMethod>MSDeploy</WebPublishMethod> | ||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> | ||
<LastUsedPlatform>Any CPU</LastUsedPlatform> | ||
<SiteUrlToLaunchAfterPublish>http://ngauthenticationresourcesapi.azurewebsites.net</SiteUrlToLaunchAfterPublish> | ||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish> | ||
<ExcludeApp_Data>False</ExcludeApp_Data> | ||
<MSDeployServiceURL>ngauthenticationresourcesapi.scm.azurewebsites.net:443</MSDeployServiceURL> | ||
<DeployIisAppPath>ngauthenticationResourcesAPI</DeployIisAppPath> | ||
<RemoteSitePhysicalPath /> | ||
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer> | ||
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod> | ||
<EnableMSDeployBackup>True</EnableMSDeployBackup> | ||
<UserName>$ngauthenticationResourcesAPI</UserName> | ||
<_SavePWD>True</_SavePWD> | ||
<_DestinationType>AzureWebSite</_DestinationType> | ||
</PropertyGroup> | ||
</Project> |
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 AngularJSAuthentication.ResourceServer.App_Start; | ||
using Microsoft.Owin; | ||
using Microsoft.Owin.Security.OAuth; | ||
using Owin; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Http; | ||
|
||
[assembly: OwinStartup(typeof(AngularJSAuthentication.ResourceServer.Startup))] | ||
namespace AngularJSAuthentication.ResourceServer | ||
{ | ||
public class Startup | ||
{ | ||
public void Configuration(IAppBuilder app) | ||
{ | ||
HttpConfiguration config = new HttpConfiguration(); | ||
|
||
ConfigureOAuth(app); | ||
|
||
WebApiConfig.Register(config); | ||
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); | ||
app.UseWebApi(config); | ||
|
||
} | ||
|
||
private void ConfigureOAuth(IAppBuilder app) | ||
{ | ||
//Token Consumption | ||
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions | ||
{ | ||
}); | ||
} | ||
} | ||
} |
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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> | ||
|
||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | ||
<!-- | ||
In the example below, the "SetAttributes" transform will change the value of | ||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator | ||
finds an attribute "name" that has a value of "MyDB". | ||
<connectionStrings> | ||
<add name="MyDB" | ||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" | ||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> | ||
</connectionStrings> | ||
--> | ||
<system.web> | ||
<!-- | ||
In the example below, the "Replace" transform will replace the entire | ||
<customErrors> section of your web.config file. | ||
Note that because there is only one customErrors section under the | ||
<system.web> node, there is no need to use the "xdt:Locator" attribute. | ||
<customErrors defaultRedirect="GenericError.htm" | ||
mode="RemoteOnly" xdt:Transform="Replace"> | ||
<error statusCode="500" redirect="InternalError.htm"/> | ||
</customErrors> | ||
--> | ||
</system.web> | ||
</configuration> |
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,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> | ||
|
||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | ||
<!-- | ||
In the example below, the "SetAttributes" transform will change the value of | ||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator | ||
finds an attribute "name" that has a value of "MyDB". | ||
<connectionStrings> | ||
<add name="MyDB" | ||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" | ||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> | ||
</connectionStrings> | ||
--> | ||
<system.web> | ||
<compilation xdt:Transform="RemoveAttributes(debug)" /> | ||
<!-- | ||
In the example below, the "Replace" transform will replace the entire | ||
<customErrors> section of your web.config file. | ||
Note that because there is only one customErrors section under the | ||
<system.web> node, there is no need to use the "xdt:Locator" attribute. | ||
<customErrors defaultRedirect="GenericError.htm" | ||
mode="RemoteOnly" xdt:Transform="Replace"> | ||
<error statusCode="500" redirect="InternalError.htm"/> | ||
</customErrors> | ||
--> | ||
</system.web> | ||
</configuration> |
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Microsoft.AspNet.Cors" version="5.0.0" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net45" /> | ||
<package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" /> | ||
<package id="Microsoft.Owin.Cors" version="3.0.0" targetFramework="net45" /> | ||
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net45" /> | ||
<package id="Microsoft.Owin.Security" version="3.0.0" targetFramework="net45" /> | ||
<package id="Microsoft.Owin.Security.OAuth" version="3.0.0" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" /> | ||
<package id="Owin" version="1.0" targetFramework="net45" /> | ||
</packages> |
Oops, something went wrong.