duanjiaopi8218 2010-07-27 21:40
浏览 89
已采纳

使用Twitter oAuth安全登录 - 最佳实践

I am new to oAuth and looking to build a web application using Twitter (oAuth) to authenticate. There will be no other login method other than via Twitters oAuth. I am looking for advise on best practice to secure the site based on tokens. Here is my plan:

  • User is taken from my site to authenticate via Twitters site
  • Generate Access token for user
  • Get the users unique Twitter id via Twitter API
  • Do a user lookup in local db with this id and locate access token if available.
  • If no user, create new row in user table and save against the user. If user found, update access token agains the user record.
  • If the user is found, md5_salt the twitterid and set as a cookie.
  • If the user re-visits, lookup user based on cookie

Does that sound like a secure approach or is using the md5 twitter id a bad idea?

Appreciate any comments.

  • 写回答

1条回答 默认 最新

  • dongti7838 2010-08-05 18:30
    关注

    Without knowing exactly what your client/consumer application is doing, it is hard to tell whether this approach will be "secure".

    One problem I see, is that once you have an access token from twitter, how do you identify your user if the cookie gets deleted? Or would you require them to get a new access token? This would mean that they would have to both login, and authorize your application each time.

    Also, an access token for one user of your app. can be stolen and used by another user of your app. since it works just like a password AND you have no authentication on your side to verify your cookie saved access token.

    To answer your question then, I would have to say that using oauth as the only authentication provider, no matter how you do it, is not a best practice.

    In order to be secure both the client (consumer) application, and the server (provider) application, need to verify the identity of your users. The easiest way to do this is with a username and password which are stored in your users head, and not on file somewhere...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行