One of our ASP web apps has a button, that generates a expiring link to a form. We have noticed that anyone with said link can view the form. I am researching a way to have the end-user be checked for authorization when the link is opened up. Ask them for their username/password before they can view the link.
my sub that generates the link:
Protected Sub ButtonLink_Click(sender As Object, e As EventArgs)
Dim strSQL As String = ""
Dim wapguid As String = ""
Dim cmd As New SqlCommand
wapguid = System.Guid.NewGuid().ToString("N")
strSQL = "INSERT INTO [WapCustomerAccess] (wapid, wapguid, expires, generatedBy) values (@wapid, @wapguid, @expires, @generatedBy)"
cmd.CommandType = CommandType.Text
cmd.CommandText = strSQL
cmd.Parameters.AddWithValue("@wapid", WAPID)
cmd.Parameters.AddWithValue("@1", wapguid)
cmd.Parameters.AddWithValue("@generatedBy", Session.Item("UserFullName"))
cmd.Parameters.AddWithValue("@expires", Date.Now.AddDays(31).ToString)
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("cnnCFHSWAP").ConnectionString
Dim con As New SqlConnection(strConnString)
cmd.Connection = con
Try
con.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
Response.Write(ex.Message & "<br />")
Finally
con.Close()
con.Dispose()
End Try
Dim t As New TextBox()
t.Text = "http://wap-test.cfhs.local/secure/waplink.aspx?SSL=true&hash=" & WAPID & "&guid=" & wapguid & "&expires=45&suid=05A2FF&salt=x00FF&enc=true"
t.ID = "txtLink"
t.Width = 800
t.ReadOnly = True
t.BackColor = Drawing.Color.SeaShell
PanelLink.Visible = True
PanelLink.Controls.AddAt(0, t)
PanelLink.Controls.Add(New LiteralControl("<br />"))
End Sub