Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth committed Apr 14, 2022
1 parent 0a87965 commit 029eba3
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/saml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class SAML {
throw new TypeError("SamlOptions required on construction");
}

assertRequired(ctorOptions.issuer, "issuer is required");
assertRequired(ctorOptions.cert, "cert is required");

const options: SamlOptions = {
Expand All @@ -147,7 +148,7 @@ class SAML {
maxAssertionAgeMs: ctorOptions.maxAssertionAgeMs ?? 0,
path: ctorOptions.path ?? "/saml/consume",
host: ctorOptions.host ?? "localhost",
issuer: ctorOptions.issuer ?? "onelogin_saml",
issuer: ctorOptions.issuer,
audience: ctorOptions.audience ?? ctorOptions.issuer ?? "unknown_audience", // use issuer as default
identifierFormat:
ctorOptions.identifierFormat === undefined
Expand Down
2 changes: 2 additions & 0 deletions test/samlRequest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe("SAML request", function () {
},
},
},
issuer: "onesaml_login",
};

const result = {
Expand Down Expand Up @@ -112,6 +113,7 @@ describe("SAML request", function () {
entryPoint: "https://wwwexampleIdp.com/saml",
cert: FAKE_CERT,
samlAuthnRequestExtensions: "anyvalue",
issuer: "onesaml_login",
};

const oSAML = new SAML(config);
Expand Down
1 change: 1 addition & 0 deletions test/samlTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("SAML.js", function () {
entryPoint: "https://exampleidp.com/path?key=value",
logoutUrl: "https://exampleidp.com/path?key=value",
cert: FAKE_CERT,
issuer: "onesaml_login",
});
req = {
protocol: "https",
Expand Down
6 changes: 5 additions & 1 deletion test/test-signatures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Signatures", function () {
samlResponseBody: Record<string, string>,
shouldErrorWith: string | false | undefined,
amountOfSignatureChecks = 1,
options: Partial<SamlConfig> = {}
options: Partial<SamlConfig> = { issuer: "onesaml_login" }
) => {
//== Instantiate new instance before every test
const samlObj = new SAML({ cert, ...options });
Expand Down Expand Up @@ -88,6 +88,7 @@ describe("Signatures", function () {
"R1A - root signed - wantAssertionsSigned=true => error",
testOneResponse("/valid/response.root-signed.assertion-unsigned.xml", INVALID_SIGNATURE, 2, {
wantAssertionsSigned: true,
issuer: "onesaml_login",
})
);
it(
Expand All @@ -99,6 +100,7 @@ describe("Signatures", function () {
{
decryptionPvk: fs.readFileSync(__dirname + "/static/testshib encryption pvk.pem"),
wantAssertionsSigned: true,
issuer: "onesaml_login",
}
)
);
Expand All @@ -110,6 +112,7 @@ describe("Signatures", function () {
2,
{
wantAssertionsSigned: true,
issuer: "onesaml_login",
}
)
);
Expand All @@ -122,6 +125,7 @@ describe("Signatures", function () {
{
decryptionPvk: fs.readFileSync(__dirname + "/static/testshib encryption pvk.pem"),
wantAssertionsSigned: true,
issuer: "onesaml_login",
}
)
);
Expand Down
Loading

0 comments on commit 029eba3

Please sign in to comment.