This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 用。NET做网站的时候, 比如看用户的信息, URL就会类似 localhost/web/userdetails.aspx?userid = 1, 如果用户自己把URL改成USERID=2, 就会看到别人的信息, 怎样用技术手段防止或者是探测URL的人工改动呢?thanks
-ningxin0809(雁影行洲);
2005-3-5
(#2159967@0)
-
第一,不要用这么明显的url; 第二,在页的开头要有个验证过程,比如,登陆名是否和看得一致?如果不一致,是否有权限(比如管理员)等等。
-luoboyang(萝卜秧);
2005-3-5
(#2159975@0)
-
多谢, 看来数据库认证逃不掉了。
-ningxin0809(雁影行洲);
2005-3-5
(#2159978@0)
-
不一定是数据库。可以用session
-luoboyang(萝卜秧);
2005-3-5
(#2159994@0)
-
是, 但是有个界面比较麻烦
-ningxin0809(雁影行洲);
2005-3-5
(#2159997@0)
-
在HTTP response返回 Status code 401和必要的要求用户输入用户名/密码信息就可以了。
-tzm_oasis(绿洲);
2005-3-5
{768}
(#2160022@0)
-
没看懂的说, 有相关的连接吗?
-ningxin0809(雁影行洲);
2005-3-5
(#2160027@0)
-
这是一个authorization的例子,第一部分是http request, 而后是response.
-tzm_oasis(绿洲);
2005-3-5
{586}
(#2160034@0)
-
这个程序是方式未经授权的拥护访问相关页面, 我的CASE是用户已经成功LOG IN了, 忽然自己想改URL,然后再PRESS GO或者REFRESH, 这样就可以看到别的用户的信息了。 这个程序好象不适用? 或者我没理解对?
-ningxin0809(雁影行洲);
2005-3-5
(#2160038@0)
-
well, in this special page , u'd better compare his login id in the session with the user id
-expertune(伪劣);
2005-3-5
(#2160048@0)
-
4242, 加上还有别的信息, 我必须写个四到破塞着了
-ningxin0809(雁影行洲);
2005-3-5
(#2160050@0)
-
你需要使用cookie一种cookie是session id的cookie, 用户登录后,http server 把这个session id给用户,以后当用户再访问任何页面,都要带着这个cookie,否则就拒绝访问。这就是萝卜秧说的session control.
一种简单一些的方法就是要求用户每次访问你的页面都要把用户名/密码放在cookie里面传给server。server 每次都去验证,没有或不对就返回401。
-tzm_oasis(绿洲);
2005-3-5
{307}
(#2160063@0)
-
cookie =/= session
-xanada(㊣流水);
2005-3-5
(#2160079@0)
-
同意,我举的例子一个是用cookie控制session,一个是用cookie不用session。其实也可以有不用cookie控制的session. 个人经验觉得用cookie一般编程简单。
-tzm_oasis(绿洲);
2005-3-5
(#2160471@0)
-
没办法用session的时候才用Cookie, Cookie的值存放在用户方,用户可以随便修改。session变量一般是存放在server的。Cookie适合存放用户的访问次数,用户界面配置之类的无关紧要的东西。
-canadiantire(轮胎-M.I.N.K.);
2005-3-5
(#2160162@0)
-
这个方法对付盗链时候常用。归根结底,还是要用户认证。
-luoboyang(萝卜秧);
2005-3-5
(#2160036@0)
-
create a random stuff, something like GUID
-expertune(伪劣);
2005-3-5
(#2160009@0)
-
替代USERID?
-ningxin0809(雁影行洲);
2005-3-5
(#2160014@0)
-
hoho, yes.
-expertune(伪劣);
2005-3-5
(#2160021@0)
-
有些ID是从DATABASE里直接提取放到DATAGRID上做连接, 所以难点
-ningxin0809(雁影行洲);
2005-3-5
(#2160024@0)
-
I normally generate GUID as user ID. It looks pro...hohoho
-expertune(伪劣);
2005-3-5
(#2160029@0)
-
关键是用了这个加密的ID,也不能保证用户神奇的一小手正好蒙对另一个用户的ID的说。
-ningxin0809(雁影行洲);
2005-3-5
(#2160033@0)
-
If u do not wanna use authentication, risk is there. BTW, if they can 蒙对 GUID, they should be able to 蒙对 username and pwd.
-expertune(伪劣);
2005-3-5
(#2160043@0)
-
那俩俺都在数据库里加密了
-ningxin0809(雁影行洲);
2005-3-5
(#2160047@0)
-
use post instead of get, att server side, only requestform. or when the user first login, store the userid in session and every other page, compare the userid.
-guestagain(guest again);
2005-3-5
(#2160071@0)
-
用POST方法。在SERVER端,不接受用GET方法传的变量。这样要想该URL,就必需应该。htmlfile,更麻烦。而且URL上也看不出来。
-647i(#2153402);(#2323);
2005-3-5
(#2160076@0)
-
同时要检查是从哪里post过来的。
-guestagain(guest again);
2005-3-5
(#2160078@0)
-
POST 变量也是从用户端传来的,所以也不安全。实际上用FireFox就可以轻易的修改POST的值。
-canadiantire(轮胎-M.I.N.K.);
2005-3-5
(#2160148@0)
-
简单啊。把userid放到session变量里面。然后写一小段code,判断当前ie的地址栏里面的id是否相符,然后把这段代码引用到你所有需要保密的页面中
-johnnyhatesjazz(Rock and Roll);
2005-3-5
(#2160098@0)
-
这不是想找个捷径嘛, 这方法正用着那
-ningxin0809(雁影行洲);
2005-3-5
(#2160212@0)
-
其实不光是asp.net, php, jsp,如果用get来传递username的话都会有这个问题,用post也不安全.这些流行的网页语言大都是用session变量来传递user name的,而且不是这样简单地传递username,你应该增加个session变量看这个用户是不是已经通过了密码验证,如果是的话显示,不是的话就不显示.相对来说,.net实现起来最方便
-jeff2ll(jeff);
2005-3-5
{153}
(#2160221@0)
-
这是偷懒啊。你想要做的是Authorization, 可能你还有其他的资源需要检查。Solution: 1. use httpmodule(prefered) 2. Create a base page and check authorization in that page and inheritate from that page.
-oceanwater(灌水日月长);
2005-3-5
(#2160229@0)
-
我这是这样干的。
-guestagain(guest again);
2005-3-5
{572}
(#2160361@0)