/// <summary>
 /// Validate a user's login credentials and retrieve their info with their roles
 /// </summary>
 /// <param name="auth"></param>
 /// <param name="model"></param>
 /// <param name="log"></param>
 public static Task <Maybe <AuthUserModel> > ValidateUserAsync(IAuthDataProvider auth, SignInModel model, ILog log)
 {
     log.Vrb("Validating credentials for {User}.", model.Email);
     return(from _ in auth.ValidateUserAsync <AuthUserModel>(model.Email, model.Password)
            from user in auth.RetrieveUserWithRolesAsync <AuthUserModel, AuthRoleModel>(model.Email)
            select user);
 }
Beispiel #2
0
 public ScopedUserContext(
     IAuthApi authApi,
     IAuthDataProvider authData)
 {
     this._authApi  = authApi;
     this._authData = authData;
 }
Beispiel #3
0
 public CheckCase(IAppDbContext context, ILogger <SignInCase> logger, IAuthDataProvider dataProvider, ICurrentUserProvider currentUserProvider)
 {
     _context             = context;
     _logger              = logger;
     _dataProvider        = dataProvider;
     _currentUserProvider = currentUserProvider;
 }
Beispiel #4
0
 public AuthBasicValidationProvider(
     IAuthDataProvider _dataProvider,
     IAuthApi api)
 {
     this._dataProvider = _dataProvider;
     this.api           = api;
 }
Beispiel #5
0
 public SignInCase(IAppDbContext context, ILogger <SignInCase> logger, SignInManager <Entity.User> signInManager, IAuthDataProvider dataProvider)
 {
     _context       = context;
     _logger        = logger;
     _signInManager = signInManager;
     _dataProvider  = dataProvider;
 }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IAuthDataProvider authDataProvider, ILogger <Startup> logger, IHostApplicationLifetime hostApplicationLifetime)
        {
            logger.LogInformation($"Connection string: {Configuration.GetConnectionString("SQLServer")}");

            authDataProvider.ApplyChanges();
            app.RegisterWithConsul(hostApplicationLifetime);

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

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseSwaggerWithUI(Configuration["ApiInfo:Name"], Configuration["ApiInfo:Version"]);
            app.UsePrometheusMetric();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Beispiel #7
0
 public SignUpCase(IAppDbContext context, ILogger <SignUpCase> logger, UserManager <Entity.User> userManager, IAuthDataProvider dataProvider, IFileUploader fileUploader, Microsoft.Extensions.Configuration.IConfiguration configuration1)
 {
     _context       = context;
     _logger        = logger;
     _userManager   = userManager;
     _dataProvider  = dataProvider;
     _fileUploader  = fileUploader;
     _configuration = configuration1;
 }
Beispiel #8
0
 /// <summary>
 /// Update the last sign in for a user
 /// </summary>
 /// <param name="auth"></param>
 /// <param name="user"></param>
 /// <param name="log"></param>
 public static Task <Maybe <bool> > UpdateUserLastSignInAsync(IAuthDataProvider auth, AuthUserId user, ILog log)
 {
     log.Vrb("Updating last sign in for user {UserId}.", user.Value);
     return(auth.User.UpdateLastSignInAsync(user)
            .AuditAsync(none: log.Msg)
            .SwitchAsync(
                some: x => F.Some(x),
                none: false
                ));
 }
Beispiel #9
0
        public HarvestRestClient(IAuthDataProvider authDataProvider)
        {
            var refitSettings = new RefitSettings
            {
                JsonSerializerSettings = new JsonSerializerSettings
                {
                    ContractResolver = new SnakeCaseContractResolver()
                }
            };

            HttpMessageHandler clientHandler = new AuthenticatedHttpClientHandler(authDataProvider);

#if DEBUG
            clientHandler = new HttpLoggingHandler(clientHandler);
#endif
            var httpClient = new HttpClient(clientHandler)
            {
                BaseAddress           = new Uri("https://api.harvestapp.com"),
                DefaultRequestHeaders =
                {
                    UserAgent =
                    {
                        new ProductInfoHeaderValue("harvest.net.fork", Assembly.GetExecutingAssembly().GetName().Version.ToString())
                    }
                }
            };
            var tokenHttpClient = new HttpClient(clientHandler)
            {
                BaseAddress           = new Uri("https://id.getharvest.com"),
                DefaultRequestHeaders =
                {
                    UserAgent =
                    {
                        new ProductInfoHeaderValue("harvest.net.fork", Assembly.GetExecutingAssembly().GetName().Version.ToString())
                    }
                }
            };
            _tokenHttpClient = tokenHttpClient;
            _httpClient      = httpClient;

            //_httpClient.DefaultRequestHeaders.Add("Harvest-Account-Id", accountId.ToString());

            Companies       = RestService.For <ICompanyApi>(_httpClient, refitSettings);
            Clients         = RestService.For <IClientApi>(_httpClient, refitSettings);
            Tasks           = RestService.For <ITaskApi>(_httpClient, refitSettings);
            Timesheets      = RestService.For <ITimesheetsApi>(_httpClient, refitSettings);
            Projects        = RestService.For <IProjectsApi>(_httpClient, refitSettings);
            TaskAssignments = RestService.For <ITaskAssignmentsApi>(_httpClient, refitSettings);
            UserAssignments = RestService.For <IUserAssignmentsApi>(_httpClient, refitSettings);
            Token           = RestService.For <IToken>(_tokenHttpClient, refitSettings);
            Account         = RestService.For <IAccountsApi>(_tokenHttpClient, refitSettings);
        }
Beispiel #10
0
 public AccountController(
     IAuthLoginProvider _IAuthLoginService,
     IUserLoginService _login,
     IAuthApi _authApi,
     IAuthDataProvider _dataProvider,
     ICacheProvider _cache)
 {
     this._IAuthLoginService = _IAuthLoginService;
     this._login             = _login;
     this._authApi           = _authApi;
     this._dataProvider      = _dataProvider;
     this._cache             = _cache;
 }
Beispiel #11
0
 public AccountController(
     IAuthLoginService _IAuthLoginService,
     IAuthTokenService _IAuthTokenService,
     LoginStatus logincontext,
     IEFRepository <AuthScope> _AuthScopeRepo,
     IEFRepository <LoginErrorLogEntity> _LogErrorRepo,
     IAuthDataProvider _IValidationDataProvider,
     ICacheProvider _cache)
 {
     this._IAuthLoginService       = _IAuthLoginService;
     this._IAuthTokenService       = _IAuthTokenService;
     this._LoginStatus             = logincontext;
     this._AuthScopeRepo           = _AuthScopeRepo;
     this._LogErrorRepo            = _LogErrorRepo;
     this._IValidationDataProvider = _IValidationDataProvider;
     this._cache = _cache;
 }
Beispiel #12
0
        public ConnectController(
            IAuthDataProvider _IValidationDataProvider,
            IAuthLoginService _IAuthLoginService,
            IAuthTokenService _IAuthTokenService,
            IAuthScopeService _IAuthScopeService,
            IAuthClientService _IAuthClientService,
            IRepository <AuthScope> _AuthScopeRepository,
            IRepository <AuthClient> _AuthClientRepository)
        {
            this._IValidationDataProvider = _IValidationDataProvider;
            this._IAuthLoginService       = _IAuthLoginService;

            this._IAuthTokenService  = _IAuthTokenService;
            this._IAuthScopeService  = _IAuthScopeService;
            this._IAuthClientService = _IAuthClientService;

            this._AuthScopeRepository  = _AuthScopeRepository;
            this._AuthClientRepository = _AuthClientRepository;
        }
Beispiel #13
0
 public AccountController(
     IAuthLoginService _IAuthLoginService,
     IUserService user,
     ILoginLogService loginlog,
     LoginStatus logincontext,
     IRepository <AuthScope> _AuthScopeRepository,
     IAuthTokenService _IAuthTokenService,
     IAuthDataProvider _IValidationDataProvider,
     ICacheProvider _cache)
 {
     this._IAuthLoginService       = _IAuthLoginService;
     this._IUserService            = user;
     this._LoginErrorLogBll        = loginlog;
     this._LoginStatus             = logincontext;
     this._AuthScopeRepository     = _AuthScopeRepository;
     this._IAuthTokenService       = _IAuthTokenService;
     this._IValidationDataProvider = _IValidationDataProvider;
     this._cache = _cache;
 }
Beispiel #14
0
 public AuthManageController(
     IAuthDataProvider _IValidationDataProvider,
     IAuthLoginService _IAuthLoginService,
     IAuthTokenService _IAuthTokenService,
     IAuthScopeService _IAuthScopeService,
     IAuthClientService _IAuthClientService,
     IEFRepository <AuthScope> _AuthScopeRepository,
     IEFRepository <AuthClient> _AuthClientRepository,
     IEFRepository <ReqLogEntity> _ReqLogModelRepository,
     IEFRepository <CacheHitLogEntity> _CacheHitLogRepository,
     ICacheProvider _cache)
 {
     this._IValidationDataProvider = _IValidationDataProvider;
     this._IAuthLoginService       = _IAuthLoginService;
     this._IAuthTokenService       = _IAuthTokenService;
     this._IAuthScopeService       = _IAuthScopeService;
     this._IAuthClientService      = _IAuthClientService;
     this._AuthScopeRepository     = _AuthScopeRepository;
     this._AuthClientRepository    = _AuthClientRepository;
     this._ReqLogModelRepository   = _ReqLogModelRepository;
     this._CacheHitLogRepository   = _CacheHitLogRepository;
     this._cache = _cache;
 }
Beispiel #15
0
 public AuthControllerDataConnector()
 {
     _dataProvider = DataProviderFactory.GetAuthDataProvider();
 }
Beispiel #16
0
 public RouteGuardAuthProvider(IAuthDataProvider <RouteGuardAuthData> authProvider, IBaseHttpClient <AuthResponseModel> httpClient)
 {
     this.httpClient = httpClient;
     authData        = authProvider.GetAuthData();
 }
 public ApplicationUserStore()
 {
     _authDataProvider = DataProviderFactory.GetAuthDataProvider();
 }
Beispiel #18
0
 public RolesController(IAuthDataProvider authDataProvider, IMapperService mapperService)
 {
     this.authDataProvider = authDataProvider;
     this.mapperService    = mapperService;
 }
 public UsersController(IAuthDataProvider db, IMapperService mapperService, ILogger <UsersController> logger)
 {
     this.db            = db;
     this.mapperService = mapperService;
     this.logger        = logger;
 }
Beispiel #20
0
 public AuthService(IAuthDataProvider authDataProvider, ICryptService cryptService, ITokenService tokenService)
 {
     this.authDataProvider = authDataProvider;
     this.cryptService     = cryptService;
     this.tokenService     = tokenService;
 }
Beispiel #21
0
 public ApplicationRoleStore()
 {
     _dataProvider = DataProviderFactory.GetAuthDataProvider();
 }
Beispiel #22
0
 public AuthenticatedHttpClientHandler(IAuthDataProvider provider)
 {
     _provider = provider ?? throw new ArgumentNullException(nameof(provider));
 }
Beispiel #23
0
 public UserController(IUserService userService, IMapperService mapperService, IAuthDataProvider authDataProvider)
 {
     this.userService      = userService;
     this.mapperService    = mapperService;
     this.authDataProvider = authDataProvider;
 }
Beispiel #24
0
 public SignInModel(IAuthDataProvider auth, IAuthJwtProvider jwt, IOptions <AuthConfig> config, ILog <SignInModel> log) : base(auth, jwt, config, log)
 {
 }
Beispiel #25
0
 public UserService(IAuthDataProvider authDataProvider, ITokenService tokenService)
 {
     this.authDataProvider = authDataProvider;
     this.tokenService     = tokenService;
 }