前端应用程序中的 JWT 身份验证流程?
JWT Authentication Flow in a Front -End Application?
我有一个简单的 CRUD Java Spring-boot REST API
,它连接到 MongoDB
到 save/retrieve 有关用户扑克统计信息的信息。此 API 当前不受 JWT 保护。
API如下图:
GET - /users/{userId}/games : gets all games relating to a user
GET - /users/{userId}/games/{roundId} : get a specific game relating to a user
POST - /users/{userId}/games/ : create a game
DELETE - /users/{userId}/games/{roundId} : Delete a game
PATCH - /users/{userId}/games/{roundId} : edit a game
我正在为网络应用添加前端,我正在学习JavaScript
但还没有开始学习具体的框架。
我想在开始开发应用程序的前端之前验证下面的 Authorisation/Authentication
流程是 correct/valid?
1. User presses login button on client (e.g express/angular app) - this hits the /login endpoint
2. Auth0 redirects client to /authorise endpoint and displays login page for User
3. Auth0 verifies username and password against DB to check if a valid user
4. If login is successful: Auth0 redirects back to a specific page on the client with a JWT Token
5. Client Application stores the JWT to use in future requests
5. This JWT can then be used to make REST API calls to Java REST API
是的,差不多就这些了,再想想一些事情:
- 获取用户,在客户端显示用户名
- 您如何在客户端存储 JWT 令牌
- 如果你想要社交登录,那就有点棘手了
我会考虑一个客户端框架,将所有这些都融入其中。
我有一个简单的 CRUD Java Spring-boot REST API
,它连接到 MongoDB
到 save/retrieve 有关用户扑克统计信息的信息。此 API 当前不受 JWT 保护。
API如下图:
GET - /users/{userId}/games : gets all games relating to a user
GET - /users/{userId}/games/{roundId} : get a specific game relating to a user
POST - /users/{userId}/games/ : create a game
DELETE - /users/{userId}/games/{roundId} : Delete a game
PATCH - /users/{userId}/games/{roundId} : edit a game
我正在为网络应用添加前端,我正在学习JavaScript
但还没有开始学习具体的框架。
我想在开始开发应用程序的前端之前验证下面的 Authorisation/Authentication
流程是 correct/valid?
1. User presses login button on client (e.g express/angular app) - this hits the /login endpoint
2. Auth0 redirects client to /authorise endpoint and displays login page for User
3. Auth0 verifies username and password against DB to check if a valid user
4. If login is successful: Auth0 redirects back to a specific page on the client with a JWT Token
5. Client Application stores the JWT to use in future requests
5. This JWT can then be used to make REST API calls to Java REST API
是的,差不多就这些了,再想想一些事情:
- 获取用户,在客户端显示用户名
- 您如何在客户端存储 JWT 令牌
- 如果你想要社交登录,那就有点棘手了
我会考虑一个客户端框架,将所有这些都融入其中。