-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
src/utils/middleware.ts
Outdated
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) | ||
]) | ||
}) | ||
]); |
There was a problem hiding this comment.
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:
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 | |
}) | |
]); |
src/utils/__tests__/saml.test.ts
Outdated
)(samlRequest) | ||
.fold( | ||
err => fail(err), | ||
_ => expect(_).not.toContain("<spid:Purpose>P</spid:Purpose>") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/utils/saml.ts
Outdated
@@ -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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SAML_EXTENSION = "https://spid.gov.it/saml‐extensions"; | |
const SPID_SAML_EXTENSION = "https://spid.gov.it/saml‐extensions"; |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This PR provides support for professional SPID saml extension