Subject: Unable to make Saml Authentication request from Angular
Date: 2020-04-08 08:41:50
Source: unable-make-saml-authentication-request-angular


We have an application built using Angular as the front end and C# REst API as the backend.

Trying to send a SAML Authentication Request for SP Initiated SSO but it is not working.

This is the API code:
            AuthnRequest authnRequest = new AuthnRequest();
            authnRequest.Destination = strIDPURL;
            authnRequest.Issuer = new Issuer(Request.RequestUri.AbsoluteUri.ToString());
            authnRequest.ForceAuthn = false;
            authnRequest.NameIdPolicy = new NameIdPolicy(null, null, true);
            authnRequest.ProviderName = strProvider;
            authnRequest.ProtocolBinding = strBinding;
            authnRequest.AssertionConsumerServiceUrl = assertionConsumerServiceUrl;

            CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "");
            // Get the certificate
            X509Certificate2 x509Certificate = (X509Certificate2)SSOConfig.SPCert;
            // Sign the authentication request.
            RSACryptoServiceProvider SigningKey = new RSACryptoServiceProvider();
            authnRequest.Sign(SigningKey, x509Certificate);

            string idpUrl = string.Format("{0}?{1}={2}",strIDPURL,
                "binding", HttpUtility.UrlEncode(strBinding));
            string spResourceUrl = Request.RequestUri.AbsoluteUri.ToString();
            string relayState = Guid.NewGuid().ToString();
            SamlSettings.CacheProvider.Insert(relayState, spResourceUrl, new TimeSpan(1, 0, 0));
            authnRequest.SendHttpPost(HttpContext.Current.Response, idpUrl, relayState);
**Getting the following error on the Angular subscribe method on the Front end.** 

Unexpected token < in JSON at position 0

Your browser does not support JavaScript. Please press the Continue button to proceed.

Please advise


Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index