protected void Page_Load(object sender, EventArgs e)
        {
            SSOLoginData ssoLoginData = new SSOLoginData()
            {
            };
            var samlRequestData = SAML2Helper.GetSamlBase64StringToGetToken(ssoLoginData);

            Response.Clear();
            string        postbackUrl = "";
            var           SAMLRequest = "";
            var           RelayState  = "";
            var           id          = "";
            StringBuilder sb          = new StringBuilder();

            sb.Append("<html>");
            sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
            sb.AppendFormat("<form name='form' action='{0}' method='post'>", postbackUrl);
            sb.AppendFormat("<input type='hidden' name='SAMLRequest' value='{0}'>", SAMLRequest);
            sb.AppendFormat("<input type='hidden' name='RelayState' value='{0}'>", RelayState);
            sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", id);
            // Other params go here
            sb.Append("</form>");
            sb.Append("</body>");
            sb.Append("</html>");

            Response.Write(sb.ToString());

            Response.End();
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SSOLoginData ssoLoginData = new SSOLoginData()
            {
                Email           = "*****@*****.**",
                City            = "New York",
                Country         = "US",
                Department      = "IT",
                ErrorUrl        = "https://errorsite.com/errorpage.aspx",
                FirstName       = "John",
                LastName        = "Smith",
                PhoneNumber     = "001354534643",
                GroupMembership = ""
            };
            var samlRequestData = SAML2Helper.GetSamlBase64StringToGetToken(ssoLoginData);

            Response.Clear();
            string        postbackUrl = "https://dev.axco.co.uk/Axco.sso/saml2/v1/signin/community";
            var           RelayState  = "https://dev.axco.co.uk/Axco.sso/saml2/v1/signin/community";
            var           id          = Guid.NewGuid().ToString();
            StringBuilder sb          = new StringBuilder();

            sb.Append("<html>");
            sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
            sb.AppendFormat("<form name='form' action='{0}' method='POST'>", postbackUrl);
            sb.AppendFormat("<input type='hidden' id='SAMLRequest' name='SAMLRequest' value='{0}'>", samlRequestData);
            sb.AppendFormat("<input type='hidden' id='RelayState' name='RelayState' value='{0}'>", RelayState);
            sb.AppendFormat("<input type='hidden' id='id' name='id' value='{0}'>", id);
            // Other params go here
            sb.Append("</form>");
            sb.Append("</body>");
            sb.Append("</html>");

            Response.Write(sb.ToString());

            Response.End();
        }
Exemplo n.º 3
0
        private string GetAuthenticationToken(SSOLoginData ssoLoginData)
        {
            string portalAPIUrl = $"{ConfigurationManager.AppSettings["PortalAPIURL"]}/api/auth/token";

            var samlRequestData = SAML2Helper.GetSamlBase64StringToGetToken(ssoLoginData);

            var client   = new HttpClient();
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("grant_type", "password"),
                // new KeyValuePair<string, string>("username", ssoLoginData.GlobalUserId.ToString()),
                new KeyValuePair <string, string>("password", samlRequestData),
                new KeyValuePair <string, string>("scope", "ssorequest")
            };

            var response = client.PostAsync(portalAPIUrl, new FormUrlEncodedContent(postData)).Result;

            if (!response.IsSuccessStatusCode)
            {
                return(null);
            }

            return(response.Content.ReadAsStringAsync().Result);
        }
Exemplo n.º 4
0
        protected void btnTestSSO_Click(object sender, EventArgs e)
        {
            SSOLoginData ssoLoginData = new SSOLoginData()
            {
                Email           = "*****@*****.**",
                UserName        = "******",
                City            = "New York",
                Country         = "US",
                Department      = "IT",
                ErrorUrl        = "https://errorsite.com/errorpage.aspx",
                FirstName       = "John",
                LastName        = "Smith",
                PhoneNumber     = "001354534643",
                GroupMembership = "InsightCompliance"
            };
            var SAMLResponse = SAML2Helper.GetSamlBase64StringToGetToken(ssoLoginData);

            Response.Clear();
            string postbackUrl = "https://dev.axco.co.uk/Axco.sso/saml2/v1/signin/AssurexGlobal";

            var           RelayState = "";
            StringBuilder sb         = new StringBuilder();

            sb.Append("<html>");
            sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
            sb.AppendFormat("<form name='form' action='{0}' method='POST'>", postbackUrl);
            sb.AppendFormat("<input type='hidden' id='SAMLResponse' name='SAMLResponse' value='{0}'>", SAMLResponse);
            sb.AppendFormat("<input type='hidden' id='RelayState' name='RelayState' value='{0}'>", RelayState);
            sb.Append("</form>");
            sb.Append("</body>");
            sb.Append("</html>");

            Response.Write(sb.ToString());

            Response.End();
        }