Java Code Examples for me.zhyd.oauth.utils.AuthStateUtils

The following examples show how to use me.zhyd.oauth.utils.AuthStateUtils. These examples are extracted from open source projects. 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 Project: JustAuth   Source File: AuthExtendRequestTest.java    License: 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 Project: FEBS-Cloud   Source File: SocialLoginController.java    License: 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 Project: mogu_blog_v2   Source File: AuthRestApi.java    License: 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 Project: jeecg-cloud   Source File: ThirdLoginController.java    License: 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 Project: jeecg-boot   Source File: ThirdLoginController.java    License: 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 Project: OneBlog   Source File: OAuthController.java    License: 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 Project: cms   Source File: OauthController.java    License: 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 Project: MaxKey   Source File: SocialSignOnEndpoint.java    License: 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 Project: pybbs   Source File: OAuthController.java    License: 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 Project: spring-boot-demo   Source File: OauthController.java    License: 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()));
}