Skip to content

Commit

Permalink
Merge branch 'feature-SAML-14_overhaul' into release-6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Mar 7, 2024
2 parents f2b6a02 + 0108574 commit 59393c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 4 additions & 1 deletion handlers/Saml2.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,17 @@ component {
var xmlPresent = Len( samlResponse.samlXml ?: "" ) > 0;
var entityFound = StructKeyExists( samlResponse, "issuerentity" ) && !IsEmpty( samlResponse.issuerEntity );
var requestTypePresent = Len( samlResponse.samlResponse.type ?: "" ) > 0;
var totallyBadRequest = !xmlPresent || !entityFound || !requestTypePresent;
var hasError = Len( samlResponse.error ?: "" ) > 0;
var totallyBadRequest = !xmlPresent || !entityFound || !requestTypePresent || hasError;

if ( !xmlPresent ) {
debugInfo.failureReason = "noxml";
} else if ( !entityFound ) {
debugInfo.failureReason = "entitynotfound";
} else if ( !requestTypePresent ) {
debugInfo.failureReason = "noresponsetype";
} else if ( hasError ) {
debugInfo.failureReason = samlResponse.error;
}
} catch( any e ) {
logError( e );
Expand Down
3 changes: 2 additions & 1 deletion helpers/saml2SsoHelpers.cfm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<cfscript>
function formatX509Certificate( required string raw ) {
var x509cert = "-----BEGIN CERTIFICATE-----" & Chr( 10 );
var stripped = ReReplace( arguments.raw, "[\s\n]", "", "all" );
var stripped = arguments.raw;
stripped = Replace( stripped, "-----BEGIN CERTIFICATE-----", "" );
stripped = Replace( stripped, "-----END CERTIFICATE-----", "" );
stripped = ReReplace( stripped, "[\s\n]", "", "all" );
for( var i=1; i <= Len( stripped ); i++ ) {
x509cert &= stripped[i];
Expand Down
9 changes: 3 additions & 6 deletions services/saml/response/SamlResponseParser.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ component {
samlResponse = parsedResponse.samlXml
, signingCert = parsedResponse.issuerEntity.idpRecord.signing_certificate ?: ""
);
if ( !signaturesValid ) {
throw(
type = "saml2responseparser.invalid.signature"
, message = "The assertion response failed signature validation."
, detail = parsedResponse.samlXml
);

if ( !sigValid ) {
parsedResponse.error = "invalidsignature";
}
}
} catch ( entitypool.missingentity e ) {
Expand Down

0 comments on commit 59393c8

Please sign in to comment.