예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_ => Configuration);
            services.
            AddOptions().
            AddApplicationOptions(Configuration).
            AddApplicationServices();

            var credentialProvider = new StaticCredentialProvider(Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                                                                  Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            services.AddAuthentication(
                options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                )
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var msAppIdKey = Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value;
            var msAppPwd   = Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value;

            var credentialProvider = new StaticCredentialProvider(
                msAppIdKey,
                msAppPwd
                );

            Conversation.UpdateContainer(builder =>
            {
                builder.Register(c =>
                                 new MicrosoftAppCredentials(msAppIdKey, msAppPwd))
                .SingleInstance();
            });

            services.AddAuthentication(
                o =>
            {
                o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                ).AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(
                o =>
            {
                o.Filters.Add(typeof(TrustServiceUrlAttribute));
            }
                ).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_ => Configuration);
            var credentialProvider = new StaticCredentialProvider(Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                                                                  Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            services.AddAuthentication(
                // This can be removed after https://github.com/aspnet/IISIntegration/issues/371
                options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                )
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });

            services.AddFakeRouter();
            services.AddFakeIntentProvider();
            services.AddFakeCommandProcessing();
        }
예제 #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_ => Configuration);

            services.AddSignalR();

            var credentialProvider = new StaticCredentialProvider(Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                                                                  Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            Configuration.GetSection(Configuration["SkypeApiURL"]);
            Configuration.GetSection(Configuration["LocalHubSignalrURL"]);


            services.AddAuthentication(
                // This can be removed after https://github.com/aspnet/IISIntegration/issues/371
                options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                )
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            // Add framework services.
            services.AddScoped <IBotService, BotService>();


            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });
        }
예제 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_ => Configuration);

            var credentialProvider = new StaticCredentialProvider(Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                                                                  Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            services.AddAuthentication(
                // This can be removed after https://github.com/aspnet/IISIntegration/issues/371
                options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                )
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });

            //var builder = new ContainerBuilder();
            //var assemblyCollection = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name.Contains("Bot") ||
            //        !x.GetName().Name.Contains("Services")).Distinct().ToArray();
            //builder
            //.RegisterAssemblyTypes(assemblyCollection)
            //.AsImplementedInterfaces()
            //.InstancePerRequest();
            //builder.Populate(services);
            //var container = builder.Build();
            //return new AutofacServiceProvider(container);
        }
예제 #6
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services">Services Collection</param>
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            var staticFolderLocation = $"{this.Env.WebRootPath}/static";

            if (!Directory.Exists(staticFolderLocation))
            {
                Directory.CreateDirectory(staticFolderLocation);
            }

            var appId       = Environment.GetEnvironmentVariable("MicrosoftAppId");
            var appPassword = Environment.GetEnvironmentVariable("MicrosoftAppPassword");

            Console.WriteLine($"AppId: {appId}");

            // Set up Bot
            services.AddSingleton(_ => this.Configuration);
            var credentialProvider = new StaticCredentialProvider(
                appId,
                appPassword);

            services.AddAuthentication(
                options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            // Set up Dependencies
            services.AddScoped <IYoutubeDownload>((options) => new Youtube_Dl(staticFolderLocation));
            services.AddScoped <IVideoConverter>((options) => new FFMpeg(staticFolderLocation));

            // Timed Services
            services.AddHostedService <DeleteExpiredDownloads>();

            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });
        }
예제 #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var credentialProvider = new StaticCredentialProvider(
                "8fb3babb-5b6b-4265-a510-4391f38c13a2",
                "vlsxzRKBS49997+(-ccVMA%"
                );

            services.AddAuthentication(
                options => {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                ).AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(options => {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });
        }
예제 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(_ => Configuration);

            var credentialProvider = new StaticCredentialProvider(Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                                                                  Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            services.AddAuthentication(
                // This can be removed after https://github.com/aspnet/IISIntegration/issues/371
                options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                )
            .AddBotAuthentication(credentialProvider);

            Conversation.UpdateContainer(
                builder =>
            {
                var store = new InMemoryDataStore();
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(new object())
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new MicrosoftAppCredentials(credentialProvider.AppId, credentialProvider.Password)).SingleInstance();
            });

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            });
        }
예제 #9
0
        /// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add in-mem cache service
            services.AddMemoryCache();

            // Credentials for bot authentication
            var credentialProvider = new StaticCredentialProvider(
                Configuration.GetSection("ProposalManagement:" + MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                Configuration.GetSection("ProposalManagement:" + MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            // Add authentication services
            services.AddAuthentication()
            .AddAzureAdBearer("AzureAdBearer", "AzureAdBearer for web api calls", options => Configuration.Bind("AzureAd", options))
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            // Add Authorization services
            services.AddScoped <IAuthorizationService, AuthorizationService>();

            // Add MVC services
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddDynamicsCRMWebHooks();


            // This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.

            services.AddSession();

            // Register configuration options
            services.Configure <AppOptions>(Configuration.GetSection("ProposalManagement"));
            services.Configure <AzureAdOptions>(Configuration.GetSection("AzureAd"));

            // Add application infrastructure services.
            services.AddSingleton <IGraphAuthProvider, GraphAuthProvider>();   // Auth provider for Graph client, must be singleton
            services.AddSingleton <IWebApiAuthProvider, WebApiAuthProvider>(); // Auth provider for WebApi calls, must be singleton
            services.AddScoped <IGraphClientAppContext, GraphClientAppContext>();
            services.AddScoped <IGraphClientUserContext, GraphClientUserContext>();
            services.AddScoped <IGraphClientOnBehalfContext, GraphClientOnBehalfContext>();
            services.AddTransient <IUserContext, UserIdentityContext>();
            services.AddScoped <IWordParser, WordParser>();
            services.AddScoped <IPowerPointParser, PowerPointParser>();

            // Add core services
            services.AddScoped <IOpportunityFactory, OpportunityFactory>();
            services.AddScoped <IOpportunityRepository, OpportunityRepository>();
            services.AddScoped <IUserProfileRepository, UserProfileRepository>();
            services.AddScoped <IDocumentRepository, DocumentRepository>();
            services.AddScoped <IMetaDataRepository, MetaDataRepository>();
            services.AddScoped <ITemplateRepository, TemplateRepository>();
            services.AddScoped <IProcessRepository, ProcessRepository>();
            services.AddScoped <SharePointListsSchemaHelper>();
            services.AddScoped <GraphSharePointUserService>();
            services.AddScoped <GraphSharePointAppService>();
            services.AddScoped <GraphUserAppService>();
            services.AddScoped <GraphTeamsUserService>();
            services.AddScoped <GraphTeamsAppService>();
            services.AddScoped <GraphTeamsOnBehalfService>();
            services.AddScoped <IAddInHelper, AddInHelper>();
            services.AddSingleton <IAzureKeyVaultService, AzureKeyVaultService>();

            // FrontEnd services
            services.AddScoped <IOpportunityService, OpportunityService>();
            services.AddScoped <IDocumentService, DocumentService>();
            services.AddScoped <IUserProfileService, UserProfileService>();
            services.AddScoped <IContextService, ContextService>();
            services.AddScoped <IMetaDataService, MetaDataService>();
            services.AddScoped <ISetupService, SetupService>();
            services.AddScoped <UserProfileHelpers>();
            services.AddScoped <TemplateHelpers>();
            services.AddScoped <OpportunityHelpers>();
            services.AddScoped <CardNotificationService>();
            services.AddScoped <ITemplateService, TemplateService>();
            services.AddScoped <IProcessService, ProcessService>();
            services.AddScoped <IRoleRepository, RoleRepository>();
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <IPowerBIService, PowerBIService>();
            services.AddScoped <IPermissionRepository, PermissionRepository>();
            services.AddScoped <IPermissionService, PermissionService>();
            services.AddScoped <IGroupsRepository, GroupsRepository>();
            services.AddScoped <IGroupsService, GroupsService>();

            // DealType Services
            services.AddScoped <ICheckListProcessService, CheckListProcessService>();
            services.AddScoped <ICustomerFeedbackProcessService, CustomerFeedbackProcessService>();
            services.AddScoped <ICustomerDecisionProcessService, CustomerDecisionProcessService>();
            services.AddScoped <IProposalDocumentProcessService, ProposalDocumentProcessService>();
            services.AddScoped <INewOpportunityProcessService, NewOpportunityProcessService>();
            services.AddScoped <IStartProcessService, StartProcessService>();
            services.AddScoped <ITeamChannelService, TeamChannelService>();
            services.AddScoped <IMemberService, MemberService>();
            services.AddScoped <INotesService, NotesService>();

            // SmartLink
            services.AddScoped <IDocumentIdService, DocumentIdService>();

            // Dynamics CRM Integration
            services.AddScoped <IDynamicsClientFactory, DynamicsClientFactory>();
            services.AddScoped <IProposalManagerClientFactory, ProposalManagerClientFactory>();
            services.AddScoped <IAccountRepository, AccountRepository>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <IConnectionRoleRepository, ConnectionRoleRepository>();
            services.AddScoped <ISharePointLocationRepository, SharePointLocationRepository>();
            services.AddScoped <IOneDriveLinkService, OneDriveLinkService>();
            services.AddScoped <IDynamicsLinkService, DynamicsLinkService>();
            services.AddSingleton <IConnectionRolesCache, ConnectionRolesCache>();
            services.AddSingleton <ISharePointLocationsCache, SharePointLocationsCache>();
            services.AddSingleton <IDeltaLinksStorage, DeltaLinksStorage>();

            //Dashboars services
            services.AddScoped <IDashboardRepository, DashBoardRepository>();
            services.AddScoped <IDashboardService, DashboardService>();
            services.AddScoped <IDashboardAnalysis, DashBoardAnalysis>();
            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });



            //Configure writing to appsettings
            services.ConfigureWritable <AppOptions>(Configuration.GetSection("ProposalManagement"));
            services.ConfigureWritable <DocumentIdActivatorConfiguration>(Configuration.GetSection("DocumentIdActivator"));
        }
예제 #10
0
        /// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add CORS exception to enable authentication in Teams Client
            //services.AddCors(options =>
            //{
            //    options.AddPolicy("AllowSpecificOrigins",
            //    builder =>
            //    {
            //        builder.WithOrigins("https://webreact20180403042343.azurewebsites.net", "https://login.microsoftonline.com");
            //    });

            //    options.AddPolicy("AllowAllMethods",
            //        builder =>
            //        {
            //            builder.WithOrigins("https://webreact20180403042343.azurewebsites.net")
            //                   .AllowAnyMethod();
            //        });

            //    options.AddPolicy("ExposeResponseHeaders",
            //        builder =>
            //        {
            //            builder.WithOrigins("https://webreact20180403042343.azurewebsites.net")
            //                   .WithExposedHeaders("X-Frame-Options");
            //        });
            //});

            // Add in-mem cache service
            services.AddMemoryCache();

            // Credentials for bot authentication
            var credentialProvider = new StaticCredentialProvider(
                Configuration.GetSection("ProposalManagement:" + MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                Configuration.GetSection("ProposalManagement:" + MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            // Add authentication services
            services.AddAuthentication()
            .AddAzureAdBearer("AzureAdBearer", "AzureAdBearer for web api calls", options => Configuration.Bind("AzureAd", options))
            .AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            // Add Authorization services
            services.AddScoped <Infrastructure.Authorization.IAuthorizationService, AuthorizationService>();

            // Add MVC services
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddDynamicsCRMWebHooks();


            // This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.

            services.AddSession();

            // Register configuration options
            services.Configure <AppOptions>(Configuration.GetSection("ProposalManagement"));

            // Add application infrastructure services.
            services.AddSingleton <IGraphAuthProvider, GraphAuthProvider>();   // Auth provider for Graph client, must be singleton
            services.AddSingleton <IWebApiAuthProvider, WebApiAuthProvider>(); // Auth provider for WebApi calls, must be singleton
            services.AddScoped <IGraphClientAppContext, GraphClientAppContext>();
            services.AddScoped <IGraphClientUserContext, GraphClientUserContext>();
            services.AddTransient <IUserContext, UserIdentityContext>();
            services.AddScoped <IWordParser, WordParser>();

            // Add core services
            services.AddScoped <IOpportunityFactory, OpportunityFactory>();
            services.AddScoped <IOpportunityRepository, OpportunityRepository>();
            services.AddScoped <IUserProfileRepository, UserProfileRepository>();
            services.AddScoped <IDocumentRepository, DocumentRepository>();
            services.AddScoped <IRegionRepository, RegionRepository>();
            services.AddScoped <IIndustryRepository, IndustryRepository>();
            services.AddScoped <ICategoryRepository, CategoryRepository>();
            services.AddScoped <IRoleMappingRepository, RoleMappingRepository>();
            services.AddScoped <ITemplateRepository, TemplateRepository>();
            services.AddScoped <IProcessRepository, ProcessRepository>();
            services.AddScoped <GraphSharePointAppService>();
            services.AddScoped <SharePointListsSchemaHelper>();
            services.AddScoped <GraphSharePointUserService>();
            services.AddScoped <GraphTeamUserService>();
            services.AddScoped <GraphUserAppService>();
            services.AddScoped <GraphTeamsAppService>();
            services.AddScoped <IAddInHelper, AddInHelper>();

            // FrontEnd services
            services.AddScoped <IOpportunityService, OpportunityService>();
            services.AddScoped <IDocumentService, DocumentService>();
            services.AddScoped <IUserProfileService, UserProfileService>();
            services.AddScoped <IRegionService, RegionService>();
            services.AddScoped <IIndustryService, IndustryService>();
            services.AddScoped <IRoleMappingService, RoleMappingService>();
            services.AddScoped <IContextService, ContextService>();
            services.AddScoped <ICategoryService, CategoryService>();
            services.AddScoped <ISetupService, SetupService>();
            services.AddScoped <UserProfileHelpers>();
            services.AddScoped <TemplateHelpers>();
            services.AddScoped <OpportunityHelpers>();
            services.AddScoped <CardNotificationService>();
            services.AddScoped <ITemplateService, TemplateService>();
            services.AddScoped <IProcessService, ProcessService>();
            services.AddScoped <IRoleRepository, RoleRepository>();
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <IPowerBIService, PowerBIService>();
            services.AddScoped <IPermissionRepository, PermissionRepository>();
            services.AddScoped <IPermissionService, PermissionService>();

            // DealType Services
            services.AddScoped <CheckListProcessService>();
            services.AddScoped <CustomerFeedbackProcessService>();
            services.AddScoped <CustomerDecisionProcessService>();
            services.AddScoped <ProposalStatusProcessService>();
            services.AddScoped <NewOpportunityProcessService>();
            services.AddScoped <StartProcessService>();

            // SmartLink
            services.AddScoped <IDocumentIdService, DocumentIdService>();

            // Dynamics CRM Integration
            services.AddScoped <IDynamicsClientFactory, DynamicsClientFactory>();
            services.AddScoped <IProposalManagerClientFactory, ProposalManagerClientFactory>();
            services.AddScoped <IAccountRepository, AccountRepository>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <IConnectionRoleRepository, ConnectionRoleRepository>();
            services.AddScoped <ISharePointLocationRepository, SharePointLocationRepository>();
            services.AddScoped <IOneDriveLinkService, OneDriveLinkService>();
            services.AddScoped <IDynamicsLinkService, DynamicsLinkService>();
            services.AddSingleton <IConnectionRolesCache, ConnectionRolesCache>();
            services.AddSingleton <ISharePointLocationsCache, SharePointLocationsCache>();
            services.AddSingleton <IDeltaLinksStorage, DeltaLinksStorage>();

            //Dashboars services
            services.AddScoped <IDashboardRepository, DashBoardRepository>();
            services.AddScoped <IDashboardService, DashboardService>();
            services.AddScoped <IDashboardAnalysis, DashBoardAnalysis>();
            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });



            //Configure writing to appsettings
            services.ConfigureWritable <AppOptions>(Configuration.GetSection("ProposalManagement"));
            services.ConfigureWritable <DocumentIdActivatorConfiguration>(Configuration.GetSection("DocumentIdActivator"));

            // Register the Swagger generator, defining 1 or more Swagger documents
            //services.AddSwaggerGen(c =>
            //{
            //    c.SwaggerDoc("v1", new Info
            //    {
            //        Version = "v1",
            //        Title = "Proposal Manager API",
            //        Description = "APIs to do CURD operations in Sharepoint schema using Microsoft Graph APIS for Proposal Management App"
            //    });

            //    var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
            //    var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
            //    c.IncludeXmlComments(xmlPath);

            //    c.OperationFilter<AddFileParamTypesOperationFilter>();
            //    c.OperationFilter<AddResponseHeadersFilter>(); // [SwaggerResponseHeader]
            //    c.OperationFilter<AppendAuthorizeToSummaryOperationFilter>();

            //    c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description = "Please enter JWT with Bearer into field", Name = "Authorization", Type = "apiKey" });
            //    c.AddSecurityRequirement(new Dictionary<string, IEnumerable<string>>
            //        {
            //            { "Bearer", Enumerable.Empty<string>() },
            //        }
            //    );

            //});

            //services.AddSwaggerExamplesFromAssemblyOf<RoleMappingModelExample>();
            // Register the Swagger generator, defining 1 or more Swagger documents
        }
예제 #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add CORS exception to enable authentication in Teams Client
            //services.AddCors(options =>
            //{
            //    options.AddPolicy("AllowSpecificOrigins",
            //    builder =>
            //    {
            //        builder.WithOrigins("https://webreact20180403042343.azurewebsites.net", "https://login.microsoftonline.com");
            //    });

            //    options.AddPolicy("AllowAllMethods",
            //        builder =>
            //        {
            //            builder.WithOrigins("https://webreact20180403042343.azurewebsites.net")
            //                   .AllowAnyMethod();
            //        });

            //    options.AddPolicy("ExposeResponseHeaders",
            //        builder =>
            //        {
            //            builder.WithOrigins("https://webreact20180403042343.azurewebsites.net")
            //                   .WithExposedHeaders("X-Frame-Options");
            //        });
            //});

            // Add in-mem cache service
            services.AddMemoryCache();

            // Credentials for bot authentication
            var credentialProvider = new StaticCredentialProvider(
                Configuration.GetSection("ProposalManagement:" + MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                Configuration.GetSection("ProposalManagement:" + MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            // Add authentication services
            services.AddAuthentication(sharedOptions =>
            {
                sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
                //sharedOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddAzureAdBearer(options => Configuration.Bind("AzureAd", options));

            //services.AddAuthentication(sharedOptions =>
            //{
            //    sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
            //    sharedOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

            //})
            //.AddBotAuthentication(credentialProvider);

            // Add MVC services
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(TrustServiceUrlAttribute));
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);


            // This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.
            services.AddMemoryCache();
            services.AddSession();

            // Register configuration options
            services.Configure <AppOptions>(Configuration.GetSection("ProposalManagement"));

            // Add application infrastructure services.
            services.AddSingleton <IGraphAuthProvider, GraphAuthProvider>();            // Auth provider for Graph client, must be singleton
            services.AddScoped <IGraphClientAppContext, GraphClientAppContext>();
            services.AddScoped <IGraphClientUserContext, GraphClientUserContext>();
            services.AddTransient <IUserContext, UserIdentityContext>();
            services.AddScoped <IWordParser, WordParser>();

            // Add core services
            services.AddScoped <IOpportunityFactory, OpportunityFactory>();
            services.AddScoped <IOpportunityRepository, OpportunityRepository>();
            services.AddScoped <IUserProfileRepository, UserProfileRepository>();
            services.AddScoped <IDocumentRepository, DocumentRepository>();
            services.AddScoped <IRegionRepository, RegionRepository>();
            services.AddScoped <IIndustryRepository, IndustryRepository>();
            services.AddScoped <ICategoryRepository, CategoryRepository>();
            services.AddScoped <IRoleMappingRepository, RoleMappingRepository>();
            services.AddScoped <INotificationRepository, NotificationRepository>();
            services.AddScoped <GraphSharePointAppService>();
            services.AddScoped <GraphSharePointUserService>();
            services.AddScoped <GraphTeamUserService>();
            services.AddScoped <GraphUserAppService>();

            // FrontEnd services
            services.AddScoped <IOpportunityService, OpportunityService>();
            services.AddScoped <IDocumentService, DocumentService>();
            services.AddScoped <IUserProfileService, UserProfileService>();
            services.AddScoped <IRegionService, RegionService>();
            services.AddScoped <IIndustryService, IndustryService>();
            services.AddScoped <IRoleMappingService, RoleMappingService>();

            services.AddScoped <ICategoryService, CategoryService>();
            services.AddScoped <INotificationService, NotificationService>();
            services.AddScoped <IContextService, ContextService>();
            services.AddScoped <UserProfileHelpers>();
            services.AddScoped <OpportunityHelpers>();
            services.AddScoped <CardNotificationService>();

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            // This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.
            services.AddMemoryCache();
            services.AddSession();
        }
예제 #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            Serilog.Log.Logger = new LoggerConfiguration()
                                 .MinimumLevel.Debug()
                                 .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                                 .MinimumLevel.Override("System", LogEventLevel.Information)
                                 .MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
                                 //amit ebben a könyvtárban írok, az megjelenik az
                                 //azure AppService napló streamjében
                                 //ez már nem működik, helyette: https://github.com/serilog/serilog-aspnetcore
                                 //.WriteTo.File(@"D:\home\LogFiles\http\RawLogs\log.txt")
                                 .WriteTo.File(
                @"D:\home\LogFiles\Application\myapp.txt",
                fileSizeLimitBytes: 1_000_000,
                rollOnFileSizeLimit: true,
                shared: true,
                flushToDiskInterval: TimeSpan.FromSeconds(1))
                                 .WriteTo.File(@"log.txt")
                                 .CreateLogger();

            var msAppIdKey = Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value;
            var msAppPwd   = Configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value;

            var credentialProvider = new StaticCredentialProvider(
                msAppIdKey,
                msAppPwd
                );

            var store = new InMemoryDataStore();

            Conversation.UpdateContainer(builder =>
            {
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();

                builder.Register(c =>
                                 new MicrosoftAppCredentials(msAppIdKey, msAppPwd))
                .SingleInstance();
            });

            services.AddAuthentication(
                o =>
            {
                o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }
                ).AddBotAuthentication(credentialProvider);

            services.AddSingleton(typeof(ICredentialProvider), credentialProvider);

            services.AddMvc(
                o =>
            {
                o.Filters.Add(typeof(TrustServiceUrlAttribute));
            }
                ).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }