Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isValidXml is somethings _a lot_ slow #552

Open
realtebo opened this issue Nov 11, 2024 · 0 comments
Open

isValidXml is somethings _a lot_ slow #552

realtebo opened this issue Nov 11, 2024 · 0 comments

Comments

@realtebo
Copy link

realtebo commented Nov 11, 2024

I'm using

"samlify": "^2.8.11"

I'm on AWS lambda environment

In an handler, I an using a controller class to handle login request's from an SP that is using my own implementation as Identity Providers

private readonly _idp: samlify.IdentityProviderInstance

In the constructor I initialize _idp

this._idp = samlify.IdentityProvider({
        wantAuthnRequestsSigned: true,
        privateKey: fs.readFileSync(IdpConfig.PrivateKeyFilePath), // in .pem format
        metadata: this._getRawMetadataXml(), // metadata in xml format
        isAssertionEncrypted: false,
        loginResponseTemplate: {
            context: IdpConfig.IdpResponseTemplate,
            attributes: params.attributes,
        },
    })

then I parse login request

    const request = await this._idp.parseLoginRequest(params.sp, params.binding, params.request)

The binding is always redirect

The code is working at 100%, even at high request rate . Very high.
The problem is that sometimes this (the previous) row takes litterally 20 seconds.

We gave 2GB of memory to lambda, without any changes; it's a bit faster, but when this happen, this parse requires 15-20 seconds anyway.

We are able to reproduce 'sometimes' the error using legit requests. And, with same request code, sometimes it happens, rarely but enough to be noticed by our customer.

We deeped dive into your code until 'isValidXml' call. This is the exact call that sometimes is so slow.

=> https://github.com/tngan/samlify/blob/master/src/flow.ts#L74

I am pretty sure it's not a bug of your code, but I cannot imagine what can happens that the SAME request is SOMETIMES requiring 20 seconds to be parsed.

How is isValidXml() working? what does it do? Does it require storage space?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant