Springboot整合第三方登录功能

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”) String toke

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值