diff --git a/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/AbstractSocialSignOnEndpoint.java b/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/AbstractSocialSignOnEndpoint.java index 0239ae72..2dbfe42e 100644 --- a/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/AbstractSocialSignOnEndpoint.java +++ b/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/AbstractSocialSignOnEndpoint.java @@ -64,13 +64,13 @@ public class AbstractSocialSignOnEndpoint { @Autowired ApplicationConfig applicationConfig; - protected AuthRequest buildAuthRequest(String instId,String provider){ + protected AuthRequest buildAuthRequest(String instId,String provider,String baseUrl){ try { SocialsProvider socialSignOnProvider = socialSignOnProviderService.get(instId,provider); _logger.debug("socialSignOn Provider : "+socialSignOnProvider); if(socialSignOnProvider != null){ - authRequest = socialSignOnProviderService.getAuthRequest(instId,provider,WebContext.getBaseUri()); + authRequest = socialSignOnProviderService.getAuthRequest(instId,provider,baseUrl); return authRequest; } }catch(Exception e) { @@ -79,7 +79,7 @@ public class AbstractSocialSignOnEndpoint { return null; } - protected SocialsAssociate authCallback(String instId,String provider) throws Exception { + protected SocialsAssociate authCallback(String instId,String provider,String baseUrl) throws Exception { SocialsAssociate socialsAssociate = null; AuthCallback authCallback=new AuthCallback(); authCallback.setCode(WebContext.getRequest().getParameter("code")); @@ -97,7 +97,7 @@ public class AbstractSocialSignOnEndpoint { authCallback.getState()); if(authRequest == null) {//if authRequest is null renew one - authRequest=socialSignOnProviderService.getAuthRequest(instId,provider,WebContext.getBaseUri()); + authRequest=socialSignOnProviderService.getAuthRequest(instId,provider,baseUrl); _logger.debug("session authRequest is null , renew one"); } diff --git a/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/SocialSignOnEndpoint.java b/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/SocialSignOnEndpoint.java index 076b09df..69b7440c 100644 --- a/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/SocialSignOnEndpoint.java +++ b/maxkey-authentications/maxkey-authentication-social/src/main/java/org/maxkey/authn/support/socialsignon/SocialSignOnEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] + * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletRequest; import org.maxkey.authn.LoginCredential; import org.maxkey.authn.annotation.CurrentUser; import org.maxkey.authn.jwt.AuthJwt; -import org.maxkey.authn.web.AuthorizationUtils; import org.maxkey.constants.ConstsLoginType; import org.maxkey.entity.Message; import org.maxkey.entity.SocialsAssociate; @@ -38,6 +37,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -54,23 +54,34 @@ public class SocialSignOnEndpoint extends AbstractSocialSignOnEndpoint{ @RequestMapping(value={"/authorize/{provider}"}, method = RequestMethod.GET) @ResponseBody - public ResponseEntity authorize(HttpServletRequest request, - @PathVariable String provider + public ResponseEntity authorize( HttpServletRequest request, + @PathVariable String provider, + @RequestHeader("Origin") String originURL ) { _logger.trace("SocialSignOn provider : " + provider); String instId = WebContext.getInst().getId(); - String authorizationUrl = buildAuthRequest(instId,provider).authorize(authTokenService.genRandomJwt()); + String authorizationUrl = + buildAuthRequest( + instId, + provider, + originURL + applicationConfig.getFrontendUri() + ).authorize(authTokenService.genRandomJwt()); + _logger.trace("authorize SocialSignOn : " + authorizationUrl); return new Message((Object)authorizationUrl).buildResponse(); } @RequestMapping(value={"/scanqrcode/{provider}"}, method = RequestMethod.GET) @ResponseBody - public ResponseEntity scanQRCode( - HttpServletRequest request, - @PathVariable("provider") String provider) { + public ResponseEntity scanQRCode(HttpServletRequest request, + @PathVariable("provider") String provider, + @RequestHeader("Origin") String originURL) { String instId = WebContext.getInst().getId(); - AuthRequest authRequest = buildAuthRequest(instId,provider); + AuthRequest authRequest = + buildAuthRequest( + instId, + provider, + originURL + applicationConfig.getFrontendUri()); if(authRequest == null ) { _logger.error("build authRequest fail ."); @@ -82,17 +93,21 @@ public class SocialSignOnEndpoint extends AbstractSocialSignOnEndpoint{ SocialsProvider scanQrProvider = new SocialsProvider(socialSignOnProvider); scanQrProvider.setState(state); scanQrProvider.setRedirectUri( - socialSignOnProviderService.getRedirectUri(WebContext.getBaseUri(), provider)); + socialSignOnProviderService.getRedirectUri( + originURL + applicationConfig.getFrontendUri(), provider)); return new Message(scanQrProvider).buildResponse(); } @RequestMapping(value={"/bind/{provider}"}, method = RequestMethod.GET) - public ResponseEntity bind(@PathVariable String provider,@CurrentUser UserInfo userInfo) { + public ResponseEntity bind(@PathVariable String provider, + @RequestHeader("Origin") String originURL, + @CurrentUser UserInfo userInfo) { //auth call back may exception try { - SocialsAssociate socialsAssociate = this.authCallback(userInfo.getInstId(),provider); + SocialsAssociate socialsAssociate = + this.authCallback(userInfo.getInstId(),provider,originURL + applicationConfig.getFrontendUri()); socialsAssociate.setSocialUserInfo(accountJsonString); socialsAssociate.setUserId(userInfo.getId()); socialsAssociate.setUsername(userInfo.getUsername()); @@ -111,11 +126,13 @@ public class SocialSignOnEndpoint extends AbstractSocialSignOnEndpoint{ } @RequestMapping(value={"/callback/{provider}"}, method = RequestMethod.GET) - public ResponseEntity callback(@PathVariable String provider) { + public ResponseEntity callback(@PathVariable String provider, + @RequestHeader("Origin") String originURL) { //auth call back may exception try { String instId = WebContext.getInst().getId(); - SocialsAssociate socialsAssociate = this.authCallback(instId,provider); + SocialsAssociate socialsAssociate = + this.authCallback(instId,provider,originURL + applicationConfig.getFrontendUri()); socialsAssociate=this.socialsAssociateService.get(socialsAssociate); diff --git a/maxkey-web-frontend/maxkey-web-app/package.json b/maxkey-web-frontend/maxkey-web-app/package.json index 1238d241..9a52cf7a 100644 --- a/maxkey-web-frontend/maxkey-web-app/package.json +++ b/maxkey-web-frontend/maxkey-web-app/package.json @@ -2,7 +2,7 @@ "name": "maxkey", "version": "3.5.0", "description": "Leading-Edge IAM Identity and Access Management", - "author": "MaxKey ", + "author": "MaxKey ", "repository": { "type": "git", "url": "https://gitee.com/dromara/MaxKey" diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/core/net/default.interceptor.ts b/maxkey-web-frontend/maxkey-web-app/src/app/core/net/default.interceptor.ts index 219aeb18..9b1e5120 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/core/net/default.interceptor.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/core/net/default.interceptor.ts @@ -1,19 +1,18 @@ /* * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - import { HttpErrorResponse, diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.html b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.html index 08bcf18e..92a3c950 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.html +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.html @@ -1,24 +1,21 @@
- - + +
- + @@ -29,15 +26,12 @@ - + - + @@ -74,7 +68,8 @@ - @@ -89,8 +84,8 @@ - {{ 'mxk.login.forgot-password' | i18n }} + {{ 'mxk.login.forgot-password' | i18n }} + -
+
{{ 'app.login.sign-in-with' | i18n }} - - {{ 'mxk.login.signup' | i18n }} -
+ {{ 'mxk.login.signup' | i18n }} +
\ No newline at end of file diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.less b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.less index 639caa99..e710ca7f 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.less +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.less @@ -22,6 +22,13 @@ padding-left: 4px; } + .login-tab{ + color: #000; + background: unset; + border-color: unset; + border-right-color: unset; + } + .icon { margin-left: 16px; color: rgb(0 0 0 / 20%); diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts index 5e18e74b..ff989797 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/login/login.component.ts @@ -50,13 +50,13 @@ export class UserLoginComponent implements OnInit, OnDestroy { form: FormGroup; error = ''; + switchTab = true; loginType = 'normal'; loading = false; passwordVisible = false; imageCaptcha = ''; captchaType = ''; state = ''; - count = 0; interval$: any; @@ -279,6 +279,7 @@ export class UserLoginComponent implements OnInit, OnDestroy { // #region social socialauth(provider: string): void { + this.authnService.clearUser(); this.socialsProviderService.authorize(provider).subscribe(res => { //console.log(res.data); window.location.href = res.data; diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/service/socials-provider.service.ts b/maxkey-web-frontend/maxkey-web-app/src/app/service/socials-provider.service.ts index 9f006bc4..d16d006c 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/service/socials-provider.service.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/service/socials-provider.service.ts @@ -1,19 +1,18 @@ /* * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/shared/utils/set2stringstil.ts b/maxkey-web-frontend/maxkey-web-app/src/app/shared/utils/set2stringstil.ts index 2316f918..f779b3fc 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/shared/utils/set2stringstil.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/shared/utils/set2stringstil.ts @@ -1,19 +1,18 @@ /* * Copyright [2022] [MaxKey of copyright http://www.maxkey.top] - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - export function set2String(set: Set): string { let setValues = ''; diff --git a/maxkey-web-frontend/maxkey-web-mgt-app/package.json b/maxkey-web-frontend/maxkey-web-mgt-app/package.json index 8965048f..2be52e2d 100644 --- a/maxkey-web-frontend/maxkey-web-mgt-app/package.json +++ b/maxkey-web-frontend/maxkey-web-mgt-app/package.json @@ -2,7 +2,7 @@ "name": "maxkey", "version": "3.5.0", "description": "Leading-Edge IAM Identity and Access Management", - "author": "MaxKey ", + "author": "MaxKey ", "repository": { "type": "git", "url": "https://gitee.com/dromara/MaxKey"