예제 #1
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
         };
     });
 }
예제 #2
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
                };
            });
        }