简体   繁体   English

我想限制用户通过API访问其他用户的数据

[英]I want to restrict a user to access data of other users through API

I have implemented token based authentication and authorization. 我已经实现了基于令牌的身份验证和授权。 I am storing the value of token in session. 我在会话中存储令牌的值。 How to restrict a user to access the data of other users if user gets the token. 如果用户获得令牌,如何限制用户访问其他用户的数据。 I am passing token only in header. 我仅在标头中传递令牌。 So if user is able to get the token value anyhow so he can access any API for any user. 因此,如果用户能够以任何方式获取令牌值,那么他可以为任何用户访问任何API。 I am calling apis in jQuery. 我在jQuery中调用API。

First of all, why do you save the value of the token in a session? 首先,为什么要在会话中保存令牌的值? That doesn't make sense, since your authorization becomes session dependent, not token dependent. 这没有任何意义,因为您的授权取决于会话,而不取决于令牌。 If you exchange password and username for token, don't use sessions as the token becomes redundant - you are authorizing the user through your session cookie. 如果您将密码和用户名交换为令牌,请不要使用会话,因为令牌会变得多余-您正在通过会话cookie授权用户。

Also, this is the idea of the token - to be working just for an hour (most services use this amount of time for the token life). 同样,这就是令牌的想法-仅工作一个小时(大多数服务在令牌寿命中使用此时间量)。 So if you are not implementing an OAuth authentication strategy, why use tokens in the first place? 因此,如果您未实施OAuth身份验证策略,为什么首先要使用令牌? And if you do, why use sessions? 如果这样做,为什么要使用会话? I think you are mixing different approaches here. 我认为您在这里混合使用不同的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 限制用户访问其他用户配置文件 - restrict users from accessing other user profiles Firebase 在没有用户登录的情况下限制对其他页面的访问 - Firebase Restrict Access to other pages without user logged in 我想在用户关闭浏览器选项卡时将数据发布到 API - I want to POST data to an API when user close the browser tab 在我的用户数据上存储其他用户数据 - Storing other user data on my users data 我想在用户登录时限制页面路由 - I want to restrict the page routing when user is logged in 用户能否在我的 firebase 代码中更新控制台中的脚本并访问其他用户的数据? - Can a user update the script in a console and access other users' data in my firebase code? 限制对经过身份验证的用户的访问 - Restrict access to the authentified user 我想通过 JavaScript 将数据从一个 html 页面传输到另一个页面? - I want to transfer data from one html page to other through JavaScript? 我有一个贯穿数组的 API,我想在每个数组元素上向客户端发送数据 - I have an API that runs through an array and I want to send data to the client on each array element 如何通过SDK(Buildfire)访问应用程序所有用户的数据 - How do I access data of all of the users of an app through the SDK (Buildfire)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM