public UserEndpoint(IUserAdapter <TUser> userAdapter, IUserTokenProvider userTokenProvider, IUserClaimsProvider <TUser> userClaimsProvider, IOrderAdapter orderAdapter) { _userAdapter = userAdapter; _userTokenProvider = userTokenProvider; _userClaimsProvider = userClaimsProvider; _orderAdapter = orderAdapter; }
public static UserManager<ApplicationUser> Create( IUserStore<ApplicationUser> store_iUserStore, IIdentityMessageService value_iIdentityMessageService, IIdentityMessageService value_iIdentityMessageService1, IUserTokenProvider<ApplicationUser, string> value_iUserTokenProvider, bool value_b, int value_i ) { UserManager<ApplicationUser> userManager = new UserManager<ApplicationUser>(store_iUserStore); ((UserManager<ApplicationUser, string>)userManager).EmailService = value_iIdentityMessageService; ((UserManager<ApplicationUser, string>)userManager).SmsService = value_iIdentityMessageService1; ((UserManager<ApplicationUser, string>)userManager).UserTokenProvider = value_iUserTokenProvider; ((UserManager<ApplicationUser, string>)userManager).UserLockoutEnabledByDefault = value_b; ((UserManager<ApplicationUser, string>)userManager) .MaxFailedAccessAttemptsBeforeLockout = value_i; return userManager; // TODO: Edit factory method of UserManager`1<ApplicationUser> // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
private void ConfigureIdentityServices(ContainerBuilder builder) { // Register the owin context - this allows non-web api services // access to the hosting builder.Register(c => c.Resolve <HttpRequestMessage>().GetOwinContext()) .As <IOwinContext>() .InstancePerRequest(); builder.RegisterType <IdentityProvider>() .AsImplementedInterfaces() .InstancePerRequest(); // Options builder.Register(c => new IdentityFactoryOptions <ApplicationUserManager> { DataProtectionProvider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider(Constants.ApplicationName) }); builder.Register(c => { IUserTokenProvider <ApplicationUser, string> tokenProvider = null; var options = c.Resolve <IdentityFactoryOptions <ApplicationUserManager> >(); var dataProtectionProvider = options.DataProtectionProvider; if (options.DataProtectionProvider != null) { tokenProvider = new DataProtectorTokenProvider <ApplicationUser>(dataProtectionProvider.Create(Constants.ApplicationName)); } return(tokenProvider); }); builder.Register(c => HttpContext.Current.GetOwinContext().Authentication).As <IAuthenticationManager>(); }
public static UserManager <ApplicationUser> Create( IUserStore <ApplicationUser> store_iUserStore, IIdentityMessageService value_iIdentityMessageService, IIdentityMessageService value_iIdentityMessageService1, IUserTokenProvider <ApplicationUser, string> value_iUserTokenProvider, bool value_b, int value_i ) { UserManager <ApplicationUser> userManager = new UserManager <ApplicationUser>(store_iUserStore); ((UserManager <ApplicationUser, string>)userManager).EmailService = value_iIdentityMessageService; ((UserManager <ApplicationUser, string>)userManager).SmsService = value_iIdentityMessageService1; ((UserManager <ApplicationUser, string>)userManager).UserTokenProvider = value_iUserTokenProvider; ((UserManager <ApplicationUser, string>)userManager).UserLockoutEnabledByDefault = value_b; ((UserManager <ApplicationUser, string>)userManager) .MaxFailedAccessAttemptsBeforeLockout = value_i; return(userManager); // TODO: Edit factory method of UserManager`1<ApplicationUser> // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
public ApplicationUserManager(IUserStore <ApplicationUser> store, IEmailService emailService, IUserTokenProvider <ApplicationUser, string> userTokenProvider) : base(store) { this._emailService = emailService; this._userTokenProvider = userTokenProvider; Init(); }
public async Task NotifyTwoFactorUserTokenAsync(string twoFactorProviderKey, User user, string token) { if (!this.userTokenTwoFactorProviders.ContainsKey(twoFactorProviderKey)) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resource.NoTwoFactorProvider, twoFactorProviderKey)); } IUserTokenProvider userTokenProvider = this.userTokenTwoFactorProviders[twoFactorProviderKey]; await userTokenProvider.NotifyAsync(user, token); }
public ApplicationUserManager( IUserStore <ApplicationUser> store, IUserTokenProvider <ApplicationUser, string> tokenProvider, IIdentityValidator <string> passwordValidator, Func <UserManager <ApplicationUser>, IIdentityValidator <ApplicationUser> > userValidatorFactory) : base(store) { base.UserTokenProvider = tokenProvider; base.PasswordValidator = passwordValidator; base.UserValidator = userValidatorFactory(this); }
/// <summary> /// This creates an instance of CoreUserManager /// </summary> /// <param name="userContext">An implementation of the BasicAuthentication.Users.UserContext abstract class. </param> /// <param name="provider">An instance of a Microsoft.AspNet.IdentityIUserTokenProvider < TUser, string > class which is used to provide password reset tokens.</param> /// <example> /// An Microsoft.AspNet.IdentityIUserTokenProvider < TUser string > can be created using a Microsoft.Owin.Security.DataProtection.IDataProtectionProvider as follows: /// <code> /// Microsoft.Owin.Security.DataProtection.IDataProtectionProvider provider; This needs to be created, here for reference. /// var tokenProvider = new Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider<BasicAuthentication.Users.IdentityUser>(provider.Create("EmailConfirmation")); /// </code> /// </example> public CoreUserManager(ICoreUserContext userContext, IUserTokenProvider <ICoreIdentityUser, string> provider) : base(new UserStore <ICoreIdentityUser>(userContext)) { this.UserContext = userContext; this.UserTokenProvider = provider; this.UserValidator = new UserValidator <ICoreIdentityUser>(this) { AllowOnlyAlphanumericUserNames = false, }; }
public async Task <string> GenerateTwoFactorUserTokenAsync(string twoFactorProviderKey, User user) { if (!this.userTokenTwoFactorProviders.ContainsKey(twoFactorProviderKey)) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resource.NoTwoFactorProvider, twoFactorProviderKey)); } IUserTokenProvider userTokenProvider = this.userTokenTwoFactorProviders[twoFactorProviderKey]; var twoFactorUserToken = await userTokenProvider.GenerateAsync(twoFactorProviderKey, user); return(twoFactorUserToken); }
public async Task <bool> ValidateTwoFactorUserTokenAsync(string twoFactorProviderKey, User user, string token) { if (!this.userTokenTwoFactorProviders.ContainsKey(twoFactorProviderKey)) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resource.NoTwoFactorProvider, twoFactorProviderKey)); } IUserTokenProvider userTokenProvider = this.userTokenTwoFactorProviders[twoFactorProviderKey]; bool twoFactorUserTokenIsValid = await userTokenProvider.ValidateAsync(twoFactorProviderKey, user, token); return(twoFactorUserTokenIsValid); }
public UserManager( UserStore store, RoleManager roleManager, EmailService emailService, IRepository <Tenant> tenantRepository, IMultiTenancyConfig multiTenancyConfig, IPermissionManager permissionManager, IUnitOfWorkManager unitOfWorkManager, ISettingManager settingManager, IUserManagementConfig userManagementConfig, IIocResolver iocResolver, IUserTokenProvider <User, long> userTokenProvider, ICacheManager cacheManager) : base( store, roleManager, tenantRepository, multiTenancyConfig, permissionManager, unitOfWorkManager, settingManager, userManagementConfig, iocResolver, cacheManager ) { this.EmailService = emailService; //RegisterTwoFactorProvider("PhoneCode",new PhoneNumberTokenProvider<User,long>() //{ // MessageFormat = "your code is {0}" //}); //RegisterTwoFactorProvider("EmailCode", new EmailTokenProvider<User, long>() //{ // Subject = "securiyCode", // BodyFormat = "your code is {0}" //}); //UserTokenProvider = new EmailTokenProvider<User, long>() //{ // Subject = "securiyCode", // BodyFormat = "your code is {0}" //}; //IUserSecurityStampStore<> UserTokenProvider = userTokenProvider; }
public ApplicationUserManager(IUserStore <ApplicationUser, string> store, IUserTokenProvider <ApplicationUser, string> tokenProvider) : base(store) { UserValidator = new UserValidator <ApplicationUser>(this) { AllowOnlyAlphanumericUserNames = true, RequireUniqueEmail = false }; PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = true, RequireDigit = true, RequireLowercase = true, RequireUppercase = true, }; UserTokenProvider = tokenProvider; }
public UserIdentityApplicationService( IClaimsIdentityFactory claimsIdentityFactory, IPasswordHasher passwordHasher, IIdentityValidator<string> passwordIdentityValidator, IIdentityValidator<User> userIdentityValidator, IUserRepository userRepository, IDbContextScopeFactory dbContextScopeFactory, IUserTokenProvider userTokenProvider, IUserTokenTwoFactorProvider userTokenTwoFactorProvider, IMapper mapper, ILog logger) : base(dbContextScopeFactory, mapper, logger) { this.claimsIdentityFactory = claimsIdentityFactory; this.passwordHasher = passwordHasher; this.passwordIdentityValidator = passwordIdentityValidator; this.userIdentityValidator = userIdentityValidator; this.userRepository = userRepository; this.userTokenProvider = userTokenProvider; this.userTokenTwoFactorProvider = userTokenTwoFactorProvider; }
public ApplicationUserManager(IUserStore <User> store, IUserTokenProvider <User, string> userTokenProvider) : base(store) { UserValidator = new UserValidator <User>(this) { AllowOnlyAlphanumericUserNames = false, RequireUniqueEmail = false }; // Configure validation logic for passwords PasswordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = false, RequireDigit = false, RequireLowercase = false, RequireUppercase = false, }; // Configure user lockout defaults UserLockoutEnabledByDefault = true; DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); MaxFailedAccessAttemptsBeforeLockout = 5; UserTokenProvider = userTokenProvider; }
public virtual void RegisterTwoFactorAuthenticationProvider(string twoFactorProviderKey, IUserTokenProvider provider) { this.userTokenTwoFactorProvider.RegisterTwoFactorUserTokenProvider(twoFactorProviderKey, provider); }
public override void RegisterTwoFactorProvider(string twoFactorProvider, IUserTokenProvider <AzureTableUser, string> provider) { base.RegisterTwoFactorProvider(twoFactorProvider, provider); }
public Task RegisterTwoFactorUserTokenProviderAsync(string twoFactorProviderKey, IUserTokenProvider userTokenProvider) { this.userTokenTwoFactorProviders[twoFactorProviderKey] = userTokenProvider; return Task.FromResult(0); }
public UserManager(IUserStore <User, int> store, IUserTokenProvider <User, int> userTokenProvider) : base(store) { this.UserTokenProvider = userTokenProvider; }
public UserService(IMapper mapper, IUserRepository userRepository, IEmailService emailService, IUserTokenProvider <User, string> userTokenProvider) { _mapper = mapper; _userRepository = userRepository; _userManager = new UserManager <User>(userRepository) { UserTokenProvider = userTokenProvider }; _emailService = emailService; }
private Container ConfigureIoCContainer(IAppBuilder appBuilder) { var container = new Container(); container.Options.DefaultScopedLifestyle = new WebRequestLifestyle(); appBuilder.Use( async(context, next) => { using (container.BeginExecutionContextScope()) { await next(); } }); container.Register <ILog>(() => LogManager.GetLogger(typeof(LogManager))); container.RegisterCollection <Profile>(); container.Register <IMapper>(() => { Mapper.Initialize(configuration => { var profiles = container.GetAllInstances <Profile>(); foreach (var profile in profiles) { configuration.AddProfile(profile); } }); return(Mapper.Instance); }, Lifestyle.Singleton); container.Register <IAmbientDbContextLocator, AmbientDbContextLocator>(Lifestyle.Scoped); container.Register <IDbContextScopeFactory>(() => new DbContextScopeFactory()); container.Register <IUserRepository, UserRepository <ApplicationDbContext> >(Lifestyle.Scoped); container.Register <IClaimsIdentityFactory, ClaimsIdentityFactory>(Lifestyle.Scoped); container.Register <IPasswordHasher, CryptoPasswordHasher>(Lifestyle.Scoped); container.Register <IIdentityValidator <string> >( () => { var passwordValidator = new PasswordValidator { RequiredLength = 6, RequireNonLetterOrDigit = true, RequireDigit = true, RequireLowercase = true, RequireUppercase = true, }; return(passwordValidator); }); container.Register <IIdentityValidator <User> >( () => { var userRepository = container.GetInstance <IUserRepository>(); var userValidator = new UserValidator(userRepository) { AllowOnlyAlphanumericUserNames = false, RequireUniqueEmail = true }; return(userValidator); }); container.Register <IUserTokenProvider>( () => { var dataProtectionProvider = appBuilder.GetDataProtectionProvider(); var dataProtector = dataProtectionProvider.Create("ASP.NET Identity"); var dataProtectorTokenProvider = new DataProtectorTokenProvider(dataProtector); return(dataProtectorTokenProvider); }); container.Register <IAuthenticationService, Rfc6238AuthenticationService>(Lifestyle.Scoped); container.Register <IAuthenticationManager>( () => { if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying) { return(new OwinContext().Authentication); } return(HttpContext.Current.GetOwinContext().Authentication); }); container.Register <IIdentityProvider, IdentityProvider>(Lifestyle.Scoped); container.Register <IIdentityMessageService, SmsService>(Lifestyle.Scoped); container.Register <IUserTokenTwoFactorProvider, UserTokenTwoFactorProvider>(Lifestyle.Scoped); container.Register <IUserIdentityApplicationService>( () => { IAuthenticationManager authenticationManager = container.GetInstance <IAuthenticationManager>(); IClaimsIdentityFactory claimsIdentityFactory = container.GetInstance <IClaimsIdentityFactory>(); IPasswordHasher passwordHasher = container.GetInstance <IPasswordHasher>(); IIdentityValidator <string> passwordIdentityValidator = container.GetInstance <IIdentityValidator <string> >(); IIdentityValidator <User> userIdentityValidator = container.GetInstance <IIdentityValidator <User> >(); IUserRepository userRepository = container.GetInstance <IUserRepository>(); IUserTokenProvider userTokenProvider = container.GetInstance <IUserTokenProvider>(); IIdentityProvider userIdentityProvider = container.GetInstance <IIdentityProvider>(); IUserTokenTwoFactorProvider userTokenTwoFactorProvider = container.GetInstance <IUserTokenTwoFactorProvider>(); IDbContextScopeFactory dbContextScopeFactory = container.GetInstance <IDbContextScopeFactory>(); IMapper mapper = container.GetInstance <IMapper>(); ILog logger = container.GetInstance <ILog>(); var userIdentityApplicationService = new UserIdentityApplicationService( authenticationManager, claimsIdentityFactory, passwordHasher, passwordIdentityValidator, userIdentityValidator, userRepository, userTokenProvider, userIdentityProvider, userTokenTwoFactorProvider, dbContextScopeFactory, mapper, logger); var authenticationService = container.GetInstance <IAuthenticationService>(); userIdentityApplicationService.RegisterTwoFactorAuthenticationProvider("Phone Code", new PhoneNumberTokenProvider(authenticationService, new SmsService())); userIdentityApplicationService.RegisterTwoFactorAuthenticationProvider("Email Code", new EmailTokenProvider(authenticationService, new EmailService())); return(userIdentityApplicationService); }); container.Register <SecurityStampValidator>( () => { IDbContextScopeFactory dbContextScopeFactory = container.GetInstance <IDbContextScopeFactory>(); IClaimsIdentityFactory claimsIdentityFactory = container.GetInstance <IClaimsIdentityFactory>(); IUserRepository userRepository = container.GetInstance <IUserRepository>(); IIdentityProvider identityProvider = container.GetInstance <IIdentityProvider>(); var securityStampValidator = new SecurityStampValidator(dbContextScopeFactory, userRepository, claimsIdentityFactory, identityProvider); return(securityStampValidator); }); container.RegisterMvcControllers(Assembly.GetExecutingAssembly()); container.Verify(); DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container)); GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorDependencyResolver(container); return(container); }
public override void RegisterTwoFactorProvider(string twoFactorProvider, IUserTokenProvider <ApplicationUser, string> provider) { base.RegisterTwoFactorProvider(twoFactorProvider, provider); }
/// <summary> /// Get the login or preview response for the given link. /// </summary> /// <param name="turnContext">The turn context.</param> /// <param name="query">The matched url.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A Task resolving to either a login card or </returns> /// <remarks> /// For more information on Link Unfurling see the documentation /// https://docs.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/link-unfurling?tabs=dotnet /// /// This method also implements messaging extension authentication to get the reddit API token for the user. /// https://docs.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/add-authentication /// </remarks> protected override async Task <MessagingExtensionResponse> OnTeamsAppBasedLinkQueryAsync( ITurnContext <IInvokeActivity> turnContext, AppBasedLinkQuery query, CancellationToken cancellationToken = default) { turnContext = turnContext ?? throw new ArgumentNullException(nameof(turnContext)); query = query ?? throw new ArgumentNullException(nameof(query)); IUserTokenProvider tokenProvider = turnContext.Adapter as IUserTokenProvider; // Get the magic code out of the request for when the login flow is completed. // https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-authentication?view=azure-bot-service-4.0#securing-the-sign-in-url string magicCode = (turnContext.Activity?.Value as JObject)?.Value <string>("state"); // Get the token from the Azure Bot Framework Token Service to handle token storage // https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-authentication?view=azure-bot-service-4.0#about-the-bot-framework-token-service var tokenResponse = await tokenProvider ?.GetUserTokenAsync( turnContext : turnContext, connectionName : this.options.Value.BotFrameworkConnectionName, magicCode : magicCode, cancellationToken : cancellationToken); try { // Execute the domain logic to get the reddit link RedditLinkModel redditLink = await this.redditHttpClient.GetLinkAsync(tokenResponse?.Token, query.Url); var preview = new MessagingExtensionAttachment( contentType: HeroCard.ContentType, contentUrl: null, content: this.RenderLinkHeroCard(redditLink)); return(new MessagingExtensionResponse { ComposeExtension = new MessagingExtensionResult { Type = "result", AttachmentLayout = AttachmentLayoutTypes.List, Attachments = new List <MessagingExtensionAttachment>() { new MessagingExtensionAttachment { ContentType = AdaptiveCard.ContentType, Content = this.RenderLinkAdaptiveCard(redditLink), Preview = preview, }, }, }, }); } catch (RedditUnauthorizedException) { this.logger.LogInformation("Attempt to fetch post resulted in unauthorized, triggering log-in flow"); // "log out" the user, so log-in gets a new token. await tokenProvider.SignOutUserAsync( turnContext : turnContext, connectionName : this.options.Value.BotFrameworkConnectionName, cancellationToken : cancellationToken); return(await this .GetAuthenticationMessagingExtensionResponseAsync(turnContext, cancellationToken) .ConfigureAwait(false)); } #pragma warning disable CA1031 catch (Exception ex) #pragma warning restore CA1031 { this.logger.LogError(ex, "Failed to get reddit post"); return(null); } }
public virtual async Task RegisterTwoFactorUserTokenProviderAsync(string twoFactorProviderKey, IUserTokenProvider provider) { await this.userTokenTwoFactorProvider.RegisterTwoFactorUserTokenProviderAsync(twoFactorProviderKey, provider); }
public override void RegisterTwoFactorProvider(string twoFactorProvider, IUserTokenProvider <SantaSecurityUser, string> provider) { throw new NotSupportedException(); }
/// <summary> /// Handle when the user is searching in the messaging extension query. /// </summary> /// <param name="turnContext">The turn context.</param> /// <param name="query">The messaging extension query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A Task that resolves to the list of cards that matched the query.</returns> /// <remarks> /// This application only supports direct links to reddit as the query string, in many applications /// this should be used to search for matching items. /// /// For more information on search based messaging extensions see the documentation /// https://docs.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/search-commands/respond-to-search?tabs=dotnet . /// </remarks> protected override async Task <MessagingExtensionResponse> OnTeamsMessagingExtensionQueryAsync( ITurnContext <IInvokeActivity> turnContext, MessagingExtensionQuery query, CancellationToken cancellationToken) { turnContext = turnContext ?? throw new ArgumentNullException(nameof(turnContext)); query = query ?? throw new ArgumentNullException(nameof(query)); IUserTokenProvider tokenProvider = turnContext.Adapter as IUserTokenProvider; string magicCode = (turnContext.Activity?.Value as JObject)?.Value <string>("state"); var tokenResponse = await tokenProvider ?.GetUserTokenAsync( turnContext : turnContext, connectionName : this.options.Value.BotFrameworkConnectionName, magicCode : magicCode, cancellationToken : cancellationToken); var queryString = query.Parameters.FirstOrDefault()?.Value as string ?? string.Empty; try { // Execute the domain logic to get the reddit link IEnumerable <RedditLinkModel> redditLinks = await this.redditHttpClient.SearchLinksAsync(tokenResponse?.Token, queryString); var attachments = redditLinks .Select(redditLink => { var preview = new MessagingExtensionAttachment( contentType: HeroCard.ContentType, contentUrl: null, content: this.RenderLinkHeroCard(redditLink)); return(new MessagingExtensionAttachment { ContentType = AdaptiveCard.ContentType, Content = this.RenderLinkAdaptiveCard(redditLink), Preview = preview, }); }) .ToList(); return(new MessagingExtensionResponse { ComposeExtension = new MessagingExtensionResult { Type = "result", AttachmentLayout = AttachmentLayoutTypes.List, Attachments = attachments, }, }); } catch (RedditUnauthorizedException) { this.logger.LogInformation("Attempt to fetch post resulted in unauthorized, triggering log-in flow"); // "log out" the user, so log-in gets a new token. await tokenProvider.SignOutUserAsync( turnContext : turnContext, connectionName : this.options.Value.BotFrameworkConnectionName, cancellationToken : cancellationToken); return(await this .GetAuthenticationMessagingExtensionResponseAsync(turnContext, cancellationToken) .ConfigureAwait(false)); } #pragma warning disable CA1031 catch (Exception ex) #pragma warning restore CA1031 { this.logger.LogError(ex, "Failed to get reddit post"); return(null); } }
public void RegisterTwoFactorUserTokenProvider(string twoFactorProviderKey, IUserTokenProvider userTokenProvider) { this.userTokenTwoFactorProviders[twoFactorProviderKey] = userTokenProvider; }
public static async Task <ClaimsIdentity> CriarIdentityAsync(this APIUsuarioBO apiUsuarioBO, APIUsuario usuario, IUserTokenProvider <APIUsuarioIdentity, string> UserTokenProvider) { UserManager <APIUsuarioIdentity> userManager = new UserManager <APIUsuarioIdentity>(new APIUsuarioUserStore(apiUsuarioBO)); userManager.UserTokenProvider = UserTokenProvider; var user = usuario.CopyTo(new APIUsuarioIdentity()); var identity = await userManager.CreateIdentityAsync(user, OAuthDefaults.AuthenticationType); return(identity); }
private async Task <MessagingExtensionResponse> GetAuthenticationMessagingExtensionResponseAsync( ITurnContext <IInvokeActivity> turnContext, CancellationToken cancellationToken) { // Before requesting the token link, make sure the request is still live. cancellationToken.ThrowIfCancellationRequested(); IUserTokenProvider tokenProvider = turnContext.Adapter as IUserTokenProvider; string signInLink = await tokenProvider ?.GetOauthSignInLinkAsync( turnContext : turnContext, connectionName : this.options.Value.BotFrameworkConnectionName, cancellationToken : cancellationToken); return(new MessagingExtensionResponse { ComposeExtension = new MessagingExtensionResult { Type = "auth", SuggestedActions = new MessagingExtensionSuggestedAction { Actions = new List <CardAction> { new CardAction { Type = ActionTypes.OpenUrl, Value = signInLink, Title = this.localizer.GetString("Sign in"), }, }, }, }, }); }
public UserIdentityApplicationService( IAuthenticationManager authenticationManager, IClaimsIdentityFactory claimsIdentityFactory, IPasswordHasher passwordHasher, IIdentityValidator <string> passwordIdentityValidator, IIdentityValidator <User> userIdentityValidator, IUserRepository userRepository, IUserTokenProvider userTokenProvider, IIdentityProvider userIdentityProvider, IUserTokenTwoFactorProvider userTokenTwoFactorProvider, IDbContextScopeFactory dbContextScopeFactory, IMapper mapper, ILog logger) : base(dbContextScopeFactory, mapper, logger) { this.authenticationManager = authenticationManager; this.claimsIdentityFactory = claimsIdentityFactory; this.passwordHasher = passwordHasher; this.passwordIdentityValidator = passwordIdentityValidator; this.userIdentityValidator = userIdentityValidator; this.userRepository = userRepository; this.userTokenProvider = userTokenProvider; this.userIdentityProvider = userIdentityProvider; this.userTokenTwoFactorProvider = userTokenTwoFactorProvider; this.AuthenticationType = Infrastructure.Identity.Model.AuthenticationType.ApplicationCookie; this.UserLockoutEnabledByDefault = true; this.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(DefaultAccountLockoutTimeSpanInMinutes); this.MaxFailedAccessAttemptsBeforeLockout = DefaultMaxFailedAccessAttemptsBeforeLockout; }