public AccountController( IUsersService usersService, ITokenStoreService tokenStoreService, ITokenFactoryService tokenFactoryService, IUnitOfWork uow, IAntiForgeryCookieService antiforgery, ITagServices tagServices, IZirReshtehServices zirReshteh ) { _zirreshteh = zirReshteh; _Tags = tagServices; _usersService = usersService; _usersService.CheckArgumentIsNull(nameof(usersService)); _tokenStoreService = tokenStoreService; _tokenStoreService.CheckArgumentIsNull(nameof(tokenStoreService)); _uow = uow; _uow.CheckArgumentIsNull(nameof(_uow)); _antiforgery = antiforgery; _antiforgery.CheckArgumentIsNull(nameof(antiforgery)); _tokenFactoryService = tokenFactoryService; _tokenFactoryService.CheckArgumentIsNull(nameof(tokenFactoryService)); }
public TokenController( IUserService userService, ITokenStoreService tokenService, IAntiForgeryCookieService antiForgeryCookieService) { _userService = userService; _tokenService = tokenService; _antiForgeryCookieService = antiForgeryCookieService; }
public AuthController(IUserService userService, IConfiguration configuration, IAntiForgeryCookieService antiforgery, ITokenStoreService tokenService, IAntiforgery antiforgeryService, RoleManager <Role> roleManager) { this.antiforgery = antiforgeryService; this._tokenService = tokenService; this._configuration = configuration; this._userService = userService; this._antiforgery = antiforgery; this.roleManager = roleManager; }
public AccountService(ITokenFactoryService tokenFactoryService, ITokenStoreService tokenStoreService, IUnitOfWork uow, IAntiForgeryCookieService antiforgery) { _tokenFactoryService = tokenFactoryService; _tokenFactoryService.CheckArgumentIsNull(nameof(tokenFactoryService)); _uow = uow; _antiforgery = antiforgery; _antiforgery.CheckArgumentIsNull(nameof(antiforgery)); _tokenStoreService = tokenStoreService; _tokenStoreService.CheckArgumentIsNull(nameof(tokenStoreService)); }
public ApiSettingsController( // ILogger<ApiSettingsController> logger, IOptionsSnapshot <ApiSettings> apiSettingsConfig, IUserService userService, IAntiForgeryCookieService antiforgery, ITokenStoreService tokenService, IAntiforgery antiforgeryService) { // _logger = logger; this.userService = userService; _apiSettingsConfig = apiSettingsConfig; this.antiforgery = antiforgeryService; this._tokenService = tokenService; this._antiforgery = antiforgery; }
public AuthenticationService(IUserManager userManager, ITokenManager tokenManager, IRoleManager roleManager, IAntiForgeryCookieService antiForgery, IOptionsSnapshot <TokenOptions> configuration, IMessageLocalizer localizer, IUserSession session) { _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager)); _tokenManager = tokenManager ?? throw new ArgumentNullException(nameof(tokenManager)); _roleManager = roleManager ?? throw new ArgumentNullException(nameof(roleManager)); _antiForgery = antiForgery ?? throw new ArgumentNullException(nameof(antiForgery)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); _session = session ?? throw new ArgumentNullException(nameof(session)); }
public AuthControllerTest() : base() { _usersService = base._serviceProvider.GetRequiredService <IUsersService>(); _tokenStoreService = base._serviceProvider.GetRequiredService <ITokenStoreService>(); _tokenFactoryService = base._serviceProvider.GetRequiredService <ITokenFactoryService>(); _uow = base._serviceProvider.GetRequiredService <IUnitOfWork>(); var httpContextAccessor = new HttpContextAccessor(); httpContextAccessor.HttpContext = new DefaultHttpContext(); _antiforgery = new AntiForgeryCookieService(httpContextAccessor, base._serviceProvider.GetRequiredService <IAntiforgery>(), base._serviceProvider.GetRequiredService <IOptions <AntiforgeryOptions> >()); // base._serviceProvider.GetRequiredService<IAntiForgeryCookieService>(); _logger = base._serviceProvider.GetRequiredService <ILogger <AuthController> >(); _controller = new AuthController(_usersService, _tokenStoreService, _tokenFactoryService, _uow, _antiforgery, _logger); }
public LesterRegistrationController( ILesterRegistrationService lesterRegistration, IUserService userService, IAntiForgeryCookieService antiForgery, IPermissionService permissionService, ITokenStoreService tokenStoreService, ITokenFactoryService tokenFactoryService, IWorkContext workContext) { _lesterRegistration = lesterRegistration; _userService = userService; _permissionService = permissionService; _tokenStoreService = tokenStoreService; _tokenFactoryService = tokenFactoryService; _antiforgery = antiForgery; _workContext = workContext; }
public AccountController( IUsersUserIdentityServiceJwt usersService, ITokenStoreService tokenStoreService, IUnitOfWork uow, IAntiForgeryCookieService antiforgery) { _usersService = usersService; _usersService.CheckArgumentIsNull(nameof(usersService)); _tokenStoreService = tokenStoreService; _tokenStoreService.CheckArgumentIsNull(nameof(tokenStoreService)); _uow = uow; _uow.CheckArgumentIsNull(nameof(_uow)); _antiforgery = antiforgery; _antiforgery.CheckArgumentIsNull(nameof(antiforgery)); }
public SecurityController( IUserService userService, ITokenStoreService tokenStoreService, ITokenFactoryService tokenFactoryService, IAntiForgeryCookieService antiforgery) { _userService = userService; _userService.CheckArgumentIsNull(nameof(userService)); _tokenStoreService = tokenStoreService; _tokenStoreService.CheckArgumentIsNull(nameof(tokenStoreService)); _antiforgery = antiforgery; _antiforgery.CheckArgumentIsNull(nameof(antiforgery)); _tokenFactoryService = tokenFactoryService; _tokenFactoryService.CheckArgumentIsNull(nameof(tokenFactoryService)); }
public AuthController(IUsersService usersService, ITokenStoreService tokenStoreService, ITokenFactoryService tokenFactoryService, IUnitOfWork uow, IAntiForgeryCookieService antiforgery, ILogger <AuthController> logger) { _usersService = usersService; _usersService.CheckArgumentIsNull(nameof(usersService)); _tokenStoreService = tokenStoreService; _tokenStoreService.CheckArgumentIsNull(nameof(tokenStoreService)); _uow = uow; _uow.CheckArgumentIsNull(nameof(_uow)); _antiforgery = antiforgery; _antiforgery.CheckArgumentIsNull(nameof(antiforgery)); _tokenFactoryService = tokenFactoryService; _tokenFactoryService.CheckArgumentIsNull(nameof(tokenFactoryService)); _logger = logger; }
public AccountsController( IUserService usersService, ITokenStoreService tokenStoreService, ITokenFactoryService tokenFactoryService, IAuthenticationUnitOfWork uow, IAntiForgeryCookieService antiforgery) { _usersService = usersService; _usersService.CheckArgumentIsNull(nameof(usersService)); _tokenStoreService = tokenStoreService; _tokenStoreService.CheckArgumentIsNull(nameof(tokenStoreService)); _uow = uow; _uow.CheckArgumentIsNull(nameof(_uow)); _antiforgery = antiforgery; _antiforgery.CheckArgumentIsNull(nameof(antiforgery)); _tokenFactoryService = tokenFactoryService; _tokenFactoryService.CheckArgumentIsNull(nameof(tokenFactoryService)); }
public AuthController(UserManager <User> userManager, IAntiForgeryCookieService antiForgery, ITokenStoreService tokenStoreService) { _userManager = userManager; _antiForgery = antiForgery; _tokenStoreService = tokenStoreService; }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAntiforgery antiforgery, IAntiForgeryCookieService antiForgeryCookieService) { app.UseStaticFiles(); app.UseSpaStaticFiles(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } loggerFactory.AddConsole(this.Configuration.GetSection("Logging")); loggerFactory.AddDebug(LogLevel.Trace); //app.UseHttpsRedirection(); app.UseAuthentication(); app.UseMvc(); //app.UseExceptionHandler(appBuilder => //{ // appBuilder.Use(async (context, next) => // { // var error = context.Features[typeof(IExceptionHandlerFeature)] as IExceptionHandlerFeature; // if (error != null && error.Error is SecurityTokenExpiredException) // { // context.Response.StatusCode = 401; // context.Response.ContentType = "application/json"; // await context.Response.WriteAsync(JsonConvert.SerializeObject(new // { // State = 401, // Msg = "token expired" // })); // } // else if (error != null && error.Error != null) // { // context.Response.StatusCode = 500; // context.Response.ContentType = "application/json"; // await context.Response.WriteAsync(JsonConvert.SerializeObject(new // { // State = 500, // Msg = error.Error.Message // })); // } // else // { // await next(); // } // }); //}); // app.UseAntiforgeryTokens(); //app.Use(next => context => //{ // var logger = loggerFactory.CreateLogger("ValidRequestMW"); // //logger.LogInformation("Request Cookie is " + context.Request.Cookies["XSRF-TOKEN"]); // //logger.LogInformation("Request Header is " + context.Request.Headers["X-XSRF-TOKEN"]); // string path = context.Request.Path.Value; // if ( //string.Equals(path, "/", StringComparison.OrdinalIgnoreCase) || //string.Equals(path, "/index.html", StringComparison.OrdinalIgnoreCase)) // { // // antiForgeryCookieService.DeleteAntiForgeryCookies(); // var tokens = antiforgery.GetAndStoreTokens(context); // context.Response.Cookies.Append( // "XSRF-TOKEN", // tokens.RequestToken, // new CookieOptions() { HttpOnly = false } // ); // } // return next(context); //}); app.UseSwagger(); app.UseSwaggerUI(c => { c.EnableFilter(); c.SwaggerEndpoint("/swagger/v1/swagger.json", "نسخه 1"); }); app.UseSpa(spa => { spa.Options.SourcePath = "Ui"; //spa.UseSpaPrerendering(options => //{ // options.BootModulePath = $"{spa.Options.SourcePath}/dist/server/main.js"; // options.BootModuleBuilder = env.IsDevelopment() // ? new AngularCliBuilder(npmScript: "build:ssr") // : null; //}); if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); }
public UserService( IUserStoreService userStoreService, IUserTokenStorageService userTokenStorageService, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <User> passwordHasher, IEnumerable <IUserValidator <User> > userValidators, IEnumerable <IPasswordValidator <User> > passwordValidators, ILookupNormalizer keyNormalizer, ISecurityService securityService, IdentityErrorDescriber identityErrorDescriber, IServiceProvider serviceProvider, ILogger <UserService> logger, IHttpContextAccessor httpContextAccessor, IUnitOfWork unitOfWork, IEmailService emailService, IAntiForgeryCookieService antiForgeryCookieService, IOptionsSnapshot <SiteSettings> options, IUsedPasswordService usedPasswordService, IUserTokenFactoryService userTokenFactoryService, IMapper mapper) : base((IUserStore <User>)userStoreService, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, identityErrorDescriber, serviceProvider, logger) { _userStoreService = userStoreService; _userStoreService.CheckArgumentIsNull(nameof(_userStoreService)); _userTokenStorageService = userTokenStorageService; _userTokenStorageService.CheckArgumentIsNull(nameof(_userTokenStorageService)); _optionsAccessor = optionsAccessor; _optionsAccessor.CheckArgumentIsNull(nameof(_optionsAccessor)); _passwordHasher = passwordHasher; _passwordHasher.CheckArgumentIsNull(nameof(_passwordHasher)); _userValidators = userValidators; _userValidators.CheckArgumentIsNull(nameof(_userValidators)); _passwordValidators = passwordValidators; _passwordValidators.CheckArgumentIsNull(nameof(_passwordValidators)); _keyNormalizer = keyNormalizer; _keyNormalizer.CheckArgumentIsNull(nameof(_keyNormalizer)); _securityService = securityService; _securityService.CheckArgumentIsNull(nameof(_securityService)); _identityErrorDescriber = identityErrorDescriber; _identityErrorDescriber.CheckArgumentIsNull(nameof(_identityErrorDescriber)); _serviceProvider = serviceProvider; _serviceProvider.CheckArgumentIsNull(nameof(_serviceProvider)); _logger = logger; _logger.CheckArgumentIsNull(nameof(_logger)); _stringEncryption = new StringEncryption(); _stringEncryption.CheckArgumentIsNull(nameof(_stringEncryption)); _httpContextAccessor = httpContextAccessor; _httpContextAccessor.CheckArgumentIsNull(nameof(_httpContextAccessor)); _unitOfWork = unitOfWork; _unitOfWork.CheckArgumentIsNull(nameof(_unitOfWork)); _usedPasswordService = usedPasswordService; _userTokenFactoryService = userTokenFactoryService; _mapper = mapper; _usedPasswordService.CheckArgumentIsNull(nameof(_usedPasswordService)); _antiForgeryCookieService = antiForgeryCookieService; _antiForgeryCookieService.CheckArgumentIsNull(nameof(_antiForgeryCookieService)); _emailService = emailService; _emailService.CheckArgumentIsNull(nameof(_emailService)); options.CheckArgumentIsNull(nameof(options)); _options = options; _smsTemplates = options.Value.SmsTemplates; _users = _unitOfWork.Set <User>(); _roles = _unitOfWork.Set <Role>(); }