-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add error message in JSON response #54389
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
Conversation
When the SAML authentication is not successful, we return a SAML Respnonse with a status that indicates a failure. This commit adds an error message in the REST API response along with the SAML Response XML string so that the caller of the API can identify that this is an unsuccessful response without needing to parse the XML.
Pinging @elastic/es-security (:Security/Security) |
@elasticmachine update branch |
@@ -65,6 +65,7 @@ public RestResponse buildResponse(SamlInitiateSingleSignOnResponse response, XCo | |||
builder.startObject(); | |||
builder.field("post_url", response.getPostUrl()); | |||
builder.field("saml_response", response.getSamlResponse()); | |||
builder.field("error", response.getError()); |
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.
Is the contract that if error
is null
then it's a success and if it's non-null then there's a failure?
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.
yes. I contemplated adding a boolean isSuccess
field but felt like this extra check wouldn't make much sense on the consumer side but I don't feel strongly about it if you think it makes this clearer/easier to consume.
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.
It feels a little weird, but I can't think of anything better, unless we add the saml status as well.
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 ended up doing just that after all
… into return-error-init
ping @tvernum in case you want to take another look since I also cleaned up the SamlAuthenticationState and added a field to the response as we talked about |
When the SAML authentication is not successful, we return a SAML Response with a status that indicates a failure. This commit adds an error message in the REST API response along with the SAML Response XML string so that the caller of the API can identify that this is an unsuccessful response without needing to parse the XML.
backport to 7.7 depends on #54553 being merged |
When the SAML authentication is not successful, we return a SAML Response with a status that indicates a failure. This commit adds an error message in the REST API response along with the SAML Response XML string so that the caller of the API can identify that this is an unsuccessful response without needing to parse the XML.
When the SAML authentication is not successful, we return a SAML Response with a status that indicates a failure. This commit adds an error message in the REST API response along with the SAML Response XML string so that the caller of the API can identify that this is an unsuccessful response without needing to parse the XML.
When the SAML authentication is not successful, we return a SAML Response with a status that indicates a failure. This commit adds an error message in the REST API response along with the SAML Response XML string so that the caller of the API can identify that this is an unsuccessful response without needing to parse the XML.
When the SAML authentication is not successful, we return a SAML
Response with a status that indicates a failure. This commit adds
an error message in the REST API response along with the SAML
Response XML string so that the caller of the API can identify
that this is an unsuccessful response without needing to parse the
XML.