Skip to content

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

Merged
merged 8 commits into from
Apr 1, 2020
Merged

Conversation

jkakavas
Copy link
Member

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
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.
@jkakavas jkakavas added the :Security/Security Security issues without another label label Mar 29, 2020
@jkakavas jkakavas requested a review from tvernum March 29, 2020 17:18
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (:Security/Security)

@jkakavas
Copy link
Member Author

@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());
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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

@jkakavas jkakavas requested a review from tvernum March 31, 2020 13:26
@jkakavas
Copy link
Member Author

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

@jkakavas jkakavas merged commit d556f87 into elastic:master Apr 1, 2020
jkakavas added a commit to jkakavas/elasticsearch that referenced this pull request Apr 1, 2020
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.
@jkakavas
Copy link
Member Author

jkakavas commented Apr 1, 2020

backport to 7.7 depends on #54553 being merged

jkakavas added a commit that referenced this pull request Apr 1, 2020
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.
jkakavas added a commit to jkakavas/elasticsearch that referenced this pull request Apr 2, 2020
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.
jkakavas added a commit that referenced this pull request Apr 2, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Security/Security Security issues without another label v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants