Skip to content

[BUG] validateInResponseTo = true does not validate responses #874

Open
@adamandreasson

Description

@adamandreasson

Found out that the responseTo was not being validated despite setting validateInResponseTo to true in the config. After some digging around, turns out setting validateInResponseTo to a truthy value is not enough. node-saml expects one of the valid values "never", "ifPresent", or "always". We tried setting it to "always" and now responses are actually validated properly.

I checked @node-saml/node-saml/lib/saml.js and found this method

    mustValidateInResponseTo(hasInResponseTo) {
        return (this.options.validateInResponseTo === types_1.ValidateInResponseTo.always ||
            (this.options.validateInResponseTo === types_1.ValidateInResponseTo.ifPresent && hasInResponseTo));
    }

Commit that changed behaviour in dependency: node-saml/node-saml@496c54e

To Reproduce
Follow the guide in the Readme and setup a basic auth. We noticed that responseTo was not being validated when we were setting up the cacheProvider and saw that it was never used, so that's one way to verify it without testing custom responses.

Expected behavior
Either validateInResponseTo = true should be equivalent to setting it to "always" or the documentation needs to be updated to reflect the values that are actually valid

Environment

  • Node.js version: 16.14.2
  • passport-saml version: 4.0.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions