fix(console): idp write access (#2258)

* fix: idp

* disable idp form in detail

* lint

* change list idp request

* fix external idp removal
This commit is contained in:
Max Peintner
2021-08-26 08:15:00 +02:00
committed by GitHub
parent 34002ec834
commit cd629a5d1c
12 changed files with 179 additions and 138 deletions

View File

@@ -2,80 +2,98 @@ import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { IDP, IDPOwnerType, IDPOwnerTypeQuery } from 'src/app/proto/generated/zitadel/idp_pb';
import { IDPQuery } from 'src/app/proto/generated/zitadel/management_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 { PolicyComponentServiceType } from '../../policy-component-types.enum';
@Component({
selector: 'app-add-idp-dialog',
templateUrl: './add-idp-dialog.component.html',
styleUrls: ['./add-idp-dialog.component.scss'],
selector: 'app-add-idp-dialog',
templateUrl: './add-idp-dialog.component.html',
styleUrls: ['./add-idp-dialog.component.scss'],
})
export class AddIdpDialogComponent {
public PolicyComponentServiceType: any = PolicyComponentServiceType;
public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
public PolicyComponentServiceType: any = PolicyComponentServiceType;
public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
public idpType!: IDPOwnerType;
public idpTypes: IDPOwnerType[] = [
IDPOwnerType.IDP_OWNER_TYPE_SYSTEM,
IDPOwnerType.IDP_OWNER_TYPE_ORG,
];
public idpType!: IDPOwnerType;
public idpTypes: IDPOwnerType[] = [
IDPOwnerType.IDP_OWNER_TYPE_SYSTEM,
IDPOwnerType.IDP_OWNER_TYPE_ORG,
];
public idp: IDP.AsObject | undefined = undefined;
public availableIdps: Array<IDP.AsObject[] | IDP.AsObject> | string[] = [];
public idp: IDP.AsObject | undefined = undefined;
public availableIdps: Array<IDP.AsObject[] | IDP.AsObject> | string[] = [];
constructor(
private mgmtService: ManagementService,
private adminService: AdminService,
public dialogRef: MatDialogRef<AddIdpDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
) {
if (data.serviceType) {
this.serviceType = data.serviceType;
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
this.idpType = IDPOwnerType.IDP_OWNER_TYPE_ORG;
break;
case PolicyComponentServiceType.ADMIN:
this.idpType = IDPOwnerType.IDP_OWNER_TYPE_SYSTEM;
break;
}
}
this.loadIdps();
constructor(
private mgmtService: ManagementService,
private toast: ToastService,
public dialogRef: MatDialogRef<AddIdpDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
) {
if (data.serviceType) {
this.serviceType = data.serviceType;
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
this.idpType = IDPOwnerType.IDP_OWNER_TYPE_ORG;
break;
case PolicyComponentServiceType.ADMIN:
this.idpType = IDPOwnerType.IDP_OWNER_TYPE_SYSTEM;
break;
}
}
public loadIdps(): void {
this.idp = undefined;
switch (this.idpType) {
case IDPOwnerType.IDP_OWNER_TYPE_ORG:
const query: IDPQuery = new IDPQuery();
const idpOTQ: IDPOwnerTypeQuery = new IDPOwnerTypeQuery();
idpOTQ.setOwnerType(this.idpType);
query.setOwnerTypeQuery(idpOTQ);
this.loadIdps();
}
this.mgmtService.listOrgIDPs(undefined, undefined, [query]).then(resp => {
this.availableIdps = resp.resultList;
});
break;
case IDPOwnerType.IDP_OWNER_TYPE_SYSTEM:
this.adminService.listIDPs().then(resp => {
this.availableIdps = resp.resultList;
});
break;
public loadIdps(): void {
this.idp = undefined;
}
}
public closeDialog(): void {
this.dialogRef.close(false);
}
public closeDialogWithSuccess(): void {
this.dialogRef.close({
idp: this.idp,
type: this.idpType,
switch (this.idpType) {
case IDPOwnerType.IDP_OWNER_TYPE_ORG:
const query: IDPQuery = new IDPQuery();
const idpOTQ: IDPOwnerTypeQuery = new IDPOwnerTypeQuery();
idpOTQ.setOwnerType(this.idpType);
query.setOwnerTypeQuery(idpOTQ);
const orgQuery = new IDPQuery();
const orgQ = new IDPOwnerTypeQuery();
orgQ.setOwnerType(IDPOwnerType.IDP_OWNER_TYPE_ORG);
orgQuery.setOwnerTypeQuery(orgQ);
this.mgmtService.listOrgIDPs(undefined, undefined, [orgQuery]).then(resp => {
this.availableIdps = resp.resultList;
}).catch(error => {
this.availableIdps = [];
this.toast.showError(error);
});
break;
case IDPOwnerType.IDP_OWNER_TYPE_SYSTEM:
const iamQuery = new IDPQuery();
const iamQ = new IDPOwnerTypeQuery();
iamQ.setOwnerType(IDPOwnerType.IDP_OWNER_TYPE_SYSTEM);
iamQuery.setOwnerTypeQuery(iamQ);
this.mgmtService.listOrgIDPs(undefined, undefined, [iamQuery]).then(resp => {
this.availableIdps = resp.resultList;
}).catch(error => {
this.availableIdps = [];
this.toast.showError(error);
});
break;
}
}
public closeDialog(): void {
this.dialogRef.close(false);
}
public closeDialogWithSuccess(): void {
this.dialogRef.close({
idp: this.idp,
type: this.idpType,
});
}
}

View File

@@ -177,7 +177,7 @@
<div class="idps">
<div class="idp"
[ngClass]="{'disabled': disabled || (serviceType == PolicyComponentServiceType.MGMT && (['login_policy.idp'] | hasFeature | async) == false)}"
[ngClass]="{'disabled': (disabled || (serviceType == PolicyComponentServiceType.MGMT && (['login_policy.idp'] | hasFeature | async) == false))}"
*ngFor="let idp of idps">
<button
[disabled]="disabled || (serviceType == PolicyComponentServiceType.MGMT && (['login_policy.idp'] | hasFeature | async) == false)"
@@ -206,13 +206,7 @@
<ng-template appHasRole [appHasRole]="['org.idp.read']">
<app-card title="{{ 'IDP.LIST.TITLE' | translate }}" description="{{ 'IDP.LIST.DESCRIPTION' | translate }}"
[expanded]="false">
<div card-actions>
<i class="lab la-google"></i>
<i class="lab la-facebook"></i>
<i class="lab la-apple"></i>
<i class="lab la-github"></i>
<i class="lab la-gitlab"></i>
</div>
<app-idp-table [service]="service" [serviceType]="serviceType"
[disabled]="([serviceType == PolicyComponentServiceType.ADMIN ? 'iam.idp.write' : serviceType == PolicyComponentServiceType.MGMT ? 'org.idp.write' : ''] | hasRole | async) == false || ((serviceType == PolicyComponentServiceType.MGMT && (['login_policy.idp'] | hasFeature | async) == false))">
</app-idp-table>

View File

@@ -77,7 +77,6 @@
padding: 10px;
border: 1px solid var(--grey);
border-radius: .5rem;
cursor: pointer;
position: relative;
min-height: 70px;
min-width: 150px;
@@ -106,6 +105,8 @@
}
&:not(.disabled) {
cursor: default;
&:hover {
.rm {
display: block;
@@ -119,6 +120,10 @@
object-fit: scale-down;
}
}
.new-idp:not(.disabled) {
cursor: pointer;
}
}
.divider {