Single Sign-On fixed
Single Sign-On fixed
This commit is contained in:
@@ -51,10 +51,10 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
||||
@ApiOperation(value = "ExtendApi认证地址接口", notes = "参数应用ID",httpMethod="GET")
|
||||
@RequestMapping("/authz/api/{id}")
|
||||
public ModelAndView authorize(HttpServletRequest request,@PathVariable("id") String id){
|
||||
|
||||
|
||||
ModelAndView modelAndView=new ModelAndView("authorize/redirect_sso_submit");
|
||||
Apps apps=getApp(id);
|
||||
_logger.debug(""+apps);
|
||||
|
||||
if(Boolean.isTrue(apps.getIsAdapter())){
|
||||
Accounts appUser=getAccounts(apps);
|
||||
|
||||
@@ -62,8 +62,6 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
||||
return generateInitCredentialModelAndView(id,"/authorize/api/"+id);
|
||||
}
|
||||
|
||||
ModelAndView modelAndView=new ModelAndView();
|
||||
|
||||
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(apps.getAdapter());
|
||||
|
||||
apps.setAppUser(appUser);
|
||||
@@ -75,8 +73,9 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
||||
modelAndView);
|
||||
return modelAndView;
|
||||
}else{
|
||||
String redirec_uri=getApp(id).getLoginUrl();
|
||||
return WebContext.redirect(redirec_uri);
|
||||
modelAndView.addObject("redirect_uri", getApp(id).getLoginUrl());
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,19 +19,16 @@ package org.maxkey.authz.exapi.endpoint.adapter;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.maxkey.authn.SigninPrincipal;
|
||||
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
|
||||
import org.maxkey.client.http.HttpVerb;
|
||||
import org.maxkey.client.oauth.OAuthClient;
|
||||
import org.maxkey.client.oauth.model.Token;
|
||||
import org.maxkey.crypto.DigestUtils;
|
||||
import org.maxkey.entity.ExtraAttrs;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.apps.Apps;
|
||||
import org.maxkey.util.HttpsTrusts;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -90,7 +87,7 @@ public class ExtendApiCndnsApiMailAdapter extends AbstractAuthorizeAdapter {
|
||||
|
||||
String tokenMd5 =DigestUtils.md5Hex(details.getCredentials());
|
||||
HashMap<String,String > requestParamenter =new HashMap<String,String >();
|
||||
String redirec_uri = "";
|
||||
String redirect_uri = "";
|
||||
if(action.equalsIgnoreCase("getDomailUrl")) {
|
||||
String sign =DigestUtils.md5Hex
|
||||
(String.format(
|
||||
@@ -102,7 +99,7 @@ public class ExtendApiCndnsApiMailAdapter extends AbstractAuthorizeAdapter {
|
||||
authkeyRestClient.addRestObject(requestParamenter);
|
||||
|
||||
HashMap<String, String> authKey=JsonUtils.gson2Object(authkeyRestClient.execute().getBody(), HashMap.class);
|
||||
redirec_uri=authKey.get("adminUrl");
|
||||
redirect_uri=authKey.get("adminUrl");
|
||||
|
||||
}else {
|
||||
String sign =DigestUtils.md5Hex
|
||||
@@ -115,11 +112,14 @@ public class ExtendApiCndnsApiMailAdapter extends AbstractAuthorizeAdapter {
|
||||
authkeyRestClient.addRestObject(requestParamenter);
|
||||
|
||||
HashMap<String, String> authKey=JsonUtils.gson2Object(authkeyRestClient.execute().getBody(), HashMap.class);
|
||||
redirec_uri=authKey.get("webmailUrl");
|
||||
redirect_uri=authKey.get("webmailUrl");
|
||||
}
|
||||
|
||||
_logger.debug("redirec_uri : "+redirec_uri);
|
||||
return WebContext.redirect(redirec_uri);
|
||||
_logger.debug("redirect_uri : "+redirect_uri);
|
||||
|
||||
modelAndView.addObject("redirect_uri", redirect_uri);
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.maxkey.authz.exapi.endpoint.adapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.maxkey.authn.SigninPrincipal;
|
||||
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
|
||||
import org.maxkey.client.oauth.OAuthClient;
|
||||
@@ -28,7 +27,6 @@ import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.apps.Apps;
|
||||
import org.maxkey.util.HttpsTrusts;
|
||||
import org.maxkey.util.JsonUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -76,9 +74,12 @@ public class ExtendApiQQExmailAdapter extends AbstractAuthorizeAdapter {
|
||||
HashMap<String, String> authKey=JsonUtils.gson2Object(authkeyRestClient.execute().getBody(), HashMap.class);
|
||||
_logger.debug("authKey : "+authKey);
|
||||
|
||||
String redirec_uri=authKey.get("login_url");
|
||||
_logger.debug("redirec_uri : "+redirec_uri);
|
||||
return WebContext.redirect(redirec_uri);
|
||||
String redirect_uri=authKey.get("login_url");
|
||||
_logger.debug("redirect_uri : "+redirect_uri);
|
||||
|
||||
modelAndView.addObject("redirect_uri", redirect_uri);
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.maxkey.crypto.DigestUtils;
|
||||
import org.maxkey.entity.ExtraAttrs;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.apps.Apps;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -83,12 +82,14 @@ public class ExtendApiTimestampSignAdapter extends AbstractAuthorizeAdapter {
|
||||
_logger.debug(""+token);
|
||||
String account = userInfo.getUsername();
|
||||
|
||||
String redirec_uri = String.format(details.getLoginUrl(),account,code,timestamp,token);
|
||||
String redirect_uri = String.format(details.getLoginUrl(),account,code,timestamp,token);
|
||||
|
||||
_logger.debug("redirect_uri : "+redirect_uri);
|
||||
|
||||
_logger.debug("redirec_uri : "+redirec_uri);
|
||||
|
||||
return WebContext.redirect(redirec_uri);
|
||||
modelAndView.addObject("redirect_uri", redirect_uri);
|
||||
|
||||
return modelAndView;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import org.maxkey.crypto.DigestUtils;
|
||||
import org.maxkey.entity.ExtraAttrs;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.apps.Apps;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -72,22 +71,24 @@ public class ExtendApiZentaoAdapter extends AbstractAuthorizeAdapter {
|
||||
_logger.debug(""+token);
|
||||
String account = userInfo.getUsername();
|
||||
|
||||
String redirec_uri = details.getLoginUrl();
|
||||
if(redirec_uri.indexOf("api.php?")<0) {
|
||||
if(redirec_uri.endsWith("/")) {
|
||||
redirec_uri += String.format(login_url_template,account,code,time,token);
|
||||
String redirect_uri = details.getLoginUrl();
|
||||
if(redirect_uri.indexOf("api.php?")<0) {
|
||||
if(redirect_uri.endsWith("/")) {
|
||||
redirect_uri += String.format(login_url_template,account,code,time,token);
|
||||
}else {
|
||||
redirec_uri +="/" + String.format(login_url_template,account,code,time,token);
|
||||
redirect_uri +="/" + String.format(login_url_template,account,code,time,token);
|
||||
}
|
||||
}else if(redirec_uri.endsWith("&")){
|
||||
redirec_uri += String.format(login_url_m_template,account,code,time,token);
|
||||
}else if(redirect_uri.endsWith("&")){
|
||||
redirect_uri += String.format(login_url_m_template,account,code,time,token);
|
||||
}else {
|
||||
redirec_uri += "&" +String.format(login_url_m_template,account,code,time,token);
|
||||
redirect_uri += "&" +String.format(login_url_m_template,account,code,time,token);
|
||||
}
|
||||
|
||||
_logger.debug("redirec_uri : "+redirec_uri);
|
||||
_logger.debug("redirect_uri : "+redirect_uri);
|
||||
modelAndView=new ModelAndView("authorize/redirect_sso_submit");
|
||||
modelAndView.addObject("redirect_uri", redirect_uri);
|
||||
|
||||
return WebContext.redirect(redirec_uri);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user