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

[DOCS] Updates for API usage #51989

Merged
merged 6 commits into from
Dec 16, 2019
Merged

Conversation

KOTungseth
Copy link
Contributor

@KOTungseth KOTungseth commented Dec 2, 2019

Summary

Replaces #38107. @dcode, I was unable to push to your branch, so I created a new PR.

Closes part of #19553.

Here is the original summary:

While trying to use the Kibana API for programmatically creating Spaces, I ran across an issue when using the examples and specifying the color that I pulled from the Kibana UI to manage spaces. Namely, the UI presents hex color codes in all caps, while the API only accepts lower case hex. Secondly, there's no documentation (that I could find) that specified that both the kbn-xsrf and Content-Type headers are required.

[skip ci]

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)

For maintainers

@KOTungseth KOTungseth added review Team:Docs v7.0.0 Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Security/Spaces Platform Security - Spaces feature v7.1.0 v7.3.0 v7.4.0 v7.5.0 labels Dec 2, 2019
@KOTungseth KOTungseth self-assigned this Dec 2, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-docs (Team:Docs)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@KOTungseth KOTungseth added the release_note:skip Skip the PR/issue when compiling release notes label Dec 2, 2019
docs/api/using-api.asciidoc Outdated Show resolved Hide resolved
docs/api/using-api.asciidoc Outdated Show resolved Hide resolved
docs/setup/settings.asciidoc Outdated Show resolved Hide resolved
@legrego
Copy link
Member

legrego commented Dec 3, 2019

Namely, the UI presents hex color codes in all caps, while the API only accepts lower case hex

This limitation/bug was fixed in #43470, and was released with 7.3.2

Secondly, there's no documentation (that I could find) that specified that both the kbn-xsrf and Content-Type headers are required.

kbn-xsrf is required by default for API calls, unless:

  1. The call is a GET or HEAD request
  2. or the path is explicitly whitelisted via server.xsrf.whitelist
  3. or XSRF protections are explicitly disabled via server.xsrf.disableProtection (we don't recommend this either)

Instructions on how to whitelist API endpoints for server.xsrf.whitelist

Example whitelist setting:

Note: We don't recommend disabling protections for arbitrary API endpoints. We want to encourage users to supply the kbn-xsrf header instead of whitelisting endpoints whenever possible. There are some scenarios where whitelisting is required, however, such as SAML and OIDC setups

server.xsrf.whitelist: ["/api/security/v1/oidc", "/api/spaces/space"]

An example that uses request headers

Would something like this be helpful?

curl -X POST \
  http://localhost:5601/api/spaces/space \
  -H 'Content-Type: application/json' \
  -H 'kbn-xsrf: true' \
  -d '{
	"id": "sales",
	"name": "Sales",
	"description": "This is your Sales Space!",
	"disabledFeatures": []
}
'

docs/api/using-api.asciidoc Outdated Show resolved Hide resolved
docs/api/using-api.asciidoc Outdated Show resolved Hide resolved
docs/setup/settings.asciidoc Show resolved Hide resolved
KOTungseth added a commit to KOTungseth/kibana that referenced this pull request Dec 16, 2019
* [DOCS] Updates for API usage

* Changes from Larry

* Update docs/api/using-api.asciidoc

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Comments from Larry

* Comment from Larry
KOTungseth added a commit to KOTungseth/kibana that referenced this pull request Dec 16, 2019
* [DOCS] Updates for API usage

* Changes from Larry

* Update docs/api/using-api.asciidoc

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Comments from Larry

* Comment from Larry
KOTungseth added a commit that referenced this pull request Dec 16, 2019
* [DOCS] Updates for API usage

* Changes from Larry

* Update docs/api/using-api.asciidoc

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Comments from Larry

* Comment from Larry
KOTungseth added a commit that referenced this pull request Dec 16, 2019
* [DOCS] Updates for API usage

* Changes from Larry

* Update docs/api/using-api.asciidoc

Co-Authored-By: Larry Gregory <lgregorydev@gmail.com>

* Comments from Larry

* Comment from Larry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Security/Spaces Platform Security - Spaces feature release_note:skip Skip the PR/issue when compiling release notes review Team:Docs Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants