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

WS-Fedaration with ADFS

$
0
0

Have used Microsoft.AspNetCore.Authentication.WsFedaration in ASP.NET core signon page is coming however "User.Identity.IsAuthenticated" is always showing false even after signin with ADFS. Here are the steps:

  1. Created ASP.NET Core MVC webapplication.
  2. Configured WREALM in ADFS.
  3. referred Microsoft.AspNetCore.Authentication.WsFedaration  library in the project
  4. Created Account Controller with login Logout, where Login action method would challenge for sign in
    1. return Challenge(
      new AuthenticationProperties { RedirectUri = redirectUrl },
      WsFederationDefaults.AuthenticationScheme);
  5. Startup code below 

    public void ConfigureServices(IServiceCollection services)
    {

    services.AddAuthentication(sharedOptions =>
    {
    sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
    })
    .AddWsFederation(options =>
    {
    // this is where your AppID URI goes

    options.Wtrealm = "http://XYZ-DevLocal";

    options.MetadataAddress = "https://signon.XYZ.net/federationmetadata/2007-06/federationmetadata.xml";


    })
    .AddCookie();

    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {

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

    app.UseHttpsRedirection();
    app.UseAuthentication();
    app.UseStaticFiles();
    app.UseCookiePolicy();

    app.UsePathBase("/OneEnrollment").UseMvc(routes =>
    //app.UseMvc(routes =>
    {
    routes.MapRoute(
    name: "default",
    template: "{controller=Home}/{action=Index}/{id?}");
    // template: "{controller=Account}/{action=Login}");
    });

    }


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>