ComponentSpace

Forums



Adding in .add authentication


Adding in .add authentication

Author
Message
akanksha10
akanksha10
New Member
New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)New Member (20 reputation)

Group: Forum Members
Posts: 16, Visits: 68
Hi Team,
I am using idp initiated SSO , where idp is .net application and SP is .net core applicatio through normal web api calls and not middleware.
In my .net core SP, i already have wesfederation in services.AddAuthentication . How can I add SAML there?
Also, how can I increase the expiry time of cookie in that. I want to set that to 12h
Code looks like this ;
services.AddAuthentication(sharedOptions =>
    {
      sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
    })
       .AddWsFederation(options =>
    {
      options.Wtrealm = Configuration.GetSection("SSOSettings").Value;
      options.MetadataAddress = Configuration.GetSection("SSOSettings:Metadata").Value;
      options.SkipUnrecognizedRequests = true;
      options.RequireHttpsMetadata = false;
    })
    .AddCookie();

Thanks
Akanksha
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)ComponentSpace Development (4K reputation)

Group: Administrators
Posts: 2.9K, Visits: 9.6K
Hi Akanksha,

We support two approaches for adding SAML SSO support to your application. The first is to call the SAML API from your application. Alternatively, you can add the SAML middleware to handle SSO rather than calling the SAML API. Calling the SAML API provides you with a little more control. Using the SAML middleware means a little less code has to be written.

The ExampleServiceProvider and MiddlewareServiceProvider projects under the Examples\SSO folder demonstrate the two approaches.

Please refer to these projects for code examples. Also, the Examples Guide in the documentation folder walks you through these examples.

Briefly though, here's an example of the start-up code when using the API approach.


// Add SAML SSO services.
services.AddSaml(Configuration.GetSection("SAML"));

 

And here's an example of the start-up code when using the middleware approach.


// Add SAML SSO services.
services.AddSaml(Configuration.GetSection("SAML"));

// Add SAML authentication services.
services.AddAuthentication().AddSaml(options =>
{
  options.PartnerName = (httpContext) => Configuration["PartnerName"];
});

 

Which cookie are you referring to? Do you mean the authentication cookie?

Assuming so, please refer to:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.cookies.cookieauthenticationoptions?view=aspnetcore-6.0


Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 3 queries. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....









Forums, Documentation & Knowledge Base - ComponentSpace


Search