Skip to content

Commit

Permalink
Beta8 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leastprivilege committed Oct 18, 2015
1 parent c759e72 commit c30ea18
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 54 deletions.
2 changes: 1 addition & 1 deletion source/AspNet5Host/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta7"
"version": "1.0.0-beta8"
}
}
6 changes: 3 additions & 3 deletions source/AspNet5Host/src/Api1/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public void ConfigureServices(IServiceCollection services)
public void Configure(IApplicationBuilder app)
{
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();

app.UseOAuthBearerAuthentication(options =>
app.UseJwtBearerAuthentication(options =>
{
options.Authority = "https://localhost:44300";
options.Audience = "https://localhost:44300/resources";
Expand All @@ -26,7 +26,7 @@ public void Configure(IApplicationBuilder app)

app.UseMiddleware<RequiredScopesMiddleware>(new List<string> { "api1" });

app.UseMvc();
app.UseMvcWithDefaultRoute();
}
}
}
2 changes: 0 additions & 2 deletions source/AspNet5Host/src/Api1/hosting.ini

This file was deleted.

10 changes: 5 additions & 5 deletions source/AspNet5Host/src/Api1/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"version": "1.0.0-*",

"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Authentication.OAuthBearer": "1.0.0-beta7"
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-beta8"
},

"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
"web": "Microsoft.AspNet.Server.Kestrel"
},

"frameworks": {
Expand Down
9 changes: 9 additions & 0 deletions source/AspNet5Host/src/Api1/wwwroot/web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>
3 changes: 3 additions & 0 deletions source/AspNet5Host/src/IdentityServerAspNet5/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public void ConfigureServices(IServiceCollection services)

public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
{
app.UseIISPlatformHandler();
app.UseDeveloperExceptionPage();

var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

var idsrvOptions = new IdentityServerOptions
Expand Down
2 changes: 0 additions & 2 deletions source/AspNet5Host/src/IdentityServerAspNet5/hosting.ini

This file was deleted.

13 changes: 7 additions & 6 deletions source/AspNet5Host/src/IdentityServerAspNet5/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
"version": "1.0.0-*",

"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
"Microsoft.Owin": "3.0.1",
"Microsoft.AspNet.DataProtection": "1.0.0-beta7",
"Microsoft.AspNet.Owin": "1.0.0-beta7",
"IdentityServer3": "2.0.0"
"Microsoft.AspNet.DataProtection": "1.0.0-beta8",
"Microsoft.AspNet.Owin": "1.0.0-beta8",
"IdentityServer3": "2.0.2"
},

"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
"web": "Microsoft.AspNet.Server.Kestrel"
},

"frameworks": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>
4 changes: 2 additions & 2 deletions source/AspNet5Host/src/MvcClient/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public IActionResult Index()

public async Task<IActionResult> CallApi()
{
var token = User.FindFirst("token").Value;
var token = User.FindFirst("access_token").Value;

var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
Expand All @@ -28,4 +28,4 @@ public async Task<IActionResult> CallApi()
return View();
}
}
}
}
62 changes: 37 additions & 25 deletions source/AspNet5Host/src/MvcClient/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Security.Claims;
using Microsoft.AspNet.Authentication;
using System.IdentityModel.Tokens.Jwt;
using System;

namespace MvcClient
{
Expand All @@ -20,6 +21,9 @@ public void Configure(IApplicationBuilder app)
{
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>();

app.UseIISPlatformHandler();
app.UseDeveloperExceptionPage();

app.UseCookieAuthentication(options =>
{
options.AuthenticationScheme = "Cookies";
Expand All @@ -28,41 +32,49 @@ public void Configure(IApplicationBuilder app)

app.UseOpenIdConnectAuthentication(options =>
{
options.AuthenticationScheme = "oidc";
options.SignInScheme = "Cookies";
options.AutomaticAuthentication = true;
options.SaveTokensAsClaims = false;

options.Authority = "https://localhost:44300";
options.RedirectUri = "http://localhost:2221/";

options.ClientId = "mvc6";
options.ResponseType = "id_token token";
options.ResponseMode = "form_post";
options.Scope = "openid email profile api1";
options.RedirectUri = "http://localhost:2221/";

options.SignInScheme = "Cookies";
options.AutomaticAuthentication = true;

options.Notifications = new OpenIdConnectAuthenticationNotifications
options.Scope.Add("openid");
options.Scope.Add("email");
options.Scope.Add("profile");
options.Scope.Add("api1");

options.Events = new OpenIdConnectEvents
{
SecurityTokenValidated = n =>
{
var incoming = n.AuthenticationTicket.Principal;
OnAuthenticationValidated = data =>
{
var incoming = data.AuthenticationTicket.Principal;
var id = new ClaimsIdentity("application", "given_name", "role");

// create application identity
var id = new ClaimsIdentity("application", "given_name", "role");
id.AddClaim(incoming.FindFirst("sub"));
id.AddClaim(incoming.FindFirst("email"));
id.AddClaim(incoming.FindFirst("email_verified"));
id.AddClaim(incoming.FindFirst("given_name"));
id.AddClaim(incoming.FindFirst("family_name"));
id.AddClaim(new Claim("token", n.ProtocolMessage.AccessToken));
id.AddClaim(incoming.FindFirst("sub"));
id.AddClaim(incoming.FindFirst("email"));
id.AddClaim(incoming.FindFirst("email_verified"));
id.AddClaim(incoming.FindFirst("given_name"));
id.AddClaim(incoming.FindFirst("family_name"));
id.AddClaim(new Claim("access_token", data.ProtocolMessage.AccessToken));
id.AddClaim(new Claim("id_token", data.ProtocolMessage.IdToken));
id.AddClaim(new Claim("expires_at", DateTime.Now.AddSeconds(double.Parse(data.ProtocolMessage.ExpiresIn)).ToString()));

n.AuthenticationTicket = new AuthenticationTicket(
new ClaimsPrincipal(id),
n.AuthenticationTicket.Properties,
n.AuthenticationTicket.AuthenticationScheme);
data.AuthenticationTicket = new AuthenticationTicket(
new ClaimsPrincipal(id),
data.AuthenticationTicket.Properties,
data.AuthenticationTicket.AuthenticationScheme);

// see https://github.com/aspnet/Security/issues/372
n.HandleResponse();
return Task.FromResult(0);
}
//data.HandleResponse();
return Task.FromResult(0);
}
};

});

app.UseMvcWithDefaultRoute();
Expand Down
2 changes: 0 additions & 2 deletions source/AspNet5Host/src/MvcClient/hosting.ini

This file was deleted.

13 changes: 7 additions & 6 deletions source/AspNet5Host/src/MvcClient/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
"version": "1.0.0-*",

"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
"Microsoft.AspNet.Mvc": "6.0.0-beta7",
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-beta7",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7"
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.OpenIdConnect": "1.0.0-beta8",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta8"
},

"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
"web": "Microsoft.AspNet.Server.Kestrel"
},

"frameworks": {
Expand Down
9 changes: 9 additions & 0 deletions source/AspNet5Host/src/MvcClient/wwwroot/web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

0 comments on commit c30ea18

Please sign in to comment.