예제 #1
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();
        }
예제 #2
0
        private string GenerateSessionId()
        {
            var nonceBytes = Sodium.Random.GetBytes(SqrlConfig.NonceLength);

            return(UrlSafeBase64Encoder.Encode(Convert.ToBase64String(nonceBytes)));
        }