Spring Security OAuth2系列1:oauth2认证授权过程中的所有默认url

Spring Security OAuth2系列1:oauth2认证授权过程中的所有默认url

因为oauth2认证过程中会调用各种各样的endpoints(对应的url)进行认证和授权,虽然这些url可以自定义,但经常会使用框架的默认值。另外,有时是框架内部自动调用,但也可以自己手动调用,为了防止手动调用时还要去找这些默认url,所以在这里做一个记录。

我先假设:
授权服务器(Authorization Server) basePath=http://localhost:8127/
客户(Client) basePath=http://localhost:8082/

1 登录

登录页面:get,http://localhost:8127/login
登录action:post,http://localhost:8127/login

2 授权

get,http://localhost:8127/oauth/authorize?prompt=consent&client_id=user&state=state=p5QxnXgN4o-hsZ0LZAtQYVudAV03hpKGDvsnCb6fsRQ%3D&response_type=code&scope=all&redirect_uri=http://localhost:8082/index.html

注:

  1. 其中client_id,可以设置为 user ,这种有意义的字符串,也可设置为 de91bdadc6b6b3599bebfa8755850fca0844aae44f13cc5e076110e961d4b79e 这种随机字符串,case by case。

  2. prompt 和 state 参数,可以省略。其中state参数起到类似 csrf token 的作用。

3 获取token

post,http://localhost:8127/oauth/token
body的json参数:{"code":"a2kf6","client_id":"user","client_secret":"123","redirect_uri":"http://localhost:8082/index.html","grant_type":"authorization_code"}

注:client_secret 可以是 123 这种有意义字符串,也可是 6baa392358c93949b4f5e9e443dfa646746eb40c67ffa3eb87decb408d500b17 这种随机字符串。

4 刷新token

post,http://localhost:8127/oauth/token
body的json参数:{"client_id":"user","client_secret":"123","refresh_token":"asdfasdsfasdfsadda3232","grant_type":"refresh_token"}

posted @ 2022-05-24 08:26  mediocrep  阅读(1104)  评论(0编辑  收藏  举报
既然选择了远方,便只顾风雨兼程!