[KEYCLOAK-1491] SAML Spec compliance. NameIDFormat is optional, AttributeStatement must contain one or more attribute or encryptedattribute statements
This commit is contained in:
parent
aaa83dc19a
commit
facf701897
2 changed files with 8 additions and 2 deletions
|
@ -286,7 +286,8 @@ public class SAMLEndpoint {
|
||||||
|
|
||||||
identity.setUsername(subjectNameID.getValue());
|
identity.setUsername(subjectNameID.getValue());
|
||||||
|
|
||||||
if (subjectNameID.getFormat().toString().equals(JBossSAMLURIConstants.NAMEID_FORMAT_EMAIL.get())) {
|
//SAML Spec 2.2.2 Format is optional
|
||||||
|
if (subjectNameID.getFormat() != null && subjectNameID.getFormat().toString().equals(JBossSAMLURIConstants.NAMEID_FORMAT_EMAIL.get())) {
|
||||||
identity.setEmail(subjectNameID.getValue());
|
identity.setEmail(subjectNameID.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -391,10 +391,15 @@ public class SamlProtocol implements LoginProtocol {
|
||||||
UserSessionModel userSession, ClientSessionModel clientSession) {
|
UserSessionModel userSession, ClientSessionModel clientSession) {
|
||||||
AssertionType assertion = response.getAssertions().get(0).getAssertion();
|
AssertionType assertion = response.getAssertions().get(0).getAssertion();
|
||||||
AttributeStatementType attributeStatement = new AttributeStatementType();
|
AttributeStatementType attributeStatement = new AttributeStatementType();
|
||||||
assertion.addStatement(attributeStatement);
|
|
||||||
for (ProtocolMapperProcessor<SAMLAttributeStatementMapper> processor : attributeStatementMappers) {
|
for (ProtocolMapperProcessor<SAMLAttributeStatementMapper> processor : attributeStatementMappers) {
|
||||||
processor.mapper.transformAttributeStatement(attributeStatement, processor.model, session, userSession, clientSession);
|
processor.mapper.transformAttributeStatement(attributeStatement, processor.model, session, userSession, clientSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SAML Spec 2.7.3 AttributeStatement must contain one or more Attribute or EncryptedAttribute
|
||||||
|
if(attributeStatement.getAttributes().size() > 0) {
|
||||||
|
assertion.addStatement(attributeStatement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseType transformLoginResponse(List<ProtocolMapperProcessor<SAMLLoginResponseMapper>> mappers,
|
public ResponseType transformLoginResponse(List<ProtocolMapperProcessor<SAMLLoginResponseMapper>> mappers,
|
||||||
|
|
Loading…
Reference in a new issue