Ejemplo n.º 1
0
        public void CantInstantiateWithEmptyClientSecret()
        {
            Exception exception =
                Assert.Throws <NexaasIDException>(() => NexaasID.Production("client id", string.Empty));

            Assert.Equal(exception.Message, Messages.EmptyClientSecret);
        }
Ejemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            //Retrive Nexaas ID application configuration
            var clientId     = Configuration.GetSection("NexaasIDConfig:ClientId").Value;
            var clientSecret = Configuration.GetSection("NexaasIDConfig:clientSecret").Value;
            var redirectUri  = Configuration.GetSection("NexaasIDConfig:RedirectUri").Value;

            //Setup Nexaas.ID.Client
            var nexaasId = Env.IsProduction()
                ? NexaasID.Production(clientId, clientSecret, redirectUri)
                : NexaasID.Sandbox(clientId, clientSecret, redirectUri);

            //Add Nexaas.ID.Client in DI container
            services.AddSingleton(nexaasId);

            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            //Configure cookie authentication
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.Cookie.Name    = "NexaasIdCookie";
                options.ExpireTimeSpan = TimeSpan.FromSeconds(7200);
                options.LoginPath      = "/auth";
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Ejemplo n.º 3
0
        public void CantInstantiateWithInvalidRedirectUril()
        {
            Exception exception =
                Assert.Throws <NexaasIDException>(() =>
                                                  NexaasID.Production("client id", "client secret", "invalid_uri"));

            Assert.Equal(exception.Message, Messages.InvalidRedirectUri);
        }