me.zhyd.oauth.utils.AuthStateUtils Java Examples

The following examples show how to use me.zhyd.oauth.utils.AuthStateUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthExtendRequestTest.java    From JustAuth with MIT License 6 votes vote down vote up
@Test
public void login() {
    AuthRequest request = new AuthExtendRequest(AuthConfig.builder()
        .clientId("clientId")
        .clientSecret("clientSecret")
        .redirectUri("http://redirectUri")
        .build());

    String state = AuthStateUtils.createState();
    request.authorize(state);
    AuthCallback callback = AuthCallback.builder()
        .code("code")
        .state(state)
        .build();
    AuthResponse response = request.login(callback);
    Assert.assertNotNull(response);

    AuthUser user = (AuthUser) response.getData();
    Assert.assertNotNull(user);
    System.out.println(JSON.toJSONString(user));
}
 
Example #2
Source File: SocialLoginController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 登录
 *
 * @param oauthType 第三方登录类型
 * @param response  response
 */
@ResponseBody
@GetMapping("/login/{oauthType}/{type}")
public void renderAuth(@PathVariable String oauthType, @PathVariable String type, HttpServletResponse response) throws IOException, FebsException {
    AuthRequest authRequest = socialLoginService.renderAuth(oauthType);
    response.sendRedirect(authRequest.authorize(oauthType + StringConstant.DOUBLE_COLON + AuthStateUtils.createState()) + "::" + type);
}
 
Example #3
Source File: AuthRestApi.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "获取认证", notes = "获取认证")
@RequestMapping("/render")
public String renderAuth(String source, HttpServletResponse response) throws IOException {
    log.info("进入render:" + source);
    AuthRequest authRequest = getAuthRequest(source);
    String token = AuthStateUtils.createState();
    String authorizeUrl = authRequest.authorize(token);
    Map<String, String> map = new HashMap<>();
    map.put(SQLConf.URL, authorizeUrl);
    return ResultUtil.result(SysConf.SUCCESS, map);
}
 
Example #4
Source File: ThirdLoginController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/render/{source}")
public void render(@PathVariable("source") String source, HttpServletResponse response) throws IOException {
    log.info("第三方登录进入render:" + source);
    AuthRequest authRequest = factory.get(source);
    String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
    log.info("第三方登录认证地址:" + authorizeUrl);
    response.sendRedirect(authorizeUrl);
}
 
Example #5
Source File: ThirdLoginController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/render/{source}")
public void render(@PathVariable("source") String source, HttpServletResponse response) throws IOException {
    log.info("第三方登录进入render:" + source);
    AuthRequest authRequest = factory.get(source);
    String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
    log.info("第三方登录认证地址:" + authorizeUrl);
    response.sendRedirect(authorizeUrl);
}
 
Example #6
Source File: OAuthController.java    From OneBlog with GNU General Public License v3.0 4 votes vote down vote up
@RequestMapping("/render/{source}")
public void renderAuth(@PathVariable("source") String source, HttpServletResponse response, HttpSession session) throws IOException {
    AuthRequest authRequest = RequestFactory.getInstance(source).getRequest();
    session.setAttribute("historyUrl", RequestUtil.getReferer());
    response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
}
 
Example #7
Source File: OauthController.java    From cms with Apache License 2.0 4 votes vote down vote up
@GetMapping("/{type}/login")
public void login(@PathVariable String type, String redirect, HttpServletResponse response) throws IOException {
    AuthRequest authRequest = factory.get(type);
    response.sendRedirect(authRequest.authorize(AuthStateUtils.createState()));
}
 
Example #8
Source File: SocialSignOnEndpoint.java    From MaxKey with Apache License 2.0 4 votes vote down vote up
public  ModelAndView socialSignOnAuthorize(String provider){
  	_logger.debug("SocialSignOn provider : "+provider);
  	String authorizationUrl=buildAuthRequest(provider).authorize(AuthStateUtils.createState());
_logger.debug("authorize SocialSignOn : "+authorizationUrl);
return WebContext.redirect(authorizationUrl);
  }
 
Example #9
Source File: OAuthController.java    From pybbs with GNU Affero General Public License v3.0 3 votes vote down vote up
@GetMapping("/redirect/{type}")
public String github(@PathVariable("type") String type, HttpSession session) {

    AuthRequest request = socialPlugin.getRequest(type);

    return redirect(request.authorize(AuthStateUtils.createState()));
}
 
Example #10
Source File: OauthController.java    From spring-boot-demo with MIT License 2 votes vote down vote up
/**
 * 登录
 *
 * @param oauthType 第三方登录类型
 * @param response  response
 * @throws IOException
 */
@RequestMapping("/login/{oauthType}")
public void renderAuth(@PathVariable String oauthType, HttpServletResponse response) throws IOException {
    AuthRequest authRequest = factory.get(getAuthSource(oauthType));
    response.sendRedirect(authRequest.authorize(oauthType + "::" + AuthStateUtils.createState()));
}