JWT token for multiple websites

て烟熏妆下的殇ゞ 提交于 2020-01-02 01:00:09

问题


How can I have a single JWT token be shared among multiple websites. I assume that the first thing would be to have the same secret on all websites.

If user logs in on site A and a token is generated I want to use the same token for website B on a totally diferent domain.

Can it be done?


回答1:


What you want can be done, but not with a single JWT token. A JWT token is intended for a certain service or application indicated by the audience (aud) claim. You cannot use the same token for another application or service.

What typically happens to make your SSO scenario work, it that the user logs in to the token issuing (authorization) server. As long as that session is valid, the user can acquire tokens for all applications the server can issue tokens for.

So, when the user logs in to the first application, the authorization server sets a cookie to establish a session. When the user navigates to the second application, the application redirects him/her to the authorization server for authentication. The authorization detects the session cookie and does not prompt to user to log in again, but issues a new JWT token for the second application.



来源:https://stackoverflow.com/questions/35423800/jwt-token-for-multiple-websites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!