fix(console): enable metadata by url (#7704)

Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
Elio Bischof 2024-04-05 12:11:29 +02:00 committed by GitHub
parent 2089992d75
commit f5608246d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 10 deletions

View File

@ -237,7 +237,7 @@ export class AppCreateComponent implements OnInit, OnDestroy {
this.samlAppRequest.setMetadataUrl(form.metadataUrl);
}
if (this.samlAppRequest) {
if (this.samlAppRequest && minimalMetadata.length > 0) {
const base64 = Buffer.from(minimalMetadata, 'utf-8').toString('base64');
this.samlAppRequest.setMetadataXml(base64);
}

View File

@ -213,7 +213,14 @@ export class AppDetailComponent implements OnInit, OnDestroy {
metadataXml: [{ value: '', disabled: true }],
});
this.samlForm.valueChanges.subscribe((form) => {
this.samlForm.valueChanges.subscribe(() => {
if (!this.app) {
this.app = new App().toObject();
}
if (!this.app.samlConfig) {
this.app.samlConfig = new SAMLConfig().toObject();
}
let minimalMetadata =
this.entityId?.value && this.acsURL?.value
? `<?xml version="1.0"?>
@ -224,15 +231,15 @@ export class AppDetailComponent implements OnInit, OnDestroy {
</md:EntityDescriptor>`
: '';
if (this.metadataUrl && this.metadataUrl.value.length > 0) {
if (this.app && this.app.samlConfig && this.app.samlConfig.metadataXml) {
this.app.samlConfig.metadataXml = '';
}
}
if (this.app && this.app.samlConfig && this.app.samlConfig.metadataXml && minimalMetadata) {
if (minimalMetadata) {
const base64 = Buffer.from(minimalMetadata, 'utf-8').toString('base64');
this.app.samlConfig.metadataXml = base64;
this.app.samlConfig.metadataUrl = '';
}
if (this.metadataUrl?.value) {
this.app.samlConfig.metadataXml = '';
this.app.samlConfig.metadataUrl = this.metadataUrl?.value;
}
});
}
@ -713,8 +720,10 @@ export class AppDetailComponent implements OnInit, OnDestroy {
req.setProjectId(this.projectId);
req.setAppId(this.app.id);
if (this.app.samlConfig) {
if (this.app.samlConfig?.metadataUrl.length > 0) {
req.setMetadataUrl(this.app.samlConfig?.metadataUrl);
}
if (this.app.samlConfig?.metadataXml.length > 0) {
req.setMetadataXml(this.app.samlConfig?.metadataXml);
}