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

Provide support for professional Spid #72

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AleDore
Copy link
Contributor

@AleDore AleDore commented Apr 26, 2021

This PR provides support for professional SPID saml extension

@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #72 (de65c91) into master (56e2e28) will increase coverage by 2.09%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
+ Coverage   66.26%   68.36%   +2.09%     
==========================================
  Files          11       11              
  Lines         750      765      +15     
  Branches      117      124       +7     
==========================================
+ Hits          497      523      +26     
+ Misses        252      241      -11     
  Partials        1        1              
Impacted Files Coverage Δ
src/config.ts 100.00% <ø> (ø)
src/strategy/spid.ts 37.20% <0.00%> (+0.25%) ⬆️
src/index.ts 64.19% <92.85%> (+4.77%) ⬆️
src/utils/middleware.ts 92.85% <100.00%> (+0.54%) ⬆️
src/utils/saml.ts 61.01% <100.00%> (+2.23%) ⬆️
src/utils/response.ts 45.45% <0.00%> (+9.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a29a77c...de65c91. Read the comment docs.

Comment on lines 22 to 44
export enum ProfessionalPurpose {
P = "P",
PX = "PX",
LP = "LP",
PG = "PG",
PF = "PF"
}

const ProfessionalSpidExtension = t.union([
t.interface({
professionalSpidEnabled: t.literal(false)
}),
t.interface({
professionalSpidEnabled: t.literal(true),
purpose: t.union([
t.literal(ProfessionalPurpose.P),
t.literal(ProfessionalPurpose.PX),
t.literal(ProfessionalPurpose.LP),
t.literal(ProfessionalPurpose.PG),
t.literal(ProfessionalPurpose.PF)
])
})
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to consider every occurrence of ProfessionalPurpose in ProfessionalSpidExtension codec, you can link them by trasforming the first into a string literal union:

Suggested change
export enum ProfessionalPurpose {
P = "P",
PX = "PX",
LP = "LP",
PG = "PG",
PF = "PF"
}
const ProfessionalSpidExtension = t.union([
t.interface({
professionalSpidEnabled: t.literal(false)
}),
t.interface({
professionalSpidEnabled: t.literal(true),
purpose: t.union([
t.literal(ProfessionalPurpose.P),
t.literal(ProfessionalPurpose.PX),
t.literal(ProfessionalPurpose.LP),
t.literal(ProfessionalPurpose.PG),
t.literal(ProfessionalPurpose.PF)
])
})
]);
type ProfessionalPurpose = t.TypeOf<typeof ProfessionalPurpose>;
export const ProfessionalPurpose = t.keyof({
P: null,
PX: null,
LP: null,
PG: null,
PF: null,
});
const ProfessionalSpidExtension = t.union([
t.interface({
professionalSpidEnabled: t.literal(false)
}),
t.interface({
professionalSpidEnabled: t.literal(true),
purpose: ProfessionalPurpose
})
]);

)(samlRequest)
.fold(
err => fail(err),
_ => expect(_).not.toContain("<spid:Purpose>P</spid:Purpose>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd test on a less restrictive pattern, like <spid:Purpose, does it have sense?

@balanza balanza self-requested a review April 26, 2021 10:45
BurnedMarshal
BurnedMarshal previously approved these changes Apr 26, 2021
Copy link
Contributor

@BurnedMarshal BurnedMarshal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -68,6 +68,8 @@ export const SAML_NAMESPACE = {
XMLDSIG: "http://www.w3.org/2000/09/xmldsig#"
};

const SAML_EXTENSION = "https://spid.gov.it/saml‐extensions";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const SAML_EXTENSION = "https://spid.gov.it/saml‐extensions";
const SPID_SAML_EXTENSION = "https://spid.gov.it/saml‐extensions";

@sonarcloud
Copy link

sonarcloud bot commented Jan 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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