服务端最主要的一个配置就是使用 @EnableAuthorizationServer
注解,该注解的作用就是引入了一些 OAuth2 相关的端点,包含以下的端点:
-
AuthorizationEndpoint
根据用户认证获得授权码,有下面两个方法:-
/oauth/authorize
- GET -
/oauth/authorize
- POST
-
TokenEndpoint
客户端根据授权码获取 token/oauth/token
- GET/oauth/token
- POST
CheckTokenEndpoint
可以用于远程解码令牌/oauth/check_token
WhitelabelApprovalEndpoint
显示授权服务器的确认页。/oauth/confirm_access
WhitelabelErrorEndpoint
显示授权服务器的错误页/oauth/error
在官方的示例中,通过下面代码直接指定了视图:
registry.addViewController("/oauth/confirm_access").setViewName("authorize");
如果想跳过这个认证确认的过程,设置autoApprove
为true。