public void ProcessRequest(HttpContextBase context)
        {
            try
            {
                string d = context.Request.QueryString["d"];
                int additionalChars;
                int.TryParse(d, out additionalChars);
                var msg = new SqrlMessage
                    {
                        SignatureBase64 = UrlSafeBase64Encoder.Decode(context.Request.Form["sqrlsig"]),
                        PublicKeyBase64 = UrlSafeBase64Encoder.Decode(context.Request.QueryString["sqrlkey"]),
                        ServerNonce = context.Request.QueryString["nut"],
                        Version = context.Request.QueryString["sqrlver"],
                        Options = context.Request.QueryString["sqrlopt"],
                        AdditionalDomainCharacters = additionalChars,
                        Uri = GetAdjustedUrl(context),
                        IpAddress = context.Request.GetClientIpAddress()
                    };

                var validator = new MessageValidator();
                validator.Validate(msg);

                context.Response.StatusCode = (int) HttpStatusCode.OK;
            }
            catch (SqrlAuthenticationException ex)
            {
                context.Response.StatusCode = (int) HttpStatusCode.Forbidden;
                context.Response.StatusDescription = ex.Message;
            }

            context.Response.End();
        }
Exemple #2
0
        public void ProcessRequest(HttpContextBase context)
        {
            try
            {
                string d = context.Request.QueryString["d"];
                int    additionalChars;
                int.TryParse(d, out additionalChars);
                var msg = new SqrlMessage
                {
                    SignatureBase64            = UrlSafeBase64Encoder.Decode(context.Request.Form["sqrlsig"]),
                    PublicKeyBase64            = UrlSafeBase64Encoder.Decode(context.Request.QueryString["sqrlkey"]),
                    ServerNonce                = context.Request.QueryString["nut"],
                    Version                    = context.Request.QueryString["sqrlver"],
                    Options                    = context.Request.QueryString["sqrlopt"],
                    AdditionalDomainCharacters = additionalChars,
                    Uri       = GetAdjustedUrl(context),
                    IpAddress = context.Request.GetClientIpAddress()
                };

                var validator = new MessageValidator();
                validator.Validate(msg);

                context.Response.StatusCode = (int)HttpStatusCode.OK;
            }
            catch (SqrlAuthenticationException ex)
            {
                context.Response.StatusCode        = (int)HttpStatusCode.Forbidden;
                context.Response.StatusDescription = ex.Message;
            }

            context.Response.End();
        }
        private void SetSqrlUrl()
        {
            Session["SQRL"] = true;
            var sqrl = new MessageValidator();
            string sqrlSessionId = sqrl.CreateSession();
            string ip = GetClientIp();
            string path = string.Format(
                "{0}://{1}/sqrl.axd?nut={2}", IsSecureConnection() ? "sqrl" : "qrl",
                Request.Url.Authority, sqrlSessionId);

            ViewBag.SqrlUrl = path;
            ViewBag.SqrlId = sqrlSessionId;
        }