duanlao1552 2016-02-25 22:17
浏览 33

令牌认证商店 - php

im trying to build a rest api using php(silex) and angularjs. I have problem with backend becouse it's not my good side, im front-end dev so angular is easy and understandable for me but unlike php. I dont have idea to good security my token auth. I thought about jwt-php, but this not solve my problem becouse i dont know where i should store my jwt token. In cookies, session or db? Or where?

I thought about db, but it's making next problem. Namely, when pass and login are correct send to table(tokens) our generate jwt token and id user. And every request from angular http interceptor. and before every request i should check header token and db token with id user to auth. If correct, let's next, else 401 header. It's my idea for this.

But I should store global id logged user to identify with token (so where, cookies?) But when we close the browser this token what we passed it still in db, its my second question, what i should do.

What are the best practies to store,use tokens? I understand tokens from client, but i dont know what i should do with backend.

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?