mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
changeSession login
This commit is contained in:
@@ -27,6 +27,7 @@ import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.domain.apps.Apps;
|
||||
import org.maxkey.persistence.service.AccountsService;
|
||||
import org.maxkey.persistence.service.AppsService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -54,11 +55,11 @@ public class AuthorizeBaseEndpoint {
|
||||
protected AccountsService accountsService;
|
||||
|
||||
protected Apps getApp(String id){
|
||||
Apps app=(Apps)WebContext.getAttribute(AuthorizeBaseEndpoint.class.getName());
|
||||
Apps app=(Apps)WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
|
||||
//session中为空或者id不一致重新加载
|
||||
if(app==null||!app.getId().equalsIgnoreCase(id)) {
|
||||
app=appsService.get(id);
|
||||
WebContext.setAttribute(AuthorizeBaseEndpoint.class.getName(), app);
|
||||
WebContext.setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP, app);
|
||||
}
|
||||
if(app == null){
|
||||
_logger.error("Applications for id "+id + " is null");
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.maxkey.authn.SigninPrincipal;
|
||||
import org.maxkey.authn.online.OnlineTicket;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.CasConstants;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.ServiceTicketImpl;
|
||||
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
|
||||
import org.maxkey.authz.singlelogout.LogoutType;
|
||||
import org.maxkey.domain.apps.AppsCasDetails;
|
||||
import org.maxkey.web.WebConstants;
|
||||
@@ -91,7 +90,7 @@ public class CasAuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
|
||||
);
|
||||
WebContext.setAttribute(CasConstants.PARAMETER.ENDPOINT_CAS_DETAILS, casDetails);
|
||||
WebContext.setAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID, casDetails.getId());
|
||||
WebContext.setAttribute(AuthorizeBaseEndpoint.class.getName(),casDetails);
|
||||
WebContext.setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP,casDetails);
|
||||
return WebContext.redirect("/authz/cas/granting");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.maxkey.authz.oauth2.provider.approval.ApprovalStore;
|
||||
import org.maxkey.domain.apps.Apps;
|
||||
import org.maxkey.domain.apps.oauth2.provider.ClientDetails;
|
||||
import org.maxkey.persistence.service.AppsService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -85,11 +86,11 @@ public class OAuth20AccessConfirmationController {
|
||||
AuthorizationRequest clientAuth =
|
||||
(AuthorizationRequest) WebContext.getAttribute("authorizationRequest");
|
||||
ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
|
||||
Apps app = (Apps)WebContext.getAttribute(AuthorizeBaseEndpoint.class.getName());
|
||||
Apps app = (Apps)WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
|
||||
//session中为空或者id不一致重新加载
|
||||
if (app == null || !app.getId().equalsIgnoreCase(clientAuth.getClientId())) {
|
||||
app = appsService.get(clientAuth.getClientId());
|
||||
WebContext.setAttribute(AuthorizeBaseEndpoint.class.getName(), app);
|
||||
WebContext.setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP, app);
|
||||
WebContext.setAttribute(app.getId(), app.getIcon());
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ public class AssertionEndpoint {
|
||||
@RequestMapping(value = "/authz/saml20/assertion")
|
||||
public ModelAndView assertion(HttpServletRequest request,HttpServletResponse response) throws Exception {
|
||||
logger.debug("saml20 assertion start.");
|
||||
bindingAdapter = (BindingAdapter) request.getSession().getAttribute("samlv20Adapter");
|
||||
bindingAdapter = (BindingAdapter) request.getSession().getAttribute(
|
||||
WebConstants.AUTHORIZE_SIGN_ON_APP_SAMLV20_ADAPTER);
|
||||
logger.debug("saml20 assertion get session samlv20Adapter "+bindingAdapter);
|
||||
AppsSAML20Details saml20Details = bindingAdapter.getSaml20Details();
|
||||
logger.debug("saml20Details "+saml20Details.getExtendAttr());
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.security.KeyStore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.authz.saml.common.AuthnRequestInfo;
|
||||
import org.maxkey.authz.saml20.binding.BindingAdapter;
|
||||
import org.maxkey.authz.saml20.binding.ExtractBindingAdapter;
|
||||
@@ -29,6 +28,7 @@ import org.maxkey.crypto.keystore.KeyStoreLoader;
|
||||
import org.maxkey.crypto.keystore.KeyStoreUtil;
|
||||
import org.maxkey.domain.apps.AppsSAML20Details;
|
||||
import org.maxkey.persistence.service.AppsSaml20DetailsService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -88,7 +88,7 @@ public class IdpInitEndpoint {
|
||||
@PathVariable("appid") String appId)throws Exception {
|
||||
logger.debug("SAML IDP init , app id is "+appId);
|
||||
AppsSAML20Details saml20Details = saml20DetailsService.getAppDetails(appId);
|
||||
|
||||
WebContext.setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP, saml20Details);
|
||||
if (saml20Details == null) {
|
||||
logger.error("samlId[" + appId + "] Error .");
|
||||
throw new Exception();
|
||||
@@ -114,7 +114,7 @@ public class IdpInitEndpoint {
|
||||
|
||||
bindingAdapter.setExtractBindingAdapter(extractRedirectBindingAdapter);
|
||||
|
||||
request.getSession().setAttribute("samlv20Adapter", bindingAdapter);
|
||||
request.getSession().setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP_SAMLV20_ADAPTER, bindingAdapter);
|
||||
|
||||
logger.debug("idp init forwarding to assertion :","/authz/saml20/assertion");
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.security.KeyStore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.authz.saml.common.AuthnRequestInfo;
|
||||
import org.maxkey.authz.saml20.binding.BindingAdapter;
|
||||
import org.maxkey.authz.saml20.binding.ExtractBindingAdapter;
|
||||
@@ -29,6 +28,7 @@ import org.maxkey.authz.saml20.xml.SAML2ValidatorSuite;
|
||||
import org.maxkey.crypto.keystore.KeyStoreUtil;
|
||||
import org.maxkey.domain.apps.AppsSAML20Details;
|
||||
import org.maxkey.persistence.service.AppsSaml20DetailsService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.opensaml.common.binding.SAMLMessageContext;
|
||||
import org.opensaml.saml2.core.AuthnRequest;
|
||||
@@ -101,14 +101,14 @@ public class SingleSignOnEndpoint {
|
||||
|
||||
extractSAMLMessage(extractBindingAdapter,request);
|
||||
|
||||
request.getSession().setAttribute("samlv20Adapter", bindingAdapter);
|
||||
request.getSession().setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP_SAMLV20_ADAPTER, bindingAdapter);
|
||||
|
||||
return WebContext.forward("/authz/saml20/assertion");
|
||||
}
|
||||
|
||||
public void extractSaml20Detail(ExtractBindingAdapter extractBindingAdapter,String samlId) throws Exception{
|
||||
AppsSAML20Details saml20Details = saml20DetailsService.getAppDetails(samlId);
|
||||
|
||||
WebContext.setAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP, saml20Details);
|
||||
if (saml20Details == null) {
|
||||
logger.error("Request SAML APPID [" + samlId + "] is not exist .");
|
||||
throw new Exception();
|
||||
|
||||
Reference in New Issue
Block a user