Beispiel #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            var IDPSettings = new IDPSettings();

            Configuration.Bind("IDPSettings", IDPSettings);
            services.AddSingleton(IDPSettings);

            services.AddNodeServices();

            services.AddControllersWithViews().AddNewtonsoftJson();
            services.AddHttpContextAccessor();

            // --------- START SCRUM ------------------------------
            services.AddTransient <IHttpContextAccessor, HttpContextAccessor>();
            services.AddHttpClient <IAPIClient, APIClient>(options =>
            {
                options.BaseAddress = new Uri(IDPSettings.LunchAppUrl);
                options.DefaultRequestHeaders.Accept.Clear();
            });
            services.AddTransient <IAPIServices, APIServices>();
            // ---------- END SCRUM -------------------

            services.AddScoped <HCMAdminHTTPClient, HCMAdminHTTPClientIdentity>();
            services.AddScoped <IHelperInterface, ApiHelper>();
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            ConfigureIdentityServer(services);
        }
Beispiel #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            var IDPSettings = new IDPSettings();

            Configuration.Bind("IDPSettings", IDPSettings);
            services.AddSingleton(IDPSettings);

            services.AddNodeServices();

            services.AddControllersWithViews().AddNewtonsoftJson();
            services.AddHttpContextAccessor();

            // --------- START SCRUM ------------------------------
            services.AddTransient <IHttpContextAccessor, HttpContextAccessor>();
            services.AddHttpClient <IAPIClient, APIClient>(options =>
            {
                options.BaseAddress = new Uri(IDPSettings.LunchAppUrl);
                options.DefaultRequestHeaders.Accept.Clear();
            });
            services.AddTransient <IAPIServices, APIServices>();
            // ---------- END SCRUM -------------------

            services.AddScoped <HCMAdminHTTPClient, HCMAdminHTTPClientIdentity>();
            services.AddScoped <IHelperInterface, ApiHelper>();
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddAuthentication(options =>
            {
                options.DefaultScheme          = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = "oidc";
            })
            .AddCookie(options =>
            {
                options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
                options.Cookie.Name    = "lunchAppCookies";
                //options.Cookie.SameSite = SameSiteMode.Strict;
                // options.Cookie.HttpOnly = true;
            })
            .AddOpenIdConnect("oidc", options =>
            {
                options.Authority            = IDPSettings.Authority;
                options.SignedOutRedirectUri = IDPSettings.SignOutURL;
                options.ClientId             = IDPSettings.ClientId;
                options.RequireHttpsMetadata = false;
                options.CallbackPath         = IDPSettings.Callback;

                options.Scope.Clear();
                options.Scope.Add("email");
                options.Scope.Add("openid");
                options.Scope.Add("profile");
                options.Scope.Add(IDPSettings.ApiId);
                options.ResponseType = "code";
                options.SaveTokens   = true;
            });
        }
Beispiel #3
0
 public IDPSettings()
 {
     Current = this;
 }