mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-26 22:38:45 +00:00
feat: protos refactoring
* start with user * user first try done in all services * user, org, idp for discussion * remove unused stuff * bla * dockerbuild * rename search, get multiple to list... * add annotation * update proto dependencies * update proto dependencies * change proto imports * replace all old imports * fix go out * remove unused lines * correct protoc flags * grpc and openapi flags * go out source path relative * -p * remove dead code * sourcepath relative * ls * is onenapi the problem? * hobla * authoption output * wrong field name * gopf * correct option, add correct flags * small improvments * SIMPLYFY * relative path * gopf bin ich en tubel * correct path * default policies in admin * grpc generation in one file * remove non ascii * metadata on manipulations * correct auth_option import * fixes * larry * idp provider to idp * fix generate * admin and auth nearly done * admin and auth nearly done * gen * healthz * imports * deleted too much imports * fix org * add import * imports * import * naming * auth_opt * gopf * management * imports * _TYPE_UNSPECIFIED * improts * auth opts * management policies * imports * passwordlessType to MFAType * auth_opt * add user grant calls * add missing messages * result * fix option * improvements * ids * fix http * imports * fixes * fields * body * add fields * remove wrong member query * fix request response * fixes * add copy files * variable versions * generate all files * improvements * add dependencies * factors * user session * oidc information, iam * remove unused file * changes * enums * dockerfile * fix build * remove unused folder * update readme for build * move old server impl * add event type to change * some changes * start admin * remove wrong field * admin only list calls missing * fix proto numbers * surprisingly it compiles * service ts changes * admin mgmt * mgmt * auth manipulation and gets done, lists missing * validations and some field changes * validations * enum validations * remove todo * move proto files to proto/zitadel * change proto path in dockerfile * it compiles! * add validate import * remove duplicate import * fix protos * fix import * tests * cleanup * remove unimplemented methods * iam member multiple queries * all auth and admin calls * add initial password on crate human * message names * management user server * machine done * fix: todos (#1346) * fix: pub sub in new eventstore * fix: todos * fix: todos * fix: todos * fix: todos * fix: todos * fix tests * fix: search method domain * admin service, user import type typescript * admin changes * admin changes * fix: search method domain * more user grpc and begin org, fix configs * fix: return object details * org grpc * remove creation date add details * app * fix: return object details * fix: return object details * mgmt service, project members * app * fix: convert policies * project, members, granted projects, searches * fix: convert usergrants * fix: convert usergrants * auth user detail, user detail, mfa, second factor, auth * fix: convert usergrants * mfa, memberships, password, owned proj detail * fix: convert usergrants * project grant * missing details * changes, userview * idp table, keys * org list and user table filter * unify rest paths (#1381) * unify rest paths * post for all searches, mfa to multi_factor, secondfactor to second_factor * remove v1 * fix tests * rename api client key to app key * machine keys, age policy * user list, machine keys, changes * fix: org states * add default flag to policy * second factor to type * idp id * app type * unify ListQuery, ListDetails, ObjectDetails field names * user grants, apps, memberships * fix type params * metadata to detail, linke idps * api create, membership, app detail, create * idp, app, policy * queries, multi -> auth factors and missing fields * update converters * provider to user, remove old mgmt refs * temp remove authfactor dialog, build finish Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Fabi <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: Fabiennne <[email protected]>
This commit is contained in:
co-authored by
Max Peintner
Fabi
Livio Amstutz
Fabiennne
parent
9f417f3957
commit
dabd5920dc
@@ -5,29 +5,28 @@ import { Subscription } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { LoginMethodComponentType } from 'src/app/modules/mfa-table/mfa-table.component';
|
||||
import {
|
||||
DefaultLoginPolicy,
|
||||
DefaultLoginPolicyRequest,
|
||||
DefaultLoginPolicyView,
|
||||
IdpProviderView as AdminIdpProviderView,
|
||||
IdpStylingType,
|
||||
IdpView as AdminIdpView,
|
||||
PasswordlessType as AdminPasswordlessType,
|
||||
} from 'src/app/proto/generated/admin_pb';
|
||||
GetLoginPolicyResponse as AdminGetLoginPolicyResponse,
|
||||
UpdateLoginPolicyRequest,
|
||||
UpdateLoginPolicyResponse,
|
||||
} from 'src/app/proto/generated/zitadel/admin_pb';
|
||||
import { IDP, IDPLoginPolicyLink, IDPStylingType } from 'src/app/proto/generated/zitadel/idp_pb';
|
||||
import {
|
||||
IdpProviderType,
|
||||
IdpProviderView as MgmtIdpProviderView,
|
||||
IdpView as MgmtIdpView,
|
||||
LoginPolicy,
|
||||
LoginPolicyRequest,
|
||||
LoginPolicyView,
|
||||
PasswordlessType as MgmtPasswordlessType,
|
||||
} from 'src/app/proto/generated/management_pb';
|
||||
AddCustomLoginPolicyRequest,
|
||||
GetLoginPolicyResponse as MgmtGetLoginPolicyResponse,
|
||||
} from 'src/app/proto/generated/zitadel/management_pb';
|
||||
import { LoginPolicy, PasswordlessType } from 'src/app/proto/generated/zitadel/policy_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { CnslLinks } from '../../links/links.component';
|
||||
import { IAM_COMPLEXITY_LINK, IAM_LABEL_LINK, IAM_LOGIN_POLICY_LINK, IAM_POLICY_LINK, ORG_COMPLEXITY_LINK, ORG_IAM_POLICY_LINK } from '../../policy-grid/policy-links';
|
||||
|
||||
import { CnslLinks } from '../../links/links.component';
|
||||
import {
|
||||
IAM_COMPLEXITY_LINK,
|
||||
IAM_LABEL_LINK,
|
||||
IAM_POLICY_LINK,
|
||||
ORG_COMPLEXITY_LINK,
|
||||
ORG_IAM_POLICY_LINK,
|
||||
} from '../../policy-grid/policy-links';
|
||||
import { PolicyComponentServiceType } from '../policy-component-types.enum';
|
||||
import { AddIdpDialogComponent } from './add-idp-dialog/add-idp-dialog.component';
|
||||
|
||||
@@ -38,19 +37,19 @@ import { AddIdpDialogComponent } from './add-idp-dialog/add-idp-dialog.component
|
||||
})
|
||||
export class LoginPolicyComponent implements OnDestroy {
|
||||
public LoginMethodComponentType: any = LoginMethodComponentType;
|
||||
public passwordlessTypes: Array<AdminPasswordlessType | MgmtPasswordlessType> = [];
|
||||
public loginData!: LoginPolicyView.AsObject | DefaultLoginPolicyView.AsObject;
|
||||
public passwordlessTypes: Array<PasswordlessType> = [];
|
||||
public loginData!: LoginPolicy.AsObject;
|
||||
|
||||
private sub: Subscription = new Subscription();
|
||||
public service!: ManagementService | AdminService;
|
||||
public PolicyComponentServiceType: any = PolicyComponentServiceType;
|
||||
public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
|
||||
public idps: MgmtIdpProviderView.AsObject[] | AdminIdpProviderView.AsObject[] = [];
|
||||
public idps: IDPLoginPolicyLink.AsObject[] = [];
|
||||
|
||||
public loading: boolean = false;
|
||||
public disabled: boolean = true;
|
||||
|
||||
public IdpStylingType: any = IdpStylingType;
|
||||
public IDPStylingType: any = IDPStylingType;
|
||||
public nextLinks: CnslLinks[] = [];
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@@ -63,8 +62,10 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
this.service = this.injector.get(ManagementService as Type<ManagementService>);
|
||||
this.passwordlessTypes = [MgmtPasswordlessType.PASSWORDLESSTYPE_ALLOWED,
|
||||
MgmtPasswordlessType.PASSWORDLESSTYPE_NOT_ALLOWED];
|
||||
this.passwordlessTypes = [
|
||||
PasswordlessType.PASSWORDLESS_TYPE_ALLOWED,
|
||||
PasswordlessType.PASSWORDLESS_TYPE_NOT_ALLOWED,
|
||||
];
|
||||
this.nextLinks = [
|
||||
ORG_COMPLEXITY_LINK,
|
||||
ORG_IAM_POLICY_LINK,
|
||||
@@ -72,8 +73,10 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
break;
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
this.service = this.injector.get(AdminService as Type<AdminService>);
|
||||
this.passwordlessTypes = [AdminPasswordlessType.PASSWORDLESSTYPE_ALLOWED,
|
||||
AdminPasswordlessType.PASSWORDLESSTYPE_NOT_ALLOWED];
|
||||
this.passwordlessTypes = [
|
||||
PasswordlessType.PASSWORDLESS_TYPE_ALLOWED,
|
||||
PasswordlessType.PASSWORDLESS_TYPE_NOT_ALLOWED,
|
||||
];
|
||||
this.nextLinks = [
|
||||
IAM_COMPLEXITY_LINK,
|
||||
IAM_POLICY_LINK,
|
||||
@@ -89,15 +92,15 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
private fetchData(): void {
|
||||
this.getData().then(data => {
|
||||
if (data) {
|
||||
this.loginData = data.toObject();
|
||||
this.getData().then(resp => {
|
||||
if (resp.policy) {
|
||||
this.loginData = resp.policy;
|
||||
this.loading = false;
|
||||
this.disabled = ((this.loginData as LoginPolicyView.AsObject)?.pb_default) ?? false;
|
||||
this.disabled = ((this.loginData as LoginPolicy.AsObject)?.isDefault) ?? false;
|
||||
}
|
||||
});
|
||||
this.getIdps().then(idps => {
|
||||
this.idps = idps;
|
||||
this.getIdps().then(resp => {
|
||||
this.idps = resp;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,48 +109,48 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
private async getData():
|
||||
Promise<LoginPolicyView | DefaultLoginPolicyView> {
|
||||
Promise<AdminGetLoginPolicyResponse.AsObject | MgmtGetLoginPolicyResponse.AsObject> {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return (this.service as ManagementService).GetLoginPolicy();
|
||||
return (this.service as ManagementService).getLoginPolicy();
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return (this.service as AdminService).GetDefaultLoginPolicy();
|
||||
return (this.service as AdminService).getLoginPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
private async getIdps(): Promise<MgmtIdpProviderView.AsObject[] | AdminIdpProviderView.AsObject[]> {
|
||||
private async getIdps(): Promise<IDPLoginPolicyLink.AsObject[]> {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return (this.service as ManagementService).GetLoginPolicyIdpProviders()
|
||||
.then((providers) => {
|
||||
return providers.toObject().resultList;
|
||||
return (this.service as ManagementService).listLoginPolicyIDPs()
|
||||
.then((resp) => {
|
||||
return resp.resultList;
|
||||
});
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return (this.service as AdminService).GetDefaultLoginPolicyIdpProviders()
|
||||
return (this.service as AdminService).listLoginPolicyIDPs()
|
||||
.then((providers) => {
|
||||
return providers.toObject().resultList;
|
||||
return providers.resultList;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async updateData():
|
||||
Promise<LoginPolicy | DefaultLoginPolicy> {
|
||||
Promise<UpdateLoginPolicyResponse.AsObject> {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
const mgmtreq = new LoginPolicyRequest();
|
||||
const mgmtreq = new AddCustomLoginPolicyRequest();
|
||||
mgmtreq.setAllowExternalIdp(this.loginData.allowExternalIdp);
|
||||
mgmtreq.setAllowRegister(this.loginData.allowRegister);
|
||||
mgmtreq.setAllowUsernamePassword(this.loginData.allowUsernamePassword);
|
||||
mgmtreq.setForceMfa(this.loginData.forceMfa);
|
||||
mgmtreq.setPasswordlessType(this.loginData.passwordlessType);
|
||||
// console.log(mgmtreq.toObject());
|
||||
if ((this.loginData as LoginPolicyView.AsObject).pb_default) {
|
||||
return (this.service as ManagementService).CreateLoginPolicy(mgmtreq);
|
||||
if ((this.loginData as LoginPolicy.AsObject).isDefault) {
|
||||
return (this.service as ManagementService).addCustomLoginPolicy(mgmtreq);
|
||||
} else {
|
||||
return (this.service as ManagementService).UpdateLoginPolicy(mgmtreq);
|
||||
return (this.service as ManagementService).updateCustomLoginPolicy(mgmtreq);
|
||||
}
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
const adminreq = new DefaultLoginPolicyRequest();
|
||||
const adminreq = new UpdateLoginPolicyRequest();
|
||||
adminreq.setAllowExternalIdp(this.loginData.allowExternalIdp);
|
||||
adminreq.setAllowRegister(this.loginData.allowRegister);
|
||||
adminreq.setAllowUsernamePassword(this.loginData.allowUsernamePassword);
|
||||
@@ -156,7 +159,7 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
|
||||
// console.log(adminreq.toObject());
|
||||
|
||||
return (this.service as AdminService).UpdateDefaultLoginPolicy(adminreq);
|
||||
return (this.service as AdminService).updateLoginPolicy(adminreq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +177,7 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
|
||||
public removePolicy(): void {
|
||||
if (this.serviceType === PolicyComponentServiceType.MGMT) {
|
||||
(this.service as ManagementService).RemoveLoginPolicy().then(() => {
|
||||
(this.service as ManagementService).resetLoginPolicyToDefault().then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
|
||||
this.loading = true;
|
||||
setTimeout(() => {
|
||||
@@ -195,8 +198,8 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(resp => {
|
||||
if (resp && resp.idp && resp.type) {
|
||||
this.addIdp(resp.idp, resp.type).then(() => {
|
||||
if (resp && resp.idp) {
|
||||
this.addIdp(resp.idp).then(() => {
|
||||
this.loading = true;
|
||||
setTimeout(() => {
|
||||
this.fetchData();
|
||||
@@ -208,29 +211,28 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private addIdp(idp: AdminIdpView.AsObject | MgmtIdpView.AsObject,
|
||||
type: IdpProviderType = IdpProviderType.IDPPROVIDERTYPE_SYSTEM): Promise<any> {
|
||||
private addIdp(idp: IDP.AsObject | IDP.AsObject): Promise<any> {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return (this.service as ManagementService).addIdpProviderToLoginPolicy(idp.id, type);
|
||||
return (this.service as ManagementService).addIDPToLoginPolicy(idp.id);
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return (this.service as AdminService).AddIdpProviderToDefaultLoginPolicy(idp.id);
|
||||
return (this.service as AdminService).addIDPToLoginPolicy(idp.id);
|
||||
}
|
||||
}
|
||||
|
||||
public removeIdp(idp: AdminIdpProviderView.AsObject | MgmtIdpProviderView.AsObject): void {
|
||||
public removeIdp(idp: IDPLoginPolicyLink.AsObject): void {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
(this.service as ManagementService).RemoveIdpProviderFromLoginPolicy(idp.idpConfigId).then(() => {
|
||||
const index = (this.idps as MgmtIdpProviderView.AsObject[]).findIndex(temp => temp === idp);
|
||||
(this.service as ManagementService).removeIDPFromLoginPolicy(idp.idpId).then(() => {
|
||||
const index = this.idps.findIndex(temp => temp === idp);
|
||||
if (index > -1) {
|
||||
this.idps.splice(index, 1);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
(this.service as AdminService).RemoveIdpProviderFromDefaultLoginPolicy(idp.idpConfigId).then(() => {
|
||||
const index = (this.idps as AdminIdpProviderView.AsObject[]).findIndex(temp => temp === idp);
|
||||
(this.service as AdminService).removeIDPFromLoginPolicy(idp.idpId).then(() => {
|
||||
const index = this.idps.findIndex(temp => temp === idp);
|
||||
if (index > -1) {
|
||||
this.idps.splice(index, 1);
|
||||
}
|
||||
@@ -241,7 +243,7 @@ export class LoginPolicyComponent implements OnDestroy {
|
||||
|
||||
public get isDefault(): boolean {
|
||||
if (this.loginData && this.serviceType === PolicyComponentServiceType.MGMT) {
|
||||
return (this.loginData as LoginPolicyView.AsObject).pb_default;
|
||||
return (this.loginData as LoginPolicy.AsObject).isDefault;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user