diff --git a/gradle.properties b/gradle.properties index 2c7006665..6333110fe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -56,8 +56,8 @@ xmlbeansVersion =5.0.2 commonscompressVersion =1.20 log4jVersion =2.17.1 kafkaclientsVersion =2.8.1 -rocketmqclientVersion =4.9.2 -rocketmqspringbootVersion =2.2.1 +rocketmqclientVersion =4.9.3 +rocketmqspringbootVersion =2.2.2 poiVersion =5.1.0 tomcatVersion =9.0.62 tomcatembedloggingjuliVersion =8.5.2 @@ -117,7 +117,7 @@ jakartavalidationapiVersion =3.0.0 attoparserVersion =2.0.5.RELEASE unbescapeVersion =1.1.6.RELEASE slf4jVersion =1.7.35 -jacksonVersion =2.13.1 +jacksonVersion =2.13.2 woodstoxVersion =6.2.8 bouncycastleVersion =1.69 junitVersion =4.11 diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/jwt/AuthJwt.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/jwt/AuthJwt.java index 6b0f68edc..a85fac9a1 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/jwt/AuthJwt.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/jwt/AuthJwt.java @@ -39,6 +39,7 @@ public class AuthJwt implements Serializable { private String email; private String instId; private String instName; + private int passwordSetType; private List authorities; @@ -147,6 +148,15 @@ public class AuthJwt implements Serializable { public void setTicket(String ticket) { this.ticket = ticket; } + + public int getPasswordSetType() { + return passwordSetType; + } + + public void setPasswordSetType(int passwordSetType) { + this.passwordSetType = passwordSetType; + } + @Override public String toString() { 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 33f39c8cd..e23d470fd 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 @@ -23,6 +23,7 @@ package org.maxkey.authn.support.socialsignon; 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; @@ -87,16 +88,15 @@ public class SocialSignOnEndpoint extends AbstractSocialSignOnEndpoint{ } - @RequestMapping(value={"/bind/{provider}"}, method = RequestMethod.POST) - public ResponseEntity bind(@PathVariable String provider) { + @RequestMapping(value={"/bind/{provider}"}, method = RequestMethod.GET) + public ResponseEntity bind(@PathVariable String provider,@CurrentUser UserInfo userInfo) { //auth call back may exception try { - String instId = WebContext.getInst().getId(); - SocialsAssociate socialsAssociate = this.authCallback(instId,provider); - UserInfo userInfo = AuthorizationUtils.getUserInfo(); + SocialsAssociate socialsAssociate = this.authCallback(userInfo.getInstId(),provider); socialsAssociate.setSocialUserInfo(accountJsonString); socialsAssociate.setUserId(userInfo.getId()); socialsAssociate.setUsername(userInfo.getUsername()); + socialsAssociate.setInstId(userInfo.getInstId()); //socialsAssociate.setAccessToken(JsonUtils.object2Json(accessToken)); //socialsAssociate.setExAttribute(JsonUtils.object2Json(accessToken.getResponseObject())); _logger.debug("Social Bind : "+socialsAssociate); diff --git a/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/SocialsAssociateMapper.xml b/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/SocialsAssociateMapper.xml index fca647543..0aa6a20d7 100644 --- a/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/SocialsAssociateMapper.xml +++ b/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/SocialsAssociateMapper.xml @@ -11,6 +11,7 @@ a.id, a.userid, a.username, + a.socialuserid, a.createdDate, a.updatedDate from @@ -18,12 +19,12 @@ left join mxk_socials_associate a - on a.provider = p.provider and a.userid = #{id} - + on a.provider = p.provider + and a.instid = p.instid + and a.instid = #{instId} + and a.userid = #{id} where - a.instid = p.instid - and a.instid = #{instId} - and p.status =1 + p.status =1 order by p.sortindex diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/layout/basic/basic.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/layout/basic/basic.component.ts index cc522781d..95ea4d11f 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/layout/basic/basic.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/layout/basic/basic.component.ts @@ -20,16 +20,7 @@ import { LayoutDefaultOptions } from '../../theme/layout-default'; logo -
- MaxKey{{ 'mxk.title' | i18n }} -
+
MaxKey{{ 'mxk.title' | i18n }}
diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.html b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.html index 5d8880e4f..bbf3661e7 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.html +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.html @@ -40,9 +40,17 @@
- - +
diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.ts index 57736e82b..7b3972161 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/config/socials-associate/socials-associate.component.ts @@ -6,10 +6,14 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzMessageService } from 'ng-zorro-antd/message'; import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; import { NzTableQueryParams } from 'ng-zorro-antd/table'; +import { logging } from 'protractor'; import { SocialsAssociateService } from '../../../service/socials-associate.service'; +import { SocialsProviderService } from '../../../service/socials-provider.service'; import { set2String } from '../../../shared/index'; +import { log } from 'console'; + @Component({ selector: 'app-socials-associate', templateUrl: './socials-associate.component.html', @@ -66,6 +70,7 @@ export class SocialsAssociateComponent implements OnInit { constructor( private modalService: NzModalService, + private socialsProviderService: SocialsProviderService, private socialsAssociateService: SocialsAssociateService, private viewContainerRef: ViewContainerRef, private fb: FormBuilder, @@ -89,22 +94,11 @@ export class SocialsAssociateComponent implements OnInit { onReset(): void { } - onAdd(e: MouseEvent): void { + onAdd(e: MouseEvent, provider: string): void { e.preventDefault(); - const modal = this.modalService.create({ - //nzContent: SocialsProviderEditerComponent, - nzViewContainerRef: this.viewContainerRef, - nzComponentParams: { - isEdit: false, - id: '' - }, - nzOnOk: () => new Promise(resolve => setTimeout(resolve, 1000)) - }); - // Return a result when closed - modal.afterClose.subscribe(result => { - if (result.refresh) { - this.fetch(); - } + this.socialsProviderService.authorize(provider).subscribe(res => { + //console.log(res.data); + window.location.href = res.data; }); } @@ -135,6 +129,7 @@ export class SocialsAssociateComponent implements OnInit { this.query.params.startDate = ''; } this.socialsAssociateService.fetch(this.query.params).subscribe(res => { + console.log(res.data); this.query.results.rows = res.data; this.query.submitLoading = false; this.query.tableLoading = false; diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/callback.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/callback.component.ts index 5b7b55dac..4687e0a04 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/callback.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/routes/passport/callback.component.ts @@ -1,5 +1,5 @@ import { Inject, Optional, Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { ReuseTabService } from '@delon/abc/reuse-tab'; import { SettingsService } from '@delon/theme'; @@ -14,8 +14,9 @@ export class CallbackComponent implements OnInit { provider = ''; constructor( + private router: Router, private socialsProviderService: SocialsProviderService, - private settingsSrv: SettingsService, + private settingsService: SettingsService, private authenticationService: AuthenticationService, @Optional() @Inject(ReuseTabService) @@ -25,14 +26,22 @@ export class CallbackComponent implements OnInit { ngOnInit(): void { this.provider = this.route.snapshot.params['provider']; - this.socialsProviderService.callback(this.provider, this.route.snapshot.queryParams).subscribe(res => { - if (res.code === 0) { - // 清空路由复用信息 - this.reuseTabService.clear(); - // 设置用户Token信息 - this.authenticationService.auth(res.data); - } - this.authenticationService.navigate({}); - }); + if (!this.settingsService.user.name) { + this.socialsProviderService.callback(this.provider, this.route.snapshot.queryParams).subscribe(res => { + if (res.code === 0) { + // 清空路由复用信息 + this.reuseTabService.clear(); + // 设置用户Token信息 + this.authenticationService.auth(res.data); + } + this.authenticationService.navigate({}); + }); + } else { + this.socialsProviderService.bind(this.provider, this.route.snapshot.queryParams).subscribe(res => { + if (res.code === 0) { + } + this.router.navigateByUrl('/config/socialsassociate'); + }); + } } } 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 e4395f9e2..816c895da 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 @@ -260,6 +260,7 @@ export class UserLoginComponent implements OnInit, OnDestroy { } getQrCode(): void { + this.authenticationService.clearUser(); this.socialsProviderService.scanqrcode(this.socials.qrScan).subscribe(res => { if (res.code === 0) { if (this.socials.qrScan === 'workweixin') { diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/service/authentication.service.ts b/maxkey-web-frontend/maxkey-web-app/src/app/service/authentication.service.ts index 9c94f84a9..38e446eaa 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/service/authentication.service.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/service/authentication.service.ts @@ -49,6 +49,11 @@ export class AuthenticationService { this.tokenService.clear(); } + clearUser() { + let user: User = {}; + this.settingsService.setUser(user); + } + auth(authJwt: any) { let user: User = { name: `${authJwt.displayName}(${authJwt.username})`, @@ -56,7 +61,8 @@ export class AuthenticationService { username: authJwt.username, userId: authJwt.id, avatar: './assets/img/avatar.svg', - email: authJwt.email + email: authJwt.email, + passwordSetType: authJwt.passwordSetType }; let hostnames = window.location.hostname.split('.'); 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 ad2d65bd2..9e91bbf57 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 @@ -26,4 +26,8 @@ export class SocialsProviderService extends BaseService { callback(provider: string, params: NzSafeAny): Observable> { return this.getByParams(params, `/logon/oauth20/callback/${provider}?_allow_anonymous=true`); } + + bind(provider: string, params: NzSafeAny): Observable> { + return this.getByParams(params, `/logon/oauth20/bind/${provider}?_allow_anonymous=true`); + } } diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout-nav.component.html b/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout-nav.component.html index 687170a20..aa1f34fe7 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout-nav.component.html +++ b/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout-nav.component.html @@ -2,7 +2,7 @@
    -
  • +
  • {{ mnav.text }}
  • diff --git a/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout.component.ts b/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout.component.ts index 2970dfdfc..e7cc253af 100644 --- a/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout.component.ts +++ b/maxkey-web-frontend/maxkey-web-app/src/app/theme/layout-default/layout.component.ts @@ -18,7 +18,7 @@ import { LayoutDefaultOptions } from './types';
    -