ComponentSpace

Forums



Specifying the SAML Configuration Programmatically


Specifying the SAML Configuration Programmatically

Author
Message
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K

For the majority of use cases, maintaining the SAML configuration in the saml.config configuration file is the simplest strategy.

SAML Configuration

However, there may be circumstances where configuration must be stored elsewhere (e.g. in a database).
Rather than defining configuration in the saml.config configuration file, the configuration may be specified programmatically. A good place to do this is in the Global.Application_Start method.
For example, the following code configures the local service provider and one partner identity provider.

 
SAMLConfiguration samlConfiguration = new SAMLConfiguration();

samlConfiguration.ServiceProviderConfiguration = new ServiceProviderConfiguration() {
    Name = "urn:componentspace:ExampleServiceProvider",
    AssertionConsumerServiceUrl = "~/SAML/AssertionConsumerService.aspx",
    LocalCertificateFile = "sp.pfx",
    LocalCertificatePassword = "password"
};

samlConfiguration.AddPartnerIdentityProvider(
    new PartnerIdentityProviderConfiguration() {
        Name = "urn:componentspace:ExampleIdentityProvider",
        SignAuthnRequest = false,
        WantSAMLResponseSigned = true,
        WantAssertionSigned = false,
        WantAssertionEncrypted = false,
        SingleSignOnServiceUrl = "http://localhost/ExampleIdentityProvider/SAML/SSOService.aspx",
        SingleLogoutServiceUrl = "http://localhost/ExampleIdentityProvider/SAML/SLOService.aspx",
        PartnerCertificateFile = "idp.cer"
    });

SAMLController.Configuration = samlConfiguration;

 


 And the following code configures the local identity provider and one partner service provider.

 
SAMLConfiguration samlConfiguration = new SAMLConfiguration();

samlConfiguration.IdentityProviderConfiguration =
    new IdentityProviderConfiguration() {
        Name = "urn:componentspace:ExampleIdentityProvider",
        LocalCertificateFile = "idp.pfx",
        LocalCertificatePassword = "password"
    };

samlConfiguration.AddPartnerServiceProvider(
    new PartnerServiceProviderConfiguration() {
        Name = "urn:componentspace:ExampleServiceProvider",
        WantAuthnRequestSigned = false,
        SignSAMLResponse = true,
        SignAssertion = false,
        EncryptAssertion = false,
        AssertionConsumerServiceUrl = "http://localhost/ExampleServiceProvider/SAML/AssertionConsumerService.aspx",
        SingleLogoutServiceUrl = "http://localhost/ExampleServiceProvider/SAML/SLOService.aspx",
        PartnerCertificateFile = "sp.cer"
    });
 
SAMLController.Configuration = samlConfiguration;




Regards
ComponentSpace Development
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K

Setting the SAMLController.Configuration property sets the current SAML configuration to that specified.
The example code works as-is and you should see the SAML configuration successfully set.
I'm not sure what you mean by calling the configuration.
Once you've specified the configuration, by setting the SAMLController.Configuration property, no further action is required on your part.



Regards
ComponentSpace Development
dave-e
dave-e
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Posts: 2, Visits: 15
I'm creating an admin web page for managing our partner identity provider configurations in the database.  Is there a way to validate these configuration settings in memory?  I see the Validate function under the SAMLConfiguration class but it only accepts a filename.  Is there a method available that would accept an instance of the SAMLConfiguration class?  Or another method that can perform validation on an instance of the PartnerIdentityProviderConfiguration class?

Thank you.


ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
The SAMLConfigurationFile.Validate method validates the specified XML file against the SAML configuration XML schema. If your SAML configuration is stored as XML then this method could be called to validate the XML prior to using it to construct a SAMLConfiguration object etc.
If you've already loaded the SAMLConfiguration and related configuration objects from a database etc (ie not stored as XML) then they should already be validated in the sense that you've programmatically constructed these objects rather than loading them from a file.
You might want to add certain checks to your admin web page. For example, if setting up a partner service provider then an assertion consumer service URL should be supplied. If it isn't then presumably you'd display an error message to the administrator.


Regards
ComponentSpace Development
mmasood
mmasood
New Member
New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)

Group: Awaiting Activation
Posts: 31, Visits: 73
ComponentSpace - Friday, February 21, 2014

For the majority of use cases, maintaining the SAML configuration in the saml.config configuration file is the simplest strategy.

SAML Configuration

However, there may be circumstances where configuration must be stored elsewhere (e.g. in a database).
Rather than defining configuration in the saml.config configuration file, the configuration may be specified programmatically. A good place to do this is in the Global.Application_Start method.
For example, the following code configures the local service provider and one partner identity provider.

 
SAMLConfiguration samlConfiguration = new SAMLConfiguration();

samlConfiguration.ServiceProviderConfiguration = new ServiceProviderConfiguration() {
    Name = "urn:componentspace:ExampleServiceProvider",
    AssertionConsumerServiceUrl = "~/SAML/AssertionConsumerService.aspx",
    LocalCertificateFile = "sp.pfx",
    LocalCertificatePassword = "password"
};

samlConfiguration.AddPartnerIdentityProvider(
    new PartnerIdentityProviderConfiguration() {
        Name = "urn:componentspace:ExampleIdentityProvider",
        SignAuthnRequest = false,
        WantSAMLResponseSigned = true,
        WantAssertionSigned = false,
        WantAssertionEncrypted = false,
        SingleSignOnServiceUrl = "http://localhost/ExampleIdentityProvider/SAML/SSOService.aspx",
        SingleLogoutServiceUrl = "http://localhost/ExampleIdentityProvider/SAML/SLOService.aspx",
        PartnerCertificateFile = "idp.cer"
    });

SAMLController.Configuration = samlConfiguration;

 


 And the following code configures the local identity provider and one partner service provider.

 
SAMLConfiguration samlConfiguration = new SAMLConfiguration();

samlConfiguration.IdentityProviderConfiguration =
    new IdentityProviderConfiguration() {
        Name = "urn:componentspace:ExampleIdentityProvider",
        LocalCertificateFile = "idp.pfx",
        LocalCertificatePassword = "password"
    };

samlConfiguration.AddPartnerServiceProvider(
    new PartnerServiceProviderConfiguration() {
        Name = "urn:componentspace:ExampleServiceProvider",
        WantAuthnRequestSigned = false,
        SignSAMLResponse = true,
        SignAssertion = false,
        EncryptAssertion = false,
        AssertionConsumerServiceUrl = "http://localhost/ExampleServiceProvider/SAML/AssertionConsumerService.aspx",
        SingleLogoutServiceUrl = "http://localhost/ExampleServiceProvider/SAML/SLOService.aspx",
        PartnerCertificateFile = "sp.cer"
    });
 
SAMLController.Configuration = samlConfiguration;



Hi,

I am creating configuration using above code and I am getting SAMLController does not exist.
Which library does it exists?

Thanks,
Muhammad Masood
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
Hi Muhammad
The SAMLController class is in the ComponentSpace.SAML2 namespace.
If you still don't see it, it's possible you're using an older version of the DLL.
You can determine the version you have as follows:
http://www.componentspace.com/Forums/31/Determining-the-Component-Version-and-License
If there's still an issue, email us at support mentioning the DLL version you are using and your forum post.

Regards
ComponentSpace Development
mmasood
mmasood
New Member
New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)

Group: Awaiting Activation
Posts: 31, Visits: 73
ComponentSpace - Wednesday, June 15, 2016
Hi Muhammad
The SAMLController class is in the ComponentSpace.SAML2 namespace.
If you still don't see it, it's possible you're using an older version of the DLL.
You can determine the version you have as follows:
http://componentspace.com/Forums/31/Determining-the-Component-Version-and-License 
If there's still an issue, email us at support mentioning the DLL version you are using and your forum post.

Hi,

I am unable to navigate to mentioned page.

Thanks,
Muhammad Masood
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
I missed the www. Please try:
http://www.componentspace.com/Forums/31/Determining-the-Component-Version-and-License


Regards
ComponentSpace Development
mmasood
mmasood
New Member
New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)New Member (39 reputation)

Group: Awaiting Activation
Posts: 31, Visits: 73
ComponentSpace - Wednesday, June 15, 2016

Here is the version I am using:



I am worried if I updated the dll, I might lose the license.

If I could load the configuration for multiple tenant using current dll that would be great.

Thanks,
Muhammad Masood
ComponentSpace
ComponentSpace
ComponentSpace Development
ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)ComponentSpace Development (4.4K reputation)

Group: Administrators
Posts: 3.2K, Visits: 11K
The version you have doesn't include the SAMLController class. This was introduced in a later release.
For the version you have, you'll find similar properties on the SAMLConfiguration class.

Regards
ComponentSpace Development
GO


Similar Topics


Execution: 0.000. 1 query. Compression Enabled.
Login
Existing Account
Email Address:


Password:


Select a Forum....












Forums, Documentation & Knowledge Base - ComponentSpace


Search