1
0
mirror of synced 2025-12-13 17:57:59 +08:00
Yangkai.Shen ee2b8e6c7a 提供Oauth列表
2019-08-02 18:31:19 +08:00
2019-08-02 18:31:19 +08:00
2019-07-22 15:23:07 +08:00
2019-07-23 14:30:28 +08:00
2019-08-01 16:16:18 +08:00
2019-08-02 15:03:09 +08:00
2019-08-01 16:16:18 +08:00

justauth-spring-boot-starter

Spring Boot 集成 JustAuth 的最佳实践~

JustAuth 脚手架

Maven Central Travis (.com) GitHub

Demo

懒得看文档的可以直接看demo

https://github.com/xkcoding/justauth-spring-boot-starter-demo

快速开始

  • 引用依赖
<dependency>
  <groupId>com.xkcoding</groupId>
  <artifactId>justauth-spring-boot-starter</artifactId>
  <version>0.0.2</version>
</dependency>
  • 添加配置,在 application.yml 中添加配置配置信息
justauth:
  enabled: true
  type:
    QQ:
      client-id: 10**********6
      client-secret: 1f7d08**********5b7**********29e
      redirect-uri: http://oauth.xkcoding.com/demo/oauth/qq/callback
  • 然后就开始玩耍吧~
@Slf4j
@RestController
@RequestMapping("/oauth")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TestController {
    private final AuthRequestFactory factory;

    @GetMapping("/login/qq")
    public void login(HttpServletResponse response) throws IOException {
        AuthRequest authRequest = factory.get(AuthSource.QQ);
        response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
    }

    @RequestMapping("/qq/callback")
    public AuthResponse login(AuthCallback callback) {
        AuthRequest authRequest2 = factory.get(AuthSource.QQ);
        AuthResponse response = authRequest2.login(callback);
        log.info("【response】= {}", JSONUtil.toJsonStr(response));
        return response;
    }
}

附录

justauth 配置列表

属性名 类型 默认值 可选项 描述
justauth.enabled boolean true true/false 是否启用 JustAuth
justauth.type java.util.Map<me.zhyd.oauth.config.AuthSource,me.zhyd.oauth.config.AuthConfig> JustAuth 配置

justauth.type 配置列表

属性名 描述
justauth.type.keys justauth.typeMap 格式的key 的取值请参考 AuthSource
justauth.type.keys.values justauth.typeMap 格式的value 的取值请参考 AuthConfig
Description
Spring Boot 集成 JustAuth 的最佳实践~
Readme 185 KiB
Languages
Java 100%