Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How can i use app.UseOpenIdConnectAuthentication?

$
0
0

Hi All Geeks,

I am quite newbie in dotnetcore. currently i am developing .net core project. I got two project MVC Web and another is for web api.

for web application, i can use app.UseCookieAuthentication to authorize website. but how can i authorize for web api.

i dont know how to use app.UseOpenIdConnectAuthentication. do you guys have any example?  Moreover, I didnt use EF.

here is my code for web application:

 public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loadServerLink();

            app.UseCookieAuthentication(options =>
            {

                options.AuthenticationScheme = "Cooker";
                //options.LoginPath = new Microsoft.AspNet.Http.PathString(@"/Account/Login");
                //options.AccessDeniedPath = new Microsoft.AspNet.Http.PathString(@"/Account/Login");

                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = true;

                options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
                options.SlidingExpiration = true;

                options.LoginPath = new Microsoft.AspNet.Http.PathString("/Account/Login");
                options.LogoutPath = new Microsoft.AspNet.Http.PathString("/Account/Logout");
                options.AccessDeniedPath = new Microsoft.AspNet.Http.PathString("/Account/AccessDenied");


                //options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                //options.CookieSecure = CookieSecureOption.SameAsRequest;
                //options.CookieHttpOnly = true;

            });

            app.UseIISPlatformHandler();

            app.UseMvc(ConfigureRoutes);

            app.UseStaticFiles();

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World -----!");
            });
        }

 any help is appriciate.

Best Rgds,

frog


Viewing all articles
Browse latest Browse all 9386

Trending Articles