mirror of
https://github.com/logto-io/logto.git
synced 2025-04-07 23:01:25 -05:00
fix(core): fix SAML validator setup (#6961)
This commit is contained in:
parent
d2468683c8
commit
b88a07598e
1 changed files with 19 additions and 15 deletions
|
@ -59,21 +59,6 @@ type SamlServiceProviderConfig = {
|
|||
certificate?: string;
|
||||
};
|
||||
|
||||
// Used to check whether xml content is valid in format.
|
||||
saml.setSchemaValidator({
|
||||
validate: async (xmlContent: string) => {
|
||||
try {
|
||||
XMLValidator.validate(xmlContent, {
|
||||
allowBooleanAttributes: true,
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
class SamlApplicationConfig {
|
||||
constructor(private readonly _details: SamlApplicationDetails) {}
|
||||
|
||||
|
@ -140,11 +125,13 @@ export class SamlApplication {
|
|||
|
||||
public get idp(): saml.IdentityProviderInstance {
|
||||
this._idp ||= this.buildSamlIdentityProvider();
|
||||
this.setSchemaValidator();
|
||||
return this._idp;
|
||||
}
|
||||
|
||||
public get sp(): saml.ServiceProviderInstance {
|
||||
this._sp ||= this.buildSamlServiceProvider();
|
||||
this.setSchemaValidator();
|
||||
return this._sp;
|
||||
}
|
||||
|
||||
|
@ -472,6 +459,23 @@ export class SamlApplication {
|
|||
);
|
||||
};
|
||||
|
||||
// Used to check whether xml content is valid in format.
|
||||
private setSchemaValidator() {
|
||||
saml.setSchemaValidator({
|
||||
validate: async (xmlContent: string) => {
|
||||
try {
|
||||
XMLValidator.validate(xmlContent, {
|
||||
allowBooleanAttributes: true,
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private buildIdpConfig(): SamlIdentityProviderConfig {
|
||||
return {
|
||||
entityId: buildSamlIdentityProviderEntityId(this.tenantEndpoint, this.samlApplicationId),
|
||||
|
|
Loading…
Add table
Reference in a new issue