예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddNewtonsoftJson();

            // Create the Bot Framework Adapter with error handling enabled.
            services.AddSingleton <IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();

            // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.)
            services.AddSingleton <IStorage, MemoryStorage>();

            // Create the User state. (Used in this bot's Dialog implementation.)
            services.AddSingleton <UserState>();

            // Create the Conversation state. (Used by the Dialog system itself.)
            services.AddSingleton <ConversationState>();

            // The Dialog that will be run by the bot.
            services.AddSingleton <MainDialog>();

            // Dialog Manager handles initiating the Dialog Stack, saving state, etc.
            services.AddSingleton <DialogManager>();

            // Register the Token Exchange Helper, for processing TokenExchangeOperation Invoke Activities
            services.AddSingleton <TokenExchangeHelper>();

            // Create the bot as a transient. In this case the ASP Controller is expecting an IBot.
            services.AddTransient <IBot, TeamsBot <MainDialog> >();


            services.AddControllersWithViews();
            services.AddHttpClient("WebClient", client => client.Timeout = TimeSpan.FromSeconds(600));
            services.AddHttpContextAccessor();
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(options =>
            {
                var azureAdOptions = new AzureADOptions();
                Configuration.Bind("AzureAd", azureAdOptions);
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidAudiences    = SSOAuthHelper.GetValidAudiences(Configuration),
                    AudienceValidator = SSOAuthHelper.AudienceValidator
                };
            });
        }
예제 #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllersWithViews();
     services.AddHttpClient("WebClient", client => client.Timeout = TimeSpan.FromSeconds(600));
     services.AddHttpContextAccessor();
     services.AddAuthentication(options =>
     {
         options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
     })
     .AddJwtBearer(options =>
     {
         var azureAdOptions = new AzureADOptions();
         Configuration.Bind("AzureAd", azureAdOptions);
         options.Authority = $"{azureAdOptions.Instance}{azureAdOptions.TenantId}/v2.0";
         options.TokenValidationParameters = new TokenValidationParameters
         {
             ValidAudiences    = SSOAuthHelper.GetValidAudiences(Configuration),
             ValidIssuers      = SSOAuthHelper.GetValidIssuers(Configuration),
             AudienceValidator = SSOAuthHelper.AudienceValidator
         };
     });
 }
예제 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDistributedMemoryCache();
            services.AddSession(options => {
                options.Cookie.IsEssential = true;
                options.IdleTimeout        = TimeSpan.FromMinutes(60);//You can set Time
            });
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => false;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddMemoryCache();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddMvc().AddSessionStateTempDataProvider();


            services.AddControllersWithViews();
            services.AddHttpClient("WebClient", client => client.Timeout = TimeSpan.FromSeconds(600));
            services.AddHttpContextAccessor();
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(options =>
            {
                var azureAdOptions = new AzureADOptions();
                Configuration.Bind("AzureAd", azureAdOptions);
                options.Authority = $"{azureAdOptions.Instance}{azureAdOptions.TenantId}/v2.0";
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidAudiences    = SSOAuthHelper.GetValidAudiences(Configuration),
                    ValidIssuers      = SSOAuthHelper.GetValidIssuers(Configuration),
                    AudienceValidator = SSOAuthHelper.AudienceValidator
                };
            });
        }