Skip to content
This repository was archived by the owner on Jan 23, 2020. It is now read-only.

Commit 5936eab

Browse files
committed
Updating to RC1
1 parent 102c561 commit 5936eab

22 files changed

+40555
-237
lines changed

.vs/config/applicationhost.config

Lines changed: 992 additions & 0 deletions
Large diffs are not rendered by default.

TodoListService/App_Start/Startup.Auth.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

TodoListService/Controllers/TodoListController.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Security.Claims;
66
using TodoListService.Models;
77
using System.Collections.Concurrent;
8+
using Microsoft.AspNet.Authorization;
89

910
namespace TodoListService.Controllers
1011
{
@@ -18,17 +19,15 @@ public class TodoListController : Controller
1819
[HttpGet]
1920
public IEnumerable<TodoItem> Get()
2021
{
21-
// Please note: use of "Context.User", instead of the standard ClaimsPrincipal.Current, is due to a bug in this release
22-
string owner = Context.User.FindFirst(ClaimTypes.NameIdentifier).Value;
22+
string owner = (ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier))?.Value;
2323
return todoStore.Where(t => t.Owner == owner).ToList();
2424
}
2525

2626
// POST api/todolist
2727
[HttpPost]
2828
public void Post(string Title)
2929
{
30-
// Please note: use of "Context.User", instead of the standard ClaimsPrincipal.Current, is due to a bug in this release
31-
string owner = Context.User.FindFirst(ClaimTypes.NameIdentifier).Value;
30+
string owner = (ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier))?.Value;
3231
todoStore.Add(new TodoItem { Owner = owner, Title = Title });
3332
}
3433
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "https://localhost:44321/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"Hosting:Environment": "Development"
16+
}
17+
},
18+
"web": {
19+
"commandName": "web",
20+
"environmentVariables": {
21+
"Hosting:Environment": "Development"
22+
}
23+
}
24+
}
25+
}

TodoListService/Startup.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
using System;
2+
using Microsoft.AspNet.Authentication.JwtBearer;
23
using Microsoft.AspNet.Builder;
34
using Microsoft.AspNet.Hosting;
4-
using Microsoft.AspNet.Http;
5-
using Microsoft.AspNet.Routing;
6-
using Microsoft.Framework.DependencyInjection;
7-
using Microsoft.Framework.ConfigurationModel;
8-
using Microsoft.AspNet.Security.OAuthBearer;
9-
using Microsoft.AspNet.Security;
10-
using System.IdentityModel.Tokens;
11-
using System.Collections.Generic;
12-
using System.Security.Claims;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.DependencyInjection;
137

148
namespace TodoListService
159
{
16-
public partial class Startup
10+
public class Startup
1711
{
18-
public Startup(IHostingEnvironment env)
12+
public Startup()
1913
{
2014
// Setup configuration sources.
21-
Configuration = new Configuration()
22-
.AddJsonFile("config.json");
15+
Configuration = new ConfigurationBuilder()
16+
.AddJsonFile("config.json")
17+
.AddEnvironmentVariables()
18+
.Build();
2319
}
2420

2521
public IConfiguration Configuration { get; set; }
@@ -28,15 +24,27 @@ public Startup(IHostingEnvironment env)
2824
// Use this method to add services to the container
2925
public void ConfigureServices(IServiceCollection services)
3026
{
27+
// Add MVC services to the services container.
3128
services.AddMvc();
29+
30+
// Add Authentication services.
31+
services.AddAuthentication();
3232
}
3333

3434
// Configure is called after ConfigureServices is called.
3535
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
3636
{
37-
ConfigureAuth(app);
38-
3937
app.UseStaticFiles();
38+
39+
// Configure the app to use Jwt Bearer Authentication
40+
app.UseJwtBearerAuthentication(new JwtBearerOptions
41+
{
42+
AutomaticAuthenticate = true,
43+
AutomaticChallenge = true,
44+
Authority = String.Format(Configuration["AzureAd:AadInstance"], Configuration["AzureAD:Tenant"]),
45+
Audience = Configuration["AzureAd:audience"],
46+
});
47+
4048
// Add MVC to the request pipeline.
4149
app.UseMvc(routes =>
4250
{

TodoListService/TodoListService.kproj renamed to TodoListService/TodoListService.xproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
55
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
66
</PropertyGroup>
7-
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
7+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
99
<ProjectGuid>299b1f6a-1bf6-4496-9770-463b2c318df5</ProjectGuid>
1010
<RootNamespace>TodoListService</RootNamespace>
@@ -15,5 +15,5 @@
1515
<SchemaVersion>2.0</SchemaVersion>
1616
<DevelopmentServerPort>51896</DevelopmentServerPort>
1717
</PropertyGroup>
18-
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
18+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
1919
</Project>

TodoListService/config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"AzureAd": {
3-
"AadInstance": "https://login.microsoftonline.com/{0}",
4-
"Tenant": "[Enter tenant name, e.g. contoso.onmicrosoft.com]",
5-
"Audience": "[Enter App ID URI of TodoListService, e.g. https://contoso.onmicrosoft.com/TodoListService]"
6-
}
2+
"AzureAd": {
3+
"AadInstance": "https://login.microsoftonline.com/{0}",
4+
"Tenant": "[Enter tenant name, e.g. contoso.onmicrosoft.com]",
5+
"Audience": "[Enter App ID URI of TodoListService, e.g. https://contoso.onmicrosoft.com/TodoListService]"
6+
}
77
}

TodoListService/project.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
2-
/* Click to learn more about project.json http://go.microsoft.com/fwlink/?LinkID=517074 */
32
"webroot": "wwwroot",
4-
"version": "1.0.0-*",
3+
"version": "1.0.0-*",
54
"dependencies": {
6-
"Microsoft.AspNet.Server.IIS": "1.0.0-beta3",
7-
"Microsoft.AspNet.Mvc": "6.0.0-beta3",
8-
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
9-
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
10-
"Microsoft.AspNet.Security.OAuthBearer": "1.0.0-beta3",
11-
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta3"
5+
"Microsoft.AspNet.Mvc": "6.0.0-*",
6+
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
7+
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
8+
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
9+
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
10+
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
11+
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
12+
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-*"
1213
},
1314
"frameworks": {
14-
"aspnet50": { },
15-
"aspnetcore50": { }
15+
"dnx451": { },
16+
"dnxcore50": { }
1617
},
1718
"exclude": [
1819
"wwwroot",
@@ -25,5 +26,8 @@
2526
"**.kproj",
2627
"**.user",
2728
"**.vspscc"
28-
]
29+
],
30+
"commands": {
31+
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001"
32+
}
2933
}

0 commit comments

Comments
 (0)