Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookieAuthentication();
            app.UseCors(builder => builder.WithOrigins("*"));

            OpenIdConnect.ConfigureApp(app, Configuration, loggerFactory.CreateLogger("OpenIdConnect"));
            JwtBearer.Configure(app, Configuration);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Config config = new Config();

            log.Info("Clicked...........................");

            OpenIdConnect oidc = new OpenIdConnect();
            String        uri  = oidc.Connect();

            Response.Redirect(uri);
        }
Ejemplo n.º 3
0
        public Dictionary <string, string> CallBackReciever()
        {
            var           code = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["code"];
            OpenIdConnect oidc = new OpenIdConnect();

            if (code != null)
            {
                oidc.GetUserInfo(code);
                if (oidc.userInfo != null)
                {
                    log.Info("Clicked................." + oidc.userInfo["name"]);
                    // validate user here and create session to login.
                }
                else
                {
                    //
                }
            }

            return(oidc.userInfo);
        }