2

post メソッドを使用してデータを保護する方法を知りたいですか、それとも十分に安全ですか?!

私は自分のポータルで以下を使用しています:

 protected Control CreateCommForm(string action)
        {
            HtmlGenericControl frm = new HtmlGenericControl("form");
            frm.Attributes.Add("method", "post");
            frm.Attributes.Add("target", "_blank");
            frm.Attributes.Add("action", action.TrimEnd());
            /////////////////////////////////////////
            HtmlGenericControl hdn_sal_a = new HtmlGenericControl("input");
            hdn_sal_a.Attributes.Add("id", "hdn_give");
            hdn_sal_a.Attributes.Add("name", "hdn_give");
            hdn_sal_a.Attributes.Add("type", "hidden");
            hdn_sal_a.Attributes.Add("value", Session["empnum"].ToString());
            /////////////////////////////////////////
            HtmlGenericControl hdn_sal_b = new HtmlGenericControl("input");
            hdn_sal_b.Attributes.Add("id", "hdn_give_b");
            hdn_sal_b.Attributes.Add("name", "hdn_give_b");
            hdn_sal_b.Attributes.Add("type", "hidden");
            hdn_sal_b.Attributes.Add("value", Session["secret"].ToString());
            /////////////////////////////////////////
            HtmlGenericControl hdn_sal_result = new HtmlGenericControl("input");
            hdn_sal_result.Attributes.Add("id", "hdn_give_rr");
            hdn_sal_result.Attributes.Add("name", "hdn_give_rr");
            hdn_sal_result.Attributes.Add("type", "hidden");
            hdn_sal_result.Attributes.Add("value", ((99 * int.Parse(Session["secret"].ToString())) + 761).ToString());
            /////////////////////////////////////////
            HtmlGenericControl hdn_sal_h = new HtmlGenericControl("input");
            hdn_sal_h.Attributes.Add("id", "hdn_givel_h");
            hdn_sal_h.Attributes.Add("name", "hdn_give_h");
            hdn_sal_h.Attributes.Add("type", "hidden");
            hdn_sal_h.Attributes.Add("value", role_h.Hash((int.Parse(Session["secret"].ToString()) - 55).ToString(), "SHA512", null));
            /////////////////////////////////////////
            frm.Controls.Add(hdn_give);
            frm.Controls.Add(hdn_give_b);
            frm.Controls.Add(hdn_give_rr);
            frm.Controls.Add(hdn_give_h);
            body.Controls.Add(frm);
            return frm;

        }

それで

        Control frm = new Control();
        frm = CreateCommForm(process_url);
        Control crl_data = FormContent(block_type, block_id, frm);
        PlaceHolder1.Controls.Add(crl_data);

そして、そのポータルから開いた Web サイトでこれらの値を次のようにチェックします。

var hr = HttpContext.Current.Request.UrlReferrer;
if (hr != null && !string.IsNullOrEmpty(hr.AbsolutePath))
    {
        if (Request.UrlReferrer.AbsolutePath.Contains("master_portal"))
        {

            if (Request.Form["hdn_give"] != null && !string.IsNullOrEmpty(Request.Form["hdn_give"].ToString())
               && Request.Form["hdn_give_b"] != null && !string.IsNullOrEmpty(Request.Form["hdn_give_b"].ToString()) &&
               Request.Form["hdn_give_rr"] != null && !string.IsNullOrEmpty(Request.Form["hdn_give_rr"].ToString()) &&
               Request.Form["hdn_give_h"] != null && !string.IsNullOrEmpty(Request.Form["hdn_give_h"].ToString())
               )
            {
              //------
            }

これで十分安全ですか、それとももっと良い方法がありますか?

4

2 に答える 2