public void Configure(IApplicationBuilder app, IHostingEnvironment env, AppDbContext context,
                              IAuthenticateService userService)
        {
            app.UseAuthentication();

            context.Database.EnsureCreated();
            userService.Create(new User {
                Email = _settings.AdminLogin, Role = UserRole.Administrator
            },
                               _settings.AdminPassword);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());


            app.UseMvc(rb =>
            {
                rb.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}"
                    );
                //defaults: new {controller = "Home", action = "Index"});
            });
        }
 public LoginController(IConfiguration configuration,
                        SignInManager <IdentityUser> signInManager, IAuthenticateService authenticationJWTService)
 {
     _configuration            = configuration;
     _signInManager            = signInManager;
     _authenticationJWTService = authenticationJWTService;
 }
Example #3
0
 public AuthentificationController(IAuthenticateService authenticateService, IMapper mapper, ILogsService log, IHttpContextAccessor httpContextAccessor)
 {
     _authenticateService = authenticateService;
     _mapper = mapper;
     _log    = log;
     _httpContextAccessor = httpContextAccessor;
 }
 public UsersController(
     IRegisterService registerService,
     IAuthenticateService authenticateService)
 {
     _registerService     = registerService;
     _authenticateService = authenticateService;
 }
Example #5
0
 public authenticationController(IAuthenticateService authService, IInstituteRepository instituteRepository, IMapper mapper)
 {
     this._authService         = authService;
     this._instituteRepository = instituteRepository ??
                                 throw new ArgumentNullException(nameof(instituteRepository));
     _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
Example #6
0
        private static bool AuthenticateUser(ControllerContext context, IAuthenticateService authenticateService)
        {
            if (context.HttpContext.User.Identity.IsAuthenticated)
            {
                var userId = context.HttpContext.User.Identity.Name;

                if (!string.IsNullOrWhiteSpace(userId))
                {
                    var sessionSecurityToken = context.HttpContext.Cache[string.Concat(CacheKeyNames.Identity, userId)] as SessionSecurityToken;

                    if (sessionSecurityToken != null)
                    {
                        // If the user's claims principal was located in cache retrieve it from there.
                        context.HttpContext.User = sessionSecurityToken.ClaimsPrincipal;

                        return true;
                    }

                    if (authenticateService.ValidateUser(Int32.Parse(userId)))
                    {
                        // If the user's claims principal was not located in cache set it and repeat the login steps.
                        Login(context.HttpContext, true);

                        return true;
                    }
                }
            }

            return false;
        }
        public AccountController(IAuthenticateService authService, UserManager <ApplicationUser> userManager, IApplicationUserService applicationUserService)
        {
            _authenticateService = authService;

            _userManager            = userManager;
            _applicationUserService = applicationUserService;
        }
Example #8
0
 public AccountController(
     IAuthenticateService auth,
     IUserService userService)
 {
     this.auth        = auth;
     this.userService = userService;
 }
Example #9
0
 public ResourceController(IResourceService service, IUserManagementService userManager,
                           IAuthenticateService authenticateService)
 {
     _service             = service;
     _userManager         = userManager;
     _authenticateService = authenticateService;
 }
Example #10
0
 public UsersController(IUserBalancesService balances, IAuthenticateService authenticateService, ITransactionsService transactions, IUsersService users)
 {
     _authenticateService = authenticateService;
     _balances            = balances;
     _transactions        = transactions;
     _users = users;
 }
 public ProjectTypeController(IProjectTypeService service, IUserManagementService userManager,
                              IAuthenticateService authenticateService)
 {
     _service             = service;
     _userManager         = userManager;
     _authenticateService = authenticateService;
 }
Example #12
0
 public UsersController(
     IAuthenticateService authenticateService,
     IRefreshTokenService refreshTokenService)
 {
     this.authenticateService = authenticateService;
     this.refreshTokenService = refreshTokenService;
 }
Example #13
0
 public UserService(IUserRepository userRepository, IAuthenticateService authenticateService, ILoginRepository loginRepository, IPasswordHashService passwordHashService)
 {
     _userRepository      = userRepository;
     _authenticateService = authenticateService;
     _loginRepository     = loginRepository;
     _passwordHashService = passwordHashService;
 }
Example #14
0
 public ProjectController(IProjectService projectService, IUserManagementService userManager,
                          IAuthenticateService authenticateService)
 {
     _projectService      = projectService;
     _userManager         = userManager;
     _authenticateService = authenticateService;
 }
 public ValuesController(TestApiAppContext context, IAuthenticateService authService, IOptions <TokenManagement> tokenManagement)
 {
     _context = context;
     // _requestLogin = login;
     _authService     = authService;
     _tokenManagement = tokenManagement.Value;
 }
Example #16
0
 public AuthController(IUserService userService, IRoleService roleService, IConfiguration config, IAuthenticateService authService)
 {
     _userService = userService;
     _roleService = roleService;
     _authService = authService;
     _config      = config;
 }
 public AuthenticateController(
     IAuthenticateService accountService,
     IMapper mapper)
 {
     _accountService = accountService;
     _mapper         = mapper;
 }
Example #18
0
 public AuthenticateController(IUserService serviceUser, IAuthenticateService serviceAuth
                               , IConfiguration config, IAuthenticateWrapper authenticateWrapper)
 {
     _authenticateWrapper = authenticateWrapper;
     _serviceAuth         = serviceAuth;
     _authOptions         = config.GetSection("AuthOptions").Get <AuthOptions>();
 }
Example #19
0
 public ApplicationUserService(IMapper mapper, UserManager <ApplicationUser> userManager,
                               IAuthenticateService authenticateService) //: base(mapper)
 {
     _userManager         = userManager;
     _mapper              = mapper;
     _authenticateService = authenticateService;
 }
 public AccountController
 (
     IAuthenticateService authenticateService
 )
 {
     _authenticateService = authenticateService;
 }
Example #21
0
 public override void SetRepositories()
 {
     _MasterRepo.NetworkInterface = (U, P, A) => ExecuteQueryWithObjectAndNetworkAccessAsync(U, P, A);
     _MasterRepo.NetworkInterfaceWithTypedParameters = (U, P, A) => ExecuteQueryWithTypedParametersAndNetworkAccessAsync(U, P, A);
     _AuthService = new AuthenticateService(_MasterRepo.NetworkInterface);
     _Reposetory  = new LoginRepository(_MasterRepo, _AuthService);
 }
 public AuthenticateController(
     IAuthenticateService authServ,
     IUserManagementService userManagementServ)
 {
     authService           = authServ;
     userManagementService = userManagementServ;
 }
Example #23
0
 public UserContext(HttpContextBase httpContext, ICustomerService customerService,
     IAuthenticateService authenticateService)
 {
     _httpContext = httpContext;
     _customerService = customerService;
     _authenticateService = authenticateService;
 }
Example #24
0
 public AuthController(
     IAuthenticateService authenticateService,
     IUserContextDataProvider userContextDataProvider)
     : base(userContextDataProvider)
 {
     this.authenticateService = authenticateService;
 }
 public DonationController(IDonationService donationService, ILiqPayService liqPayService,
                           IAuthenticateService authenticateService)
 {
     _donationService     = donationService;
     _liqPayService       = liqPayService;
     _authenticateService = authenticateService;
 }
 public AuthCommandHandler(IAuthenticateService service,
                           IUserRepository repository, IPasswordHasher hasher)
 {
     _service    = service;
     _repository = repository;
     _hasher     = hasher;
 }
Example #27
0
        public void GetAuthTokenSuccessTest()
        {
            // Arrange
            AuthenticateUserResource resource = new AuthenticateUserResource();
            User user = new User();

            mapper.Map <AuthenticateUserResource, User>(Arg.Any <AuthenticateUserResource>()).Returns(user);
            IAuthenticateService authenticateService = Substitute.For <IAuthenticateService>();
            string token;

            authenticateService.IsAuthenticated(user, out token)
            .Returns(x => {
                x[1] = "token";
                return(true);
            });
            AuthenticateController controller = new AuthenticateController(authenticateService, mapper);

            // Act
            IActionResult result = controller.GetAuthToken(resource);

            // Assert
            result.Should().BeOfType <OkObjectResult>();
            OkObjectResult okResult = result as OkObjectResult;

            okResult.Value.Should().Be("token");
        }
Example #28
0
 public WebWorkContext(
     IAuthenticateService authenticationService,
     IHttpContextAccessor httpContextAccessor)
 {
     _authenticationService = authenticationService;
     _httpContextAccessor   = httpContextAccessor;
 }
 public GoogleAuthenticateService(IAuthenticateService tokenAuthenticationService, UserManager <ApplicationUser> userManager, IAuthenticateService authenticateService, SignInManager <ApplicationUser> signInManager)
 {
     _tokenAuthenticationService = tokenAuthenticationService;
     _userManager         = userManager;
     _authenticateService = authenticateService;
     _signInManager       = signInManager;
 }
Example #30
0
        public LoginViewViewModel(IViewAwareStatus viewAwareStatus, IAuthenticateService authenticateService,
                                  IMessageBoxService messageBoxService, IBusinessUnitService businessUnitService, IViewInjectionService viewInjectionService)
        {
            //base.IsCloseable = true;
            //Initialise Services
            this.viewAwareStatus      = viewAwareStatus;
            this.authenticateService  = authenticateService;
            this.messageBoxService    = messageBoxService;
            this.businessUnitService  = businessUnitService;
            this.viewInjectionService = viewInjectionService;
            //this.regionManager = regionManager;
            //Initialise Properties
            UserName                         = new DataWrapper <string>(this, userNameArgs);
            Password                         = new DataWrapper <string>(this, passwordArgs);
            SelectedBusinessUnit             = new DataWrapper <Int32>(this, businessUnitsArgs);
            this.viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded);


            cachedListOfDataWrappers =
                DataWrapperHelper.GetWrapperProperties <LoginViewViewModel>(this);

            //Register Mediator
            Mediator.Instance.Register(this);

            //Initialise Rules
            userName.AddRule(UserNameCannnotBeEmptyRule);
            password.AddRule(PasswordCannotBeEmptyRule);
            selectedBusinessUnit.AddRule(SelectedBusinessUnitCannotBeEmpty);

            //Initialise Commands
            LoginCommand       = new SimpleCommand <object, object>(CanExecuteLoginCommand, ExecuteLoginCommand);
            CancelLoginCommand = new SimpleCommand <object, object>(ExecuteCancelLoginCommand);
        }
Example #31
0
        /// <summary>
        /// 构造一个权限认证Session,需要提供一个认证服务对象
        /// </summary>
        static SecuritySession()
        {
            IAuthenticateService authenticateService = SecurityServiceProvider.GetAuthenticateService();
            _authenticateService = authenticateService;

            IAuthorizationService azService = SecurityServiceProvider.GetAuthorizationService();
            _azService = azService;
        }
Example #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthController"/> class.
 /// </summary>
 /// <param name="authenticateService">Service for Authentication.</param>
 /// <param name="context"> Instance of Database context.</param>
 /// <param name="configuration">Instance of IConfiguration.</param>
 /// <param name="logger">Logger instance.</param>
 /// <param name="userService">userservices.</param>
 /// <param name="userManager">usermanager is a class provided by Identity Library which has bunch of in built methods.</param>
 public AuthController(IAuthenticateService authenticateService, ILogger <AuthController> logger, DataContext context, IConfiguration configuration, UserManager <User> userManager)
 {
     this.authenticateService = authenticateService;
     this.context             = context;
     this.configuration       = configuration;
     this.logger      = logger;
     this.userManager = userManager;
 }
Example #33
0
 public JwtCustomAuthHandler(IOptionsMonitor <BasicAuthenticationOptions> options,
                             ILoggerFactory logger,
                             UrlEncoder encoder,
                             ISystemClock clock, IAuthenticateService service, IConfiguration config) : base(options, logger, encoder, clock)
 {
     this.service = service;
     this._config = config;
 }
Example #34
0
 public HomeController(
     IAuthenticateService authenticateService,
     IContactUsService contactUsService,
     IUserLogService userLogService)
 {
     _authenticateService = authenticateService;
     _contactUsService = contactUsService;
     _userLogService = userLogService;
 }
 /// <summary>
 /// 获取用户验证服务对象
 /// </summary>
 /// <returns></returns>
 public static IAuthenticateService GetAuthenticateService()
 {
     Initialize();
     if (_atSvc == null)
     {
         _atSvc = System.Activator.CreateInstance(Type.GetType(_authenticateServiceProviderType),_config) as IAuthenticateService;
     }
     return _atSvc;
 }
 public AuthorizationController(IAuthenticateService authService)
 {
     _authService = authService;
 }
 public AccountController(IAuthenticateService authService)
 {
     _authService = authService;
 }
        public LoginViewViewModel(IViewAwareStatus viewAwareStatus, IAuthenticateService authenticateService,
                                  IMessageBoxService messageBoxService, IBusinessUnitService businessUnitService, IViewInjectionService viewInjectionService)
        {
            //base.IsCloseable = true;
            //Initialise Services
            this.viewAwareStatus = viewAwareStatus;
            this.authenticateService = authenticateService;
            this.messageBoxService = messageBoxService;
            this.businessUnitService = businessUnitService;
            this.viewInjectionService = viewInjectionService;
            //this.regionManager = regionManager;
            //Initialise Properties
            UserName = new DataWrapper<string>(this, userNameArgs);
            Password = new DataWrapper<string>(this, passwordArgs);
            SelectedBusinessUnit = new DataWrapper<Int32>(this, businessUnitsArgs);
            this.viewAwareStatus.ViewLoaded += new Action(viewAwareStatus_ViewLoaded);

            cachedListOfDataWrappers =
                DataWrapperHelper.GetWrapperProperties<LoginViewViewModel>(this);

            //Register Mediator
            Mediator.Instance.Register(this);

            //Initialise Rules
            userName.AddRule(UserNameCannnotBeEmptyRule);
            password.AddRule(PasswordCannotBeEmptyRule);
            selectedBusinessUnit.AddRule(SelectedBusinessUnitCannotBeEmpty);

            //Initialise Commands
            LoginCommand = new SimpleCommand<object, object>(CanExecuteLoginCommand, ExecuteLoginCommand);
            CancelLoginCommand = new SimpleCommand<object, object>(ExecuteCancelLoginCommand);
        }