Based on the wonderful example of Sean Luttin in https://stackoverflow.com/a/166268/2128/ , I was able to use this code to generate and consume carrier tokens. Minor changes were in getting the latest packages:
"dependencies": { "Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final", "AspNet.Security.OpenIdConnect.Server": "1.0.0-beta4" }
Although the code is a great start, it is not a complete solution that fully integrates w / ASP.NET Identity. I changed the AuthorizationProvider class as follows:
public override Task GrantResourceOwnerCredentials( GrantResourceOwnerCredentialsContext context) { var user = _userManager.FindByNameAsync(context.UserName).Result; if (user == null) { context.Rejected("The user name or password is incorrect."); } else { var signInManager = context.HttpContext.RequestServices .GetRequiredService<SignInManager<ApplicationUser>>(); if (signInManager.CanSignInAsync(user).Result && _userManager.CheckPasswordAsync(user, context.Password).Result) { var principal = signInManager.CreateUserPrincipalAsync(user).Result;
I am using CreateUserPrincipalAsync to create a ClaimsPrincipal for the Validated method. Is there a better way to integrate w / ASP.NET Identity?
source share