当前位置:   article > 正文

Springboot整合第三方登录功能_bladesocialendpoint

bladesocialendpoint

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

/**

  • 第三方登陆端点

  • @author tarzan

*/

@Slf4j

@RestController

@AllArgsConstructor

@RequestMapping(“auth”)

@ConditionalOnProperty(value = “social.enabled”, havingValue = “true”)

@Api(value = “第三方登陆”, tags = “第三方登陆端点”)

public class BladeSocialEndpoint {

private final SocialProperties socialProperties;

/**

  • 授权完毕跳转

*/

@ApiOperation(value = “授权完毕跳转(RequestMapping)”)

@RequestMapping(“/oauth/render/{source}”)

public void renderAuth(@PathVariable(“source”) String source, HttpServletResponse response) throws IOException {

AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties);

String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());

response.sendRedirect(authorizeUrl);

}

/**

  • 获取认证信息

*/

@ApiOperation(value = “获取认证信息(RequestMapping)”)

@RequestMapping(“/oauth/callback/{source}”)

public Object login(@PathVariable(“source”) String source, AuthCallback callback) {

AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties);

return authRequest.login(callback);

}

/**

  • 撤销授权

*/

@ApiOperation(value = “撤销授权(RequestMapping)”)

@RequestMapping(“/oauth/revoke/{source}/{token}”)

public Object revokeAuth(@PathVariable(“source”) String source, @PathVariable(“token”) Str

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/727346
推荐阅读
相关标签
  

闽ICP备14008679号