private string BuildIdToken(string invitedEmail, string invitedAccountId, string invitedGroupId) { var configOptions = AuthenticationCustomerOptions.Construct(Config); var issuer = $"{Request.Scheme}://{Request.Host}{Request.PathBase.Value}/"; // All parameters send to Azure AD B2C needs to be sent as claims IList <Claim> claims = new List <Claim>(); claims.Add(new Claim(Constants.AuthenticationProperties.InvitedEmail, invitedEmail, ClaimValueTypes.String, issuer)); claims.Add(new Claim(Constants.AuthenticationProperties.InvitedAccountId, invitedAccountId, ClaimValueTypes.String, issuer)); claims.Add(new Claim(Constants.AuthenticationProperties.InvitedGroupId, invitedGroupId, ClaimValueTypes.String, issuer)); // Create the token var token = new JwtSecurityToken( issuer, configOptions.ClientId, claims, DateTime.Now, DateTime.Now.AddDays(7), SigningCredentials.Value); // Get the representation of the signed token var jwtHandler = new JwtSecurityTokenHandler(); return(jwtHandler.WriteToken(token)); }
private void ConfigureBusinessCustomerAuthentication( IConfiguration configuration, AuthenticationBuilder authenticationBuilder, PolicyManager manager) { var authenticationOptions = AuthenticationCustomerOptions.Construct(Configuration); var policyList = manager.BusinessCustomerPolicySetupList; // BusinessCustomerPolicySetupList authenticationBuilder.AddOpenIdConnect(Constants.AuthenticationSchemes.BusinessCustomerAuth, options => { options.Authority = authenticationOptions.Authority; options.CallbackPath = new PathString("/b2b-signin-callback"); options.ClientId = authenticationOptions.ClientId; options.CorrelationCookie.Expiration = TimeSpan.FromHours(3); options.ConfigurationManager = new PolicyConfigurationManager( authenticationOptions.Authority, policyList); options.Events = CreateB2BOpenIdConnectEvents(); options.SignedOutCallbackPath = new PathString("/b2b-signout-callback"); options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = Constants.ClaimTypes.Name }; }); }
private void ConfigureCustomerAuthentication( IConfiguration configuration, IServiceCollection services, AuthenticationBuilder authenticationBuilder, PolicyManager manager) { var authenticationOptions = AuthenticationCustomerOptions.Construct(configuration); var policyList = manager.CustomerPolicySetupList; authenticationBuilder.AddOpenIdConnect(Constants.AuthenticationSchemes.CustomerAuth, options => { options.Authority = authenticationOptions.Authority; options.CallbackPath = new PathString("/b2c-signin-callback"); options.ClientId = authenticationOptions.ClientId; options.ClientSecret = authenticationOptions.ClientSecret; options.CorrelationCookie.Expiration = TimeSpan.FromHours(3); options.ConfigurationManager = new PolicyConfigurationManager( authenticationOptions.Authority, policyList); options.Events = CreateB2COpenIdConnectEvents(manager); options.Scope.Remove("profile"); options.SignedOutCallbackPath = new PathString("/b2c-signout-callback"); options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = Constants.ClaimTypes.Name }; }); }
public PolicyManager(IConfiguration configuration) { var authOptions = AuthenticationCustomerOptions.Construct(configuration); _prefix = authOptions.PolicyPrefix; }