fix(console): delete provider, refactor add and update methods (#5515)

fix: provider deletion
This commit is contained in:
Max Peintner
2023-03-21 17:48:35 +01:00
committed by GitHub
parent a6c471b2e4
commit 9b41758af0
14 changed files with 425 additions and 840 deletions

View File

@@ -142,31 +142,17 @@ export class IdpTableComponent implements OnInit {
dialogRef.afterClosed().subscribe((resp) => { dialogRef.afterClosed().subscribe((resp) => {
if (resp) { if (resp) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { this.service.deleteProvider(idp.id).then(
(this.service as ManagementService).removeOrgIDP(idp.id).then( () => {
() => { this.toast.showInfo('IDP.TOAST.DELETED', true);
this.toast.showInfo('IDP.TOAST.DELETED', true); setTimeout(() => {
setTimeout(() => { this.refreshPage();
this.refreshPage(); }, 1000);
}, 1000); },
}, (error) => {
(error) => { this.toast.showError(error);
this.toast.showError(error); },
}, );
);
} else {
(this.service as AdminService).removeIDP(idp.id).then(
() => {
this.toast.showInfo('IDP.TOAST.DELETED', true);
setTimeout(() => {
this.refreshPage();
}, 1000);
},
(error) => {
this.toast.showError(error);
},
);
}
} }
}); });
} }

View File

@@ -130,134 +130,77 @@ export class ProviderAzureADComponent {
} }
public addAzureADProvider(): void { public addAzureADProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddAzureADProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddAzureADProviderRequest()
: new AdminAddAzureADProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setEmailVerified(this.emailVerified?.value); req.setEmailVerified(this.emailVerified?.value);
const tenant = new AzureADTenant(); const tenant = new AzureADTenant();
tenant.setTenantId(this.tenantId?.value); tenant.setTenantId(this.tenantId?.value);
tenant.setTenantType(this.tenantType?.value); tenant.setTenantType(this.tenantType?.value);
req.setTenant(tenant); req.setTenant(tenant);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options); req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addAzureADProvider(req) .addAzureADProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.router.navigate(['/org-settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddAzureADProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setClientId(this.clientId?.value); this.toast.showError(error);
req.setClientSecret(this.clientSecret?.value); this.loading = false;
req.setEmailVerified(this.emailVerified?.value); });
const tenant = new AzureADTenant();
tenant.setTenantId(this.tenantId?.value);
tenant.setTenantType(this.tenantType?.value);
req.setTenant(tenant);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.addAzureADProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.router.navigate(['/settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
}
} }
public updateAzureADProvider(): void { public updateAzureADProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateAzureADProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateAzureADProviderRequest()
req.setName(this.name?.value); : new AdminUpdateAzureADProviderRequest();
req.setClientId(this.clientId?.value);
req.setEmailVerified(this.emailVerified?.value);
const tenant = new AzureADTenant(); req.setId(this.provider.id);
req.setName(this.name?.value);
req.setClientId(this.clientId?.value);
req.setEmailVerified(this.emailVerified?.value);
tenant.setTenantId(this.tenantId?.value); const tenant = new AzureADTenant();
tenant.setTenantType(this.tenantType?.value);
req.setTenant(tenant);
req.setScopesList(this.scopesList?.value); tenant.setTenantId(this.tenantId?.value);
req.setProviderOptions(this.options); tenant.setTenantType(this.tenantType?.value);
req.setTenant(tenant);
if (this.updateClientSecret) { req.setScopesList(this.scopesList?.value);
req.setClientSecret(this.clientSecret?.value); req.setProviderOptions(this.options);
}
this.loading = true; if (this.updateClientSecret) {
(this.service as ManagementService) req.setClientSecret(this.clientSecret?.value);
.updateAzureADProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.router.navigate(['/org-settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} else if (PolicyComponentServiceType.ADMIN) {
const req = new AdminUpdateAzureADProviderRequest();
req.setId(this.provider.id);
req.setName(this.name?.value);
req.setClientId(this.clientId?.value);
req.setEmailVerified(this.emailVerified?.value);
const tenant = new AzureADTenant();
tenant.setTenantId(this.tenantId?.value);
tenant.setTenantType(this.tenantType?.value);
req.setTenant(tenant);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as AdminService)
.updateAzureADProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.router.navigate(['/settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
} }
this.loading = true;
this.service
.updateAzureADProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} }
} }

View File

@@ -122,107 +122,62 @@ export class ProviderGithubESComponent {
} }
public addGenericOAuthProvider(): void { public addGenericOAuthProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGitHubEnterpriseServerProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGitHubEnterpriseServerProviderRequest()
: new AdminAddGitHubEnterpriseServerProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); req.setAuthorizationEndpoint(this.authorizationEndpoint?.value);
req.setTokenEndpoint(this.tokenEndpoint?.value); req.setTokenEndpoint(this.tokenEndpoint?.value);
req.setUserEndpoint(this.userEndpoint?.value); req.setUserEndpoint(this.userEndpoint?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGitHubEnterpriseServerProvider(req) .addGitHubEnterpriseServerProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGitHubEnterpriseServerProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); this.toast.showError(error);
req.setTokenEndpoint(this.tokenEndpoint?.value); this.loading = false;
req.setUserEndpoint(this.userEndpoint?.value); });
req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true;
(this.service as AdminService)
.addGitHubEnterpriseServerProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
public updateGenericOAuthProvider(): void { public updateGenericOAuthProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateGitHubEnterpriseServerProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateGitHubEnterpriseServerProviderRequest()
req.setName(this.name?.value); : new AdminUpdateGitHubEnterpriseServerProviderRequest();
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); req.setId(this.provider.id);
req.setTokenEndpoint(this.tokenEndpoint?.value); req.setName(this.name?.value);
req.setUserEndpoint(this.userEndpoint?.value); req.setAuthorizationEndpoint(this.authorizationEndpoint?.value);
req.setClientId(this.clientId?.value); req.setTokenEndpoint(this.tokenEndpoint?.value);
req.setClientSecret(this.clientSecret?.value); req.setUserEndpoint(this.userEndpoint?.value);
req.setScopesList(this.scopesList?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.updateGitHubEnterpriseServerProvider(req) .updateGitHubEnterpriseServerProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminUpdateGitHubEnterpriseServerProviderRequest(); })
req.setId(this.provider.id); .catch((error) => {
req.setName(this.name?.value); this.toast.showError(error);
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); this.loading = false;
req.setTokenEndpoint(this.tokenEndpoint?.value); });
req.setUserEndpoint(this.userEndpoint?.value);
req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true;
(this.service as AdminService)
.updateGitHubEnterpriseServerProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
} }

View File

@@ -119,105 +119,61 @@ export class ProviderGithubComponent {
} }
public addGithubProvider(): void { public addGithubProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGithubProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGithubProviderRequest()
: new AdminAddGithubProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options); req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGitHubProvider(req) .addGitHubProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGithubProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setClientId(this.clientId?.value); this.toast.showError(error);
req.setClientSecret(this.clientSecret?.value); this.loading = false;
req.setScopesList(this.scopesList?.value); });
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.addGitHubProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
}
} }
public updateGithubProvider(): void { public updateGithubProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateGithubProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateGithubProviderRequest()
req.setName(this.name?.value); : new AdminUpdateGithubProviderRequest();
req.setClientId(this.clientId?.value); req.setId(this.provider.id);
req.setScopesList(this.scopesList?.value); req.setName(this.name?.value);
req.setProviderOptions(this.options); req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) { if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as ManagementService)
.updateGitHubProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} else if (PolicyComponentServiceType.ADMIN) {
const req = new AdminUpdateGithubProviderRequest();
req.setId(this.provider.id);
req.setName(this.name?.value);
req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as AdminService)
.updateGitHubProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
} }
this.loading = true;
this.service
.updateGitHubProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} }
} }

View File

@@ -15,6 +15,11 @@
<form [formGroup]="form" (ngSubmit)="submitForm()"> <form [formGroup]="form" (ngSubmit)="submitForm()">
<div class="identity-provider-content"> <div class="identity-provider-content">
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.NAME' | translate }}</cnsl-label>
<input cnslInput formControlName="name" />
</cnsl-form-field>
<cnsl-form-field class="formfield"> <cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.ISSUER' | translate }}</cnsl-label> <cnsl-label>{{ 'IDP.ISSUER' | translate }}</cnsl-label>
<input cnslInput formControlName="issuer" /> <input cnslInput formControlName="issuer" />
@@ -74,12 +79,6 @@
</cnsl-form-field> </cnsl-form-field>
</div> </div>
<cnsl-form-field class="formfield">
<cnsl-label>{{ 'IDP.NAME' | translate }}</cnsl-label>
<input cnslInput formControlName="name" />
<span class="name-hint cnsl-secondary-text" cnslHint>{{ 'IDP.NAMEHINT' | translate }}</span>
</cnsl-form-field>
<cnsl-provider-options <cnsl-provider-options
[initialOptions]="provider?.config?.options" [initialOptions]="provider?.config?.options"
(optionsChanged)="options = $event" (optionsChanged)="options = $event"

View File

@@ -52,7 +52,7 @@ export class ProviderGitlabSelfHostedComponent {
private breadcrumbService: BreadcrumbService, private breadcrumbService: BreadcrumbService,
) { ) {
this.form = new FormGroup({ this.form = new FormGroup({
name: new FormControl('', []), name: new FormControl('', [requiredValidator]),
issuer: new FormControl('', [requiredValidator]), issuer: new FormControl('', [requiredValidator]),
clientId: new FormControl('', [requiredValidator]), clientId: new FormControl('', [requiredValidator]),
clientSecret: new FormControl('', [requiredValidator]), clientSecret: new FormControl('', [requiredValidator]),
@@ -120,109 +120,63 @@ export class ProviderGitlabSelfHostedComponent {
} }
public addGitlabSelfHostedProvider(): void { public addGitlabSelfHostedProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGitLabSelfHostedProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGitLabSelfHostedProviderRequest()
: new AdminAddGitLabSelfHostedProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setIssuer(this.issuer?.value); req.setIssuer(this.issuer?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options); req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGitLabSelfHostedProvider(req) .addGitLabSelfHostedProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGitLabSelfHostedProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setIssuer(this.issuer?.value); this.toast.showError(error);
req.setClientId(this.clientId?.value); this.loading = false;
req.setClientSecret(this.clientSecret?.value); });
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.addGitLabSelfHostedProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
}
} }
public updateGitlabSelfHostedProvider(): void { public updateGitlabSelfHostedProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateGitLabSelfHostedProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateGitLabSelfHostedProviderRequest()
req.setName(this.name?.value); : new AdminUpdateGitLabSelfHostedProviderRequest();
req.setIssuer(this.issuer?.value); req.setId(this.provider.id);
req.setClientId(this.clientId?.value); req.setName(this.name?.value);
req.setScopesList(this.scopesList?.value); req.setIssuer(this.issuer?.value);
req.setProviderOptions(this.options); req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) { if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as ManagementService)
.updateGitLabSelfHostedProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} else if (PolicyComponentServiceType.ADMIN) {
const req = new AdminUpdateGitLabSelfHostedProviderRequest();
req.setId(this.provider.id);
req.setName(this.name?.value);
req.setIssuer(this.issuer?.value);
req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as AdminService)
.updateGitLabSelfHostedProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
} }
this.loading = true;
this.service
.updateGitLabSelfHostedProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} }
} }

View File

@@ -119,105 +119,61 @@ export class ProviderGitlabComponent {
} }
public addGitlabProvider(): void { public addGitlabProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGitLabProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGitLabProviderRequest()
: new AdminAddGitLabProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options); req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGitLabProvider(req) .addGitLabProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGitLabProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setClientId(this.clientId?.value); this.toast.showError(error);
req.setClientSecret(this.clientSecret?.value); this.loading = false;
req.setScopesList(this.scopesList?.value); });
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.addGitLabProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
}
} }
public updateGitlabProvider(): void { public updateGitlabProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateGitLabProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateGitLabProviderRequest()
req.setName(this.name?.value); : new AdminUpdateGitLabProviderRequest();
req.setClientId(this.clientId?.value); req.setId(this.provider.id);
req.setScopesList(this.scopesList?.value); req.setName(this.name?.value);
req.setProviderOptions(this.options); req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) { if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as ManagementService)
.updateGitLabProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} else if (PolicyComponentServiceType.ADMIN) {
const req = new AdminUpdateGitLabProviderRequest();
req.setId(this.provider.id);
req.setName(this.name?.value);
req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options);
if (this.updateClientSecret) {
req.setClientSecret(this.clientSecret?.value);
}
this.loading = true;
(this.service as AdminService)
.updateGoogleProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
} }
this.loading = true;
this.service
.updateGitLabProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
} }
} }

View File

@@ -119,50 +119,30 @@ export class ProviderGoogleComponent {
} }
public addGoogleProvider(): void { public addGoogleProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGoogleProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGoogleProviderRequest()
: new AdminAddGoogleProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
req.setProviderOptions(this.options); req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGoogleProvider(req) .addGoogleProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGoogleProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setClientId(this.clientId?.value); this.toast.showError(error);
req.setClientSecret(this.clientSecret?.value); this.loading = false;
req.setScopesList(this.scopesList?.value); });
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.addGoogleProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.loading = false;
this.toast.showError(error);
});
}
} }
public updateGoogleProvider(): void { public updateGoogleProvider(): void {

View File

@@ -49,7 +49,7 @@
></cnsl-provider-options> ></cnsl-provider-options>
</div> </div>
<div class="jwt-create-actions"> <div class="identity-provider-create-actions">
<button color="primary" mat-raised-button class="continue-button" [disabled]="form.invalid" type="submit"> <button color="primary" mat-raised-button class="continue-button" [disabled]="form.invalid" type="submit">
<span *ngIf="id">{{ 'ACTIONS.SAVE' | translate }}</span> <span *ngIf="id">{{ 'ACTIONS.SAVE' | translate }}</span>
<span *ngIf="!id">{{ 'ACTIONS.CREATE' | translate }}</span> <span *ngIf="!id">{{ 'ACTIONS.CREATE' | translate }}</span>

View File

@@ -117,104 +117,60 @@ export class ProviderJWTComponent {
} }
public addJWTProvider(): void { public addJWTProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddJWTProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddJWTProviderRequest()
: new AdminAddJWTProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setHeaderName(this.headerName?.value); req.setHeaderName(this.headerName?.value);
req.setIssuer(this.issuer?.value); req.setIssuer(this.issuer?.value);
req.setJwtEndpoint(this.jwtEndpoint?.value); req.setJwtEndpoint(this.jwtEndpoint?.value);
req.setKeysEndpoint(this.keysEndpoint?.value); req.setKeysEndpoint(this.keysEndpoint?.value);
req.setProviderOptions(this.options); req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addJWTProvider(req) .addJWTProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddJWTProviderRequest(); })
.catch((error) => {
req.setName(this.name?.value); this.toast.showError(error);
req.setHeaderName(this.headerName?.value); this.loading = false;
req.setIssuer(this.issuer?.value); });
req.setJwtEndpoint(this.jwtEndpoint?.value);
req.setKeysEndpoint(this.keysEndpoint?.value);
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.addJWTProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
public updateJWTProvider(): void { public updateJWTProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateJWTProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateJWTProviderRequest()
req.setName(this.name?.value); : new AdminUpdateJWTProviderRequest();
req.setHeaderName(this.headerName?.value); req.setId(this.provider.id);
req.setIssuer(this.issuer?.value); req.setName(this.name?.value);
req.setJwtEndpoint(this.jwtEndpoint?.value); req.setHeaderName(this.headerName?.value);
req.setKeysEndpoint(this.keysEndpoint?.value); req.setIssuer(this.issuer?.value);
req.setProviderOptions(this.options); req.setJwtEndpoint(this.jwtEndpoint?.value);
req.setKeysEndpoint(this.keysEndpoint?.value);
req.setProviderOptions(this.options);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.updateJWTProvider(req) .updateJWTProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminUpdateJWTProviderRequest(); })
req.setId(this.provider.id); .catch((error) => {
req.setName(this.name?.value); this.toast.showError(error);
req.setHeaderName(this.headerName?.value); this.loading = false;
req.setIssuer(this.issuer?.value); });
req.setJwtEndpoint(this.jwtEndpoint?.value);
req.setKeysEndpoint(this.keysEndpoint?.value);
req.setProviderOptions(this.options);
this.loading = true;
(this.service as AdminService)
.updateJWTProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
} }

View File

@@ -124,111 +124,64 @@ export class ProviderOAuthComponent {
} }
public addGenericOAuthProvider(): void { public addGenericOAuthProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGenericOAuthProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGenericOAuthProviderRequest()
: new AdminAddGenericOAuthProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); req.setAuthorizationEndpoint(this.authorizationEndpoint?.value);
req.setIdAttribute(this.idAttribute?.value); req.setIdAttribute(this.idAttribute?.value);
req.setTokenEndpoint(this.tokenEndpoint?.value); req.setTokenEndpoint(this.tokenEndpoint?.value);
req.setUserEndpoint(this.userEndpoint?.value); req.setUserEndpoint(this.userEndpoint?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGenericOAuthProvider(req) .addGenericOAuthProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.router.navigate(['/org-settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGenericOAuthProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); this.toast.showError(error);
req.setIdAttribute(this.idAttribute?.value); this.loading = false;
req.setTokenEndpoint(this.tokenEndpoint?.value); });
req.setUserEndpoint(this.userEndpoint?.value);
req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true;
(this.service as AdminService)
.addGenericOAuthProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.router.navigate(['/settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
public updateGenericOAuthProvider(): void { public updateGenericOAuthProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateGenericOAuthProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateGenericOAuthProviderRequest()
req.setName(this.name?.value); : new AdminUpdateGenericOAuthProviderRequest();
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); req.setId(this.provider.id);
req.setIdAttribute(this.idAttribute?.value); req.setName(this.name?.value);
req.setTokenEndpoint(this.tokenEndpoint?.value); req.setAuthorizationEndpoint(this.authorizationEndpoint?.value);
req.setUserEndpoint(this.userEndpoint?.value); req.setIdAttribute(this.idAttribute?.value);
req.setClientId(this.clientId?.value); req.setTokenEndpoint(this.tokenEndpoint?.value);
req.setClientSecret(this.clientSecret?.value); req.setUserEndpoint(this.userEndpoint?.value);
req.setScopesList(this.scopesList?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.updateGenericOAuthProvider(req) .updateGenericOAuthProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.router.navigate(['/org-settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminUpdateGenericOAuthProviderRequest(); })
req.setId(this.provider.id); .catch((error) => {
req.setName(this.name?.value); this.toast.showError(error);
req.setAuthorizationEndpoint(this.authorizationEndpoint?.value); this.loading = false;
req.setIdAttribute(this.idAttribute?.value); });
req.setTokenEndpoint(this.tokenEndpoint?.value);
req.setUserEndpoint(this.userEndpoint?.value);
req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true;
(this.service as AdminService)
.updateGenericOAuthProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.router.navigate(['/settings'], { queryParams: { id: 'idp' } });
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
} }

View File

@@ -120,99 +120,58 @@ export class ProviderOIDCComponent {
} }
public addGenericOIDCProvider(): void { public addGenericOIDCProvider(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtAddGenericOIDCProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
? new MgmtAddGenericOIDCProviderRequest()
: new AdminAddGenericOIDCProviderRequest();
req.setName(this.name?.value); req.setName(this.name?.value);
req.setClientId(this.clientId?.value); req.setClientId(this.clientId?.value);
req.setClientSecret(this.clientSecret?.value); req.setClientSecret(this.clientSecret?.value);
req.setIssuer(this.issuer?.value); req.setIssuer(this.issuer?.value);
req.setScopesList(this.scopesList?.value); req.setScopesList(this.scopesList?.value);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.addGenericOIDCProvider(req) .addGenericOIDCProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminAddGenericOIDCProviderRequest(); })
req.setName(this.name?.value); .catch((error) => {
req.setClientId(this.clientId?.value); this.toast.showError(error);
req.setClientSecret(this.clientSecret?.value); this.loading = false;
req.setIssuer(this.issuer?.value); });
req.setScopesList(this.scopesList?.value);
this.loading = true;
(this.service as AdminService)
.addGenericOIDCProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
public updateGenericOIDCProvider(): void { public updateGenericOIDCProvider(): void {
if (this.provider) { if (this.provider) {
if (this.serviceType === PolicyComponentServiceType.MGMT) { const req =
const req = new MgmtUpdateGenericOIDCProviderRequest(); this.serviceType === PolicyComponentServiceType.MGMT
req.setId(this.provider.id); ? new MgmtUpdateGenericOIDCProviderRequest()
req.setName(this.name?.value); : new AdminUpdateGenericOIDCProviderRequest();
req.setClientId(this.clientId?.value); req.setId(this.provider.id);
req.setClientSecret(this.clientSecret?.value); req.setName(this.name?.value);
req.setIssuer(this.issuer?.value); req.setClientId(this.clientId?.value);
req.setScopesList(this.scopesList?.value); req.setClientSecret(this.clientSecret?.value);
req.setIssuer(this.issuer?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true; this.loading = true;
(this.service as ManagementService) this.service
.updateGenericOIDCProvider(req) .updateGenericOIDCProvider(req)
.then((idp) => { .then((idp) => {
setTimeout(() => { setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false; this.loading = false;
}); this.close();
} else if (PolicyComponentServiceType.ADMIN) { }, 2000);
const req = new AdminUpdateGenericOIDCProviderRequest(); })
req.setId(this.provider.id); .catch((error) => {
req.setName(this.name?.value); this.toast.showError(error);
req.setClientId(this.clientId?.value); this.loading = false;
req.setClientSecret(this.clientSecret?.value); });
req.setIssuer(this.issuer?.value);
req.setScopesList(this.scopesList?.value);
this.loading = true;
(this.service as AdminService)
.updateGenericOIDCProvider(req)
.then((idp) => {
setTimeout(() => {
this.loading = false;
this.close();
}, 2000);
})
.catch((error) => {
this.toast.showError(error);
this.loading = false;
});
}
} }
} }

View File

@@ -156,8 +156,6 @@ import {
RemoveIAMMemberResponse, RemoveIAMMemberResponse,
RemoveIDPFromLoginPolicyRequest, RemoveIDPFromLoginPolicyRequest,
RemoveIDPFromLoginPolicyResponse, RemoveIDPFromLoginPolicyResponse,
RemoveIDPRequest,
RemoveIDPResponse,
RemoveLabelPolicyFontRequest, RemoveLabelPolicyFontRequest,
RemoveLabelPolicyFontResponse, RemoveLabelPolicyFontResponse,
RemoveLabelPolicyIconDarkRequest, RemoveLabelPolicyIconDarkRequest,
@@ -898,12 +896,6 @@ export class AdminService {
return this.grpcService.admin.listLoginPolicyIDPs(req, null).then((resp) => resp.toObject()); return this.grpcService.admin.listLoginPolicyIDPs(req, null).then((resp) => resp.toObject());
} }
public removeIDP(id: string): Promise<RemoveIDPResponse.AsObject> {
const req = new RemoveIDPRequest();
req.setIdpId(id);
return this.grpcService.admin.removeIDP(req, null).then((resp) => resp.toObject());
}
public deactivateIDP(id: string): Promise<DeactivateIDPResponse.AsObject> { public deactivateIDP(id: string): Promise<DeactivateIDPResponse.AsObject> {
const req = new DeactivateIDPRequest(); const req = new DeactivateIDPRequest();
req.setIdpId(id); req.setIdpId(id);
@@ -1002,7 +994,9 @@ export class AdminService {
return this.grpcService.admin.updateGitHubEnterpriseServerProvider(req, null).then((resp) => resp.toObject()); return this.grpcService.admin.updateGitHubEnterpriseServerProvider(req, null).then((resp) => resp.toObject());
} }
public deleteProvider(req: DeleteProviderRequest): Promise<DeleteProviderResponse.AsObject> { public deleteProvider(id: string): Promise<DeleteProviderResponse.AsObject> {
const req = new DeleteProviderRequest();
req.setId(id);
return this.grpcService.admin.deleteProvider(req, null).then((resp) => resp.toObject()); return this.grpcService.admin.deleteProvider(req, null).then((resp) => resp.toObject());
} }

View File

@@ -330,8 +330,6 @@ import {
RemoveMultiFactorFromLoginPolicyResponse, RemoveMultiFactorFromLoginPolicyResponse,
RemoveOrgDomainRequest, RemoveOrgDomainRequest,
RemoveOrgDomainResponse, RemoveOrgDomainResponse,
RemoveOrgIDPRequest,
RemoveOrgIDPResponse,
RemoveOrgMemberRequest, RemoveOrgMemberRequest,
RemoveOrgMemberResponse, RemoveOrgMemberResponse,
RemoveOrgMetadataRequest, RemoveOrgMetadataRequest,
@@ -857,12 +855,6 @@ export class ManagementService {
return this.grpcService.mgmt.listLoginPolicyIDPs(req, null).then((resp) => resp.toObject()); return this.grpcService.mgmt.listLoginPolicyIDPs(req, null).then((resp) => resp.toObject());
} }
public removeOrgIDP(idpId: string): Promise<RemoveOrgIDPResponse.AsObject> {
const req = new RemoveOrgIDPRequest();
req.setIdpId(idpId);
return this.grpcService.mgmt.removeOrgIDP(req, null).then((resp) => resp.toObject());
}
public deactivateOrgIDP(idpId: string): Promise<DeactivateOrgIDPResponse.AsObject> { public deactivateOrgIDP(idpId: string): Promise<DeactivateOrgIDPResponse.AsObject> {
const req = new DeactivateOrgIDPRequest(); const req = new DeactivateOrgIDPRequest();
req.setIdpId(idpId); req.setIdpId(idpId);
@@ -961,7 +953,9 @@ export class ManagementService {
return this.grpcService.mgmt.updateGitHubEnterpriseServerProvider(req, null).then((resp) => resp.toObject()); return this.grpcService.mgmt.updateGitHubEnterpriseServerProvider(req, null).then((resp) => resp.toObject());
} }
public deleteProvider(req: DeleteProviderRequest): Promise<DeleteProviderResponse.AsObject> { public deleteProvider(id: string): Promise<DeleteProviderResponse.AsObject> {
const req = new DeleteProviderRequest();
req.setId(id);
return this.grpcService.mgmt.deleteProvider(req, null).then((resp) => resp.toObject()); return this.grpcService.mgmt.deleteProvider(req, null).then((resp) => resp.toObject());
} }