核心 POM 配置 WebSecurityConfig 开启 Spring 方法级的安全保护 配置 TokenConfig 来定义 Token 的生成方式 配置 UserDetailsService 和 JdbcClientDetailsService 获取用户和客户端信息自定义客户端表结构 定义 UserDetailsService 的实现类用于查询用户信息 重写 JdbcClientDetailsService 用于查询客户端信息 继承 AuthorizationServerConfigurerAdapter 来实现认证服务器的核心配置 测试端口 获取 code:Get /oauth/authorize?client_id=c1&response_type=code&scope=all&redirect_uri=http://www.baidu.com 简化模式获取 token:Get /oauth/authorize?response_type=token&client_id=c1&redirect_uri=http://www.baidu.com 密码模式获取 token:Post /oauth/token grant_type:password username:用户名 password:密码 Authorization:Basic YzI6NDU2 — 请求头添加客户端信息 授权码模式获取 token:Post /oauth/token grant_type:authorization_code code:获取到的 code redirect_uri:重定向url Authorization:Basic YzI6NDU2 — 请求头添加客户端信息 刷新 token:Post /oauth/token grant_type:refresh_token refresh_token:拿到获取token时得到的refresh_token Authorization:Basic YzI6NDU2 — 请求头添加客户端信息
|