Skip to content

egov-moldova/AGE.AspNetCore.MPass.Saml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

MPass SAML Authentication

This package is intended for Service Provider integration built on ASP.NET Core 2.0+ with MPass using SAML v2.0 protocol and format for authentication.

Getting Started

Please go through the following instructions to integrate your project with MPass.

Prerequisites

Before being able to integrate with MPass, a Service Provider, including its certificate, must be registered accordingly in MPass. MPass accepts certificates issued by STISC.

Installing

Install the following package from NuGet

Install-Package AGE.AspNetCore.MPass.Saml

Then follow the instructions from Configuration and Usage sections below.

Configuration

Add the following configuration section to your appsettings.json:

{
	...
	"MPassSamlOptions": {
		"SamlRequestIssuer": "https://sampleservice.md",
		"ServiceCertificatePath": "Files\\Certificates\\sampleservice.md.pfx",
		"ServiceCertificatePassword": "yourpfxpassword",
		"IdentityProviderCertificatePath": "Files\\Certificates\\testmpass.gov.md.cer",
		"SamlMessageTimeout": "00:10:00",
		"SamlLoginDestination": "https://testmpass.gov.md/login/saml",
		"SamlLogoutDestination": "https://testmpass.gov.md/logout/saml",
		"ServiceRootUrl": "https://localhost:5000"
	}
	...
}

where ServiceRootUrl is the base path of your published service.

Please note that your Service must be published using https protocol.

Usage

Add the following code snippet to your Startup.ConfigureServices method:

services.Configure<MPassSamlOptions>(MPassSamlDefaults.AuthenticationScheme, Configuration.GetSection("MPassSamlOptions"));

services.AddAuthentication(sharedOptions =>
{
	sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
	sharedOptions.DefaultChallengeScheme = MPassSamlDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
	options.Cookie.Name = "auth";
	options.Cookie.SameSite = SameSiteMode.None;
})
.AddMPassSaml();

In your Startup.Configure add the Authentication Middleware.

app.UseAuthentication();

Releases

No releases published

Packages

No packages published

Languages