Skip to content
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

Document SAML APIs #45105

Merged
merged 24 commits into from
Oct 11, 2019
Merged

Document SAML APIs #45105

merged 24 commits into from
Oct 11, 2019

Conversation

jkakavas
Copy link
Member

@jkakavas jkakavas commented Aug 1, 2019

This change adds documentation for the SAML APIs in Elasticsearch
and adds simple instructions on how these APIs can be used to
authenticate a user with SAML by a custom web application other
than Kibana.

Resolves: #40352

This change adds documentation for the SAML APIs in Elasticsearch
and adds simple instructions on how these APIs can be used to
authenticate a user with SAML by a custom web application other
than Kibana.

Resolves: elastic#40352
@jkakavas jkakavas added >docs General docs changes :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v8.0.0 v7.4.0 labels Aug 1, 2019
@jkakavas jkakavas requested review from tvernum and lcawl August 1, 2019 16:47
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs

@jkakavas
Copy link
Member Author

jkakavas commented Aug 1, 2019

@elasticmachine update branch

@jkakavas
Copy link
Member Author

jkakavas commented Aug 2, 2019

@elasticmachine test this please

@jkakavas
Copy link
Member Author

jkakavas commented Aug 2, 2019

java.lang.AssertionError: Failure at [painless/10_basic:109]: watch_record.state didn't match expected value:
            watch_record.state: expected String [executed] but was String [not_executed_already_queued]

@elasticmachine run elasticsearch-ci/2

@jkakavas jkakavas requested a review from tvernum September 12, 2019 09:15
@jkakavas
Copy link
Member Author

@elasticmachine test this please

Copy link
Contributor

@tvernum tvernum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've iterated on this enough times, and it's time to get it out for public consumption.

@jkakavas
Copy link
Member Author

jkakavas commented Oct 7, 2019

@lcawl is this ok to merge from your perspective too ?

@@ -853,3 +853,171 @@ A conscious effort has been made to mask this complexity with sane defaults and
documentation above but in case you encounter issues while configuring a SAML realm, you can
look through our {stack-ov}/trb-security-saml.html[SAML troubleshooting documentation] that has
suggestions and resolutions for common issues.

=== SAML without {kib}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't specify an anchor here, our build makes one up, which is not reliable. I suggest:

Suggested change
=== SAML without {kib}
[[saml-no-kibana]]
=== SAML without {kib}

for subsequent calls to {es}. The refresh token enables the user to get new {es}
access tokens after the current one expires.

==== SAML realm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, we should have an anchor here too. Otherwise, it is currently defaulting to "_saml_realm". For example:

Suggested change
==== SAML realm
[[saml-no-kibana-realm]]
==== SAML realm

You must create a SAML realm and configure it accordingly
in {es}. See <<saml-guide-authentication>>

==== Service Account user for accessing the APIs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, this is defaulting to "_service_account_user_for_accessing_the_apis" for an anchor. I suggest explicitly setting it to something like this:

Suggested change
==== Service Account user for accessing the APIs
[[saml-no-kibana-user]]
==== Service Account user for accessing the APIs

Response for that user, you can call the Authenticate API `/_security/_authenticate/` using the access token as a `Bearer` token
and the SAML attribute values will be contained in the response as part of the <<saml-user-metadata>>.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section's URL defaults to "_handling_the_idp_initiated_authentication_flow", so I suggest setting it to something like this:

Suggested change
[[saml-idp-init]]

// CONSOLE
// TEST[skip:handled in IT]

==== Handling the logout flow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section URL defaults to "_handling_the_logout_flow", I suggest something like this:

Suggested change
==== Handling the logout flow
[[saml-logout]]
==== Handling the logout flow

Submits a SAML `Response` message to {es} for consumption.

NOTE: This API is intended for use by custom web applications other than {kib}.
If you are using {kib}, see the {stack-ov}/saml-guide.html[SAML guide].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this PR is rebased against master, you'll see that this content is all now in the elasticsearch repo for use in the Elasticsearch Reference, so the URLs should change as follows:

Suggested change
If you are using {kib}, see the {stack-ov}/saml-guide.html[SAML guide].
If you are using {kib}, see the <<saml-guide>>.

as a `Bearer` token for subsequent requests and a refresh token that can be later used to refresh the given
access token as described in {ref}/security-api-get-token.html[get token API].
as a `Bearer` token for subsequent requests and a refresh token that can be later used to refresh the given
access token as described in {ref}/security-api-get-token.html[get token API].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
access token as described in {ref}/security-api-get-token.html[get token API].
access token as described in <<security-api-get-token,get token API>>.

. Make an HTTP POST request to `_security/saml/prepare`, authenticating as
the `saml-service-user` user. Use either the name of the SAML realm in the {es} configuration or the value for
the Assertion Consumer Service URL in the request body.
See the {ref}/security-api-saml-prepare-authentication.html[SAML prepare authentication API] for more details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
See the {ref}/security-api-saml-prepare-authentication.html[SAML prepare authentication API] for more details.
See the <<security-api-saml-prepare-authentication,SAML prepare authentication API>> for more details.

`_security/saml/authenticate` API. It must authenticate as the `saml-service-user` user and pass
the Base64 encoded SAML Response that was sent as the body of the request. It must also pass the value for `id` that it had saved in the user's session previously.
+
See {ref}/security-api-saml-authenticate.html[SAML authenticate API] for more details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
See {ref}/security-api-saml-authenticate.html[SAML authenticate API] for more details.
See <<security-api-saml-authenticate,SAML authenticate API>> for more details.

+
Elasticsearch will validate this and if all is correct will respond with an access token that can be used
as a `Bearer` token for subsequent requests. It also supplies a refresh token that can be later used to refresh the given
access token as described in {ref}/security-api-get-token.html[get token API].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
access token as described in {ref}/security-api-get-token.html[get token API].
access token as described in <<security-api-get-token,get token API>>.


==== Handling the logout flow
. At some point, if necessary, the custom web application can log the user out by using the
{ref}/security-api-saml-logout.html[SAML logout API] and passing the access token and refresh token as parameters. For example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ref}/security-api-saml-logout.html[SAML logout API] and passing the access token and refresh token as parameters. For example:
<<security-api-saml-logout,SAML logout API>> and passing the access token and refresh token as parameters. For example:

. Alternatively, the IdP might initiate the Single Logout flow at some point. In order to handle this,
the Logout URL (`sp.logout`) needs to be handled by the custom web app. The query part of the URL that the
user will be redirected to will contain a SAML Logout request and this query part needs to be relayed to {es}
using the {ref}/security-api-saml-invalidate.html[SAML invalidate API]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using the {ref}/security-api-saml-invalidate.html[SAML invalidate API]
using the <<security-api-saml-invalidate,SAML invalidate API>>

@jkakavas jkakavas merged commit f68b036 into elastic:master Oct 11, 2019
jkakavas added a commit to jkakavas/elasticsearch that referenced this pull request Oct 11, 2019
* Document SAML APIs

This change adds documentation for the SAML APIs in Elasticsearch
and adds simple instructions on how these APIs can be used to
authenticate a user with SAML by a custom web application other
than Kibana.

Resolves: elastic#40352

* typo

* fix links

* fix more links

* [DOCS] Fixes broken link

* Add metadata file with shorter names for docs, fix typos and mute tests

* [DOCS] Reformats the SAML APIs to match API template

* Apply suggestions from code review

Co-Authored-By: Lisa Cawley <[email protected]>

* Address feedback and add small section on IdP-initiated SSO handling

* address feedback

* moar feedback

* Clarifications and addressing feedback

* properly resolve conflicts

* address feedback

* fix doc links

* minor fixes

* Fix reference
jkakavas added a commit that referenced this pull request Oct 11, 2019
This change adds documentation for the SAML APIs in Elasticsearch
and adds simple instructions on how these APIs can be used to
authenticate a user with SAML by a custom web application other
than Kibana.

Resolves: #40352
howardhuanghua pushed a commit to TencentCloudES/elasticsearch that referenced this pull request Oct 14, 2019
* Document SAML APIs

This change adds documentation for the SAML APIs in Elasticsearch
and adds simple instructions on how these APIs can be used to
authenticate a user with SAML by a custom web application other
than Kibana.

Resolves: elastic#40352

* typo

* fix links

* fix more links

* [DOCS] Fixes broken link

* Add metadata file with shorter names for docs, fix typos and mute tests

* [DOCS] Reformats the SAML APIs to match API template

* Apply suggestions from code review

Co-Authored-By: Lisa Cawley <[email protected]>

* Address feedback and add small section on IdP-initiated SSO handling

* address feedback

* moar feedback

* Clarifications and addressing feedback

* properly resolve conflicts

* address feedback

* fix doc links

* minor fixes

* Fix reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>docs General docs changes :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v7.5.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document SAML APIs
6 participants