Ejemplo n.º 1
0
 public ApplicationController(ILoggerFactory logger, IHostingEnvironment hostingEnvironment, IJwtService jwtService, IDataProtectionService dataProtectionService)
 {
     _logger                = logger.CreateLogger(LogCategories.PORTAL);
     _hostingEnvironment    = hostingEnvironment;
     _jwtService            = jwtService;
     _dataProtectionService = dataProtectionService;
 }
Ejemplo n.º 2
0
 public AppSettingsService(IAsyncRepository <AppSettings> appSettingsRepository, IDataProtectionService dataProtectionService, IMemoryCache memoryCache, ILogger <AppSettingsService> logger)
 {
     _appSettingsRepository = appSettingsRepository;
     _dataProtectionService = dataProtectionService;
     _memoryCache           = memoryCache;
     _logger = logger;
 }
Ejemplo n.º 3
0
 public DataProtectionController(IMailService mailService,
                                 IDataProtectionService dataProtectionService, IUserService userService)
 {
     _mailService           = mailService;
     _dataProtectionService = dataProtectionService;
     _userService           = userService;
 }
Ejemplo n.º 4
0
 public RequestTutorEmailOperation(ICommandBus commandBus, IUrlBuilder urlBuilder, IDataProtectionService dataProtectionService, IQueryBus queryBus)
 {
     _commandBus            = commandBus;
     _urlBuilder            = urlBuilder;
     _dataProtectionService = dataProtectionService;
     _queryBus = queryBus;
 }
Ejemplo n.º 5
0
 public RequestTutorAdminEmailOperation(ICommandBus commandBus, IUrlBuilder urlBuilder, IDataProtectionService dataProtectionService, IQueryBus queryBus,
                                        IConfigurationKeys configuration)
 {
     _commandBus            = commandBus;
     _urlBuilder            = urlBuilder;
     _dataProtectionService = dataProtectionService;
     _queryBus      = queryBus;
     _configuration = configuration;
 }
Ejemplo n.º 6
0
 public SharedAccountService(IAsyncRepository <SharedAccount> sharedAccountRepository,
                             IAccountService accountService,
                             IHardwareVaultTaskService hardwareVaultTaskService,
                             IDataProtectionService dataProtectionService)
 {
     _sharedAccountRepository  = sharedAccountRepository;
     _accountService           = accountService;
     _hardwareVaultTaskService = hardwareVaultTaskService;
     _dataProtectionService    = dataProtectionService;
 }
 public DataProtectionController(ILogger <BaseController> logger,
                                 IConfiguration configuration,
                                 IBuildDataProtectionVmService buildDataProtectionVm,
                                 IDataProtectionService dataProtectionService,
                                 IGtmService gtmService,
                                 IWebActivityService webActionLoggingService,
                                 IDistributedCache distributedCache,
                                 IApplicationSessionState applicationSessionState) : base(logger, distributedCache, applicationSessionState, configuration)
 {
     _buildDataProtectionVm = buildDataProtectionVm;
     _dataProtectionService = dataProtectionService;
     _gtmService            = gtmService;
     _webActivityService    = webActionLoggingService;
 }
 public RemoteDeviceConnectionsService(IServiceProvider services,
                                       IHardwareVaultService hardwareVaultService,
                                       IRemoteTaskService remoteTaskService,
                                       IEmployeeService employeeService,
                                       IDataProtectionService dataProtectionService,
                                       ILogger <RemoteDeviceConnectionsService> logger)
 {
     _services              = services;
     _hardwareVaultService  = hardwareVaultService;
     _remoteTaskService     = remoteTaskService;
     _employeeService       = employeeService;
     _dataProtectionService = dataProtectionService;
     _logger = logger;
 }
Ejemplo n.º 9
0
 public RemoteTaskService(IHardwareVaultService hardwareVaultService,
                          IHardwareVaultTaskService hardwareVaultTaskService,
                          IAccountService accountService,
                          IDataProtectionService dataProtectionService,
                          ILdapService ldapService,
                          IAppSettingsService appSettingsService,
                          ISynchronizationService synchronizationService)
 {
     _hardwareVaultService     = hardwareVaultService;
     _hardwareVaultTaskService = hardwareVaultTaskService;
     _accountService           = accountService;
     _dataProtectionService    = dataProtectionService;
     _ldapService            = ldapService;
     _appSettingsService     = appSettingsService;
     _synchronizationService = synchronizationService;
 }
Ejemplo n.º 10
0
 public SamlController(ILoggerFactory logger, IOptions <AuthConfiguration> spidConfiguration,
                       RequestOptionFactory requestOptionFactory, IAuthRequest authRequest, IAuthResponse authResponse, ILogoutResponse logoutResponse,
                       ITokenService tokenService, IdpHelper idpHelper, IDataProtectionService dataProtectionService)
 {
     _logger                = logger.CreateLogger(LogCategories.AUTHENGINE);
     _traceLogger           = logger.CreateLogger(LogCategories.SAMLTRACE);
     _sessionAuthLogger     = logger.CreateLogger(LogCategories.AUTHSESSION);
     _spidConfiguration     = spidConfiguration?.Value;
     _requestOptionFactory  = requestOptionFactory;
     _authRequest           = authRequest;
     _authResponse          = authResponse;
     _logoutResponse        = logoutResponse;
     _tokenService          = tokenService;
     _idpHelper             = idpHelper;
     _dataProtectionService = dataProtectionService;
 }
Ejemplo n.º 11
0
 public EmployeeService(IAsyncRepository <Employee> employeeRepository,
                        IHardwareVaultService hardwareVaultService,
                        IHardwareVaultTaskService hardwareVaultTaskService,
                        ISoftwareVaultService softwareVaultService,
                        IAccountService accountService,
                        ISharedAccountService sharedAccountService,
                        IWorkstationService workstationService,
                        IDataProtectionService dataProtectionService)
 {
     _employeeRepository       = employeeRepository;
     _hardwareVaultService     = hardwareVaultService;
     _hardwareVaultTaskService = hardwareVaultTaskService;
     _softwareVaultService     = softwareVaultService;
     _accountService           = accountService;
     _sharedAccountService     = sharedAccountService;
     _workstationService       = workstationService;
     _dataProtectionService    = dataProtectionService;
 }
Ejemplo n.º 12
0
 public AccountService(IUserRepository repository, IDataProtectionService dataProtectionService)
 {
     _repository     = repository;
     _dataProtection = dataProtectionService;
 }
Ejemplo n.º 13
0
 public TestableService(IXmlFileService xmlFileService, IDataProtectionService dataProtectionService)
     : base(xmlFileService, dataProtectionService)
 {
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsService"/> class.
 /// </summary>
 public SettingsService(Context appContext, IXmlFileService xmlFileService, IDataProtectionService dataProtectionService)
     : base(xmlFileService, dataProtectionService)
 {
     _appContext = appContext;
 }
Ejemplo n.º 15
0
 public CustomJwtBearerEvents(IJwtService jwtService, IDataProtectionService dataProtectionService)
 {
     _dataProtectionService = dataProtectionService;
     _jwtService            = jwtService;
 }
 public DataProtectionServiceProtectTests(ITestOutputHelper testOutputHelper, IDataProtectionServiceFactory dataProtectionServiceFactory)
 {
     _testOutputHelper             = testOutputHelper;
     _dataProtectionServiceFactory = dataProtectionServiceFactory;
     _dataProtectionService        = dataProtectionServiceFactory.CreateInstance("tests");
 }
Ejemplo n.º 17
0
 public TestableService(IXmlFileService xmlFileService, IDataProtectionService dataProtectionService, IEnvironmentService environmentService)
     : base(xmlFileService, dataProtectionService, environmentService)
 {
 }
Ejemplo n.º 18
0
 public SettingsServiceBase(IXmlFileService xmlFileService, IDataProtectionService dataProtectionService, IEnvironmentService environmentService)
 {
     _xmlFileService        = xmlFileService;
     _dataProtectionService = dataProtectionService;
     _environmentSettings   = environmentService;
 }
Ejemplo n.º 19
0
 public EntityRepository(ApplicationDbContext dbContext, IDataProtectionService dataProtection, IHttpContextAccessor httpContextAccessor)
 {
     _dbContext           = dbContext;
     _dataProtection      = dataProtection;
     _httpContextAccessor = httpContextAccessor;
 }
Ejemplo n.º 20
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IConfigurationSection jwtAppSettings = Configuration.GetSection(nameof(JwtConfiguration));
            IConfigurationSection authSettings   = Configuration.GetSection(nameof(AuthConfiguration));

            services.AddProtectionData(this.Configuration);

            services.AddSAMLAuth(this.Configuration);
            services.AddSPIDLogging();

            services.AddTransient <CustomJwtBearerEvents>();

            ServiceProvider        sp = services.BuildServiceProvider();
            IDataProtectionService dataProtectionService = sp.GetService <IDataProtectionService>();
            SymmetricSecurityKey   signingKey            = dataProtectionService.GetSigningKey();

            services.AddJwtSPID(this.Configuration, signingKey);
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddCookie()
            .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, cfg =>
            {
                cfg.RequireHttpsMetadata = true;
                cfg.SaveToken            = true;

                cfg.TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateIssuer = true,
                    ValidIssuer    = jwtAppSettings[nameof(JwtConfiguration.Issuer)],

                    ValidateAudience = true,
                    ValidAudience    = jwtAppSettings[nameof(JwtConfiguration.Issuer)],

                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = signingKey,

                    ValidateLifetime = true,
                    ClockSkew        = TimeSpan.Zero
                };

                cfg.EventsType = typeof(CustomJwtBearerEvents);
            });

            services.AddOptions();
            services.Configure <ClientConfiguration>(options =>
            {
                options.IdpType         = authSettings.GetValue <IdpType>(nameof(AuthConfiguration.IdpType));
                options.ApplicationName = this.Configuration.GetValue <string>(nameof(ClientConfiguration.ApplicationName));
            });

            Assembly             externalAssembly     = typeof(SamlController).GetTypeInfo().Assembly;
            EmbeddedFileProvider embeddedFileProvider = new EmbeddedFileProvider(externalAssembly, "VecompSoftware.DocSuite.SPID.AuthEngine");

            services.Configure <RazorViewEngineOptions>(options =>
            {
                options.FileProviders.Add(embeddedFileProvider);
            });

            IConfigurationSection corsOrigins = Configuration.GetSection("AllowedOrigins");

            string[] allowedOrigins = corsOrigins.Get <string[]>();
            services.AddCors(options =>
            {
                options.AddPolicy("AllowSpecificOrigin",
                                  builder => builder
                                  .WithOrigins(allowedOrigins)
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });
            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
            });
        }
Ejemplo n.º 21
0
        public static async Task SendEmail(
            [ActivityTrigger] UpdateUserEmailDto user,
            [SendGrid(ApiKey = "SendgridKey", From = "Spitball <*****@*****.**>")] IAsyncCollector <SendGridMessage> emailProvider,
            [Inject] IQueryBus queryBus,
            [Inject] IUrlBuilder urlBuilder,
            [Inject] IDataProtectionService dataProtectService,
            [Inject] IHostUriService hostUriService,
            CancellationToken token)
        {
            var code = dataProtectService.ProtectData(user.UserId.ToString(), DateTimeOffset.UtcNow.AddDays(3));
            var uri  = hostUriService.GetHostUri();

            var questionNvc = new NameValueCollection()
            {
                ["width"]  = "86",
                ["height"] = "96",
                ["mode"]   = "crop"
            };

            var q      = new GetUpdatesEmailByUserQuery(user.UserId, user.Since);
            var result = (await queryBus.QueryAsync(q, token)).ToList();

            if (result.Count == 0)
            {
                return;
            }
            var courses = result.GroupBy(g => g.Course).Take(3).Select(s =>
            {
                var emailUpdates = s.Take(4).ToList();
                return(new Course()
                {
                    Name = s.Key,
                    Url = urlBuilder.BuildCourseEndPoint(s.Key),
                    NeedMore = emailUpdates.Count == 4,
                    Documents = emailUpdates.OfType <DocumentUpdateEmailDto>().Select(document =>
                    {
                        var uriBuilder = new UriBuilder(uri)
                        {
                            Path = $"api/image/document/{document.Id}",
                        };
                        uriBuilder.AddQuery(questionNvc);

                        return new Document()
                        {
                            Url = urlBuilder.BuildDocumentEndPoint(document.Id, new { token = code }),
                            Name = document.Name,
                            UserName = document.UserName,
                            DocumentPreview = uriBuilder.ToString(),
                            UserImage = BuildUserImage(document.UserId, document.UserImage, document.UserName, hostUriService)
                        };
                    }),
                    Questions = emailUpdates.OfType <QuestionUpdateEmailDto>().Select(question => new Question()
                    {
                        QuestionUrl = urlBuilder.BuildQuestionEndPoint(question.QuestionId, new { token = code }),
                        QuestionText = question.QuestionText,
                        UserImage = BuildUserImage(question.UserId, question.UserImage, question.UserName, hostUriService),
                        UserName = question.UserName,
                        AnswerText = question.AnswerText
                    })
                });
            });

            var templateData = new UpdateEmail(user.UserName, user.ToEmailAddress, user.Language.TextInfo.IsRightToLeft)
            {
                DocumentCountUpdate = result.OfType <DocumentUpdateEmailDto>().Count(),
                QuestionCountUpdate = result.OfType <QuestionUpdateEmailDto>().Count(),
                Courses             = courses
            };

            var message = new SendGridMessage
            {
                Asm = new ASM {
                    GroupId = UnsubscribeGroup.Update
                },
                TemplateId = Equals(user.Language, Language.Hebrew.Info)
                    ? HebrewTemplateId : EnglishTemplateId
            };

            templateData.To = user.ToEmailAddress;
            var personalization = new Personalization
            {
                TemplateData = templateData
            };


            message.Personalizations = new List <Personalization>()
            {
                personalization
            };
            message.AddCategory("updates");
            message.TrackingSettings = new TrackingSettings
            {
                Ganalytics = new Ganalytics
                {
                    UtmCampaign = "updates",
                    UtmSource   = "SendGrid",
                    UtmMedium   = "Email",
                    Enable      = true
                }
            };
            message.AddTo(user.ToEmailAddress);
            await emailProvider.AddAsync(message, token);

            await emailProvider.FlushAsync(token);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsService"/> class.
 /// </summary>
 public SettingsService(IXmlFileService xmlFileService, IDataProtectionService dataProtectionService)
     : base(xmlFileService, dataProtectionService)
 {
 }
Ejemplo n.º 23
0
 public JwtService(IOptions <JwtConfiguration> jwtConfiguration, IDataProtectionService dataProtectionService, IDistributedCache memoryCache)
 {
     _jwtConfiguration      = jwtConfiguration?.Value;
     _dataProtectionService = dataProtectionService;
     _memoryCache           = memoryCache;
 }
Ejemplo n.º 24
0
 public CredentialService(IFileSystem fileSystem, IDataProtectionService dataProtectionService)
 {
     this.fileSystem = fileSystem;
     this.dataProtectionService = dataProtectionService;
 }
Ejemplo n.º 25
0
 public UserRepository(ApplicationDbContext dbContext, IDataProtectionService dataProtection)
 {
     _dbContext = dbContext;
 }
Ejemplo n.º 26
0
 public Handler(IDataContext dataContext, IDataProtectionService protectionService)
 {
     _dataContext       = dataContext;
     _protectionService = protectionService;
 }
Ejemplo n.º 27
0
 public SettingsServiceBase(IXmlFileService xmlFileService, IDataProtectionService dataProtectionService)
 {
     _xmlFileService        = xmlFileService;
     _dataProtectionService = dataProtectionService;
 }