Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create SAML Authentication request using WIF

It seems most of the WIF information out there is useful for enabling federated authentication across entire applications. I'm interested in using the API to create SAML authentication requests and receive/interpret the SAML responses.

I found the following post on SO Reading SAML Attributes from SAML Token that gets me going in the right direction in regards to receiving and interpreting SAML responses. Can anyone give me more information on how I might use the API to create SAML requests?

Any more info (reading material, videos, etc) on the API in general would be greatly appreciated.

like image 339
hackerhasid Avatar asked Feb 02 '11 17:02

hackerhasid


People also ask

Is SAML the same as SSO?

SAML enables Single-Sign On (SSO), a term that means users can log in once, and those same credentials can be reused to log into other service providers.

How do I create a SAML connection in Auth0?

Create SAML Enterprise connection in Auth0. Go to Dashboard > Authentication > Enterprise, and select SAML. Select Create Connection.

Does SAML use HTTP?

HTTPS is required by default to configure SAML. As the SAML protocol is browser based both the product and the Identity Provider must use HTTPS (rather than HTTP), to prevent man-in-the-middle attacks and capturing XML documents with SAML assertions.


1 Answers

Here's a little example form one of our samples that shows how to programatically create a request for a (SAML) Security Token to an STS:

private static SecurityToken GetSamlToken(string realm, string stsEndpoint, ClientCredentials clientCredentials)
    {
        using (var factory = new WSTrustChannelFactory(
            new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), 
            new EndpointAddress(new Uri(stsEndpoint))))
        {
            factory.Credentials.UserName.UserName = clientCredentials.UserName.UserName;
            factory.Credentials.UserName.Password = clientCredentials.UserName.Password;
            factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            factory.TrustVersion = TrustVersion.WSTrust13;

            WSTrustChannel channel = null;

            try
            {
                var rst = new RequestSecurityToken
                              {
                                  RequestType = WSTrust13Constants.RequestTypes.Issue, 
                                  AppliesTo = new EndpointAddress(realm), 
                                  KeyType = KeyTypes.Bearer, 
                              };

                channel = (WSTrustChannel)factory.CreateChannel();

                return channel.Issue(rst);
            }
            finally
            {
                if (channel != null)
                {
                    channel.Abort();
                }

                factory.Abort();
            }
        }
like image 147
Eugenio Pace Avatar answered Oct 06 '22 00:10

Eugenio Pace