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

[security] Token auth provider #26997

Merged
merged 10 commits into from
Dec 19, 2018
Merged

[security] Token auth provider #26997

merged 10 commits into from
Dec 19, 2018

Conversation

epixa
Copy link
Contributor

@epixa epixa commented Dec 11, 2018

From a user perspective, the token provider behaves similarly to the
basic provider in that it can power the native login experience and can
also be used for API calls via the authorization header (albeit with the
Bearer realm).

From a technical perspective, the token provider deals with
authentication via the token service in Elasticsearch, so while it
handles user credentials in the case of login, a temporary, refreshable
access token is stored in the session cookie instead. This means that
when you log out, not only is the cookie invalidated, but the token
itself cannot be reused.

@epixa epixa added the blocked label Dec 11, 2018
@epixa epixa self-assigned this Dec 11, 2018
@epixa epixa force-pushed the token-auth-provider branch from 35a6b0f to 0f15d2f Compare December 11, 2018 22:46
@elasticmachine

This comment has been minimized.

@epixa

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@epixa epixa force-pushed the token-auth-provider branch from 0f15d2f to ea187b1 Compare December 12, 2018 21:23
@elasticmachine

This comment has been minimized.

@epixa epixa force-pushed the token-auth-provider branch from ea187b1 to 44075e8 Compare December 13, 2018 00:28
@epixa epixa removed the blocked label Dec 13, 2018
@elasticmachine

This comment has been minimized.

From a user perspective, the token provider behaves similarly to the
basic provider in that it can power the native login experience and can
also be used for API calls via the authorization header (albeit with the
Bearer realm).

From a technical perspective, the token provider deals with
authentication via the token service in Elasticsearch, so while it
handles user credentials in the case of login, a temporary, refreshable
access token is stored in the session cookie instead. This means that
when you log out, not only is the cookie invalidated, but the token
itself cannot be reused.
@epixa epixa force-pushed the token-auth-provider branch from 44075e8 to bf191a8 Compare December 13, 2018 17:59
@epixa epixa requested a review from a team as a code owner December 13, 2018 17:59
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@epixa epixa removed their assignment Dec 13, 2018
@epixa epixa added review v7.0.0 Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! enhancement New value added to drive a business result v6.6.0 labels Dec 13, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security

@epixa epixa added release_note:enhancement and removed enhancement New value added to drive a business result labels Dec 13, 2018
Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

The provider is working beautifully! I tested it with SAML enabled as well, and it's working great.

The only concern that I have with the provider is that when using only the token provider, users will find it rather complicated to execute cURL requests against Kibana APIs, and they'll have to authenticate against ES APIs to get a Bearer token to submit, or they'll have to enable the basic provider additionally. I'm not necessarily suggesting that we change this, just noting it to see if you had any thoughts.

@epixa epixa removed the review label Dec 14, 2018
@epixa
Copy link
Contributor Author

epixa commented Dec 14, 2018

The only concern that I have with the provider is that when using only the token provider, users will find it rather complicated to execute cURL requests against Kibana APIs, and they'll have to authenticate against ES APIs to get a Bearer token to submit, or they'll have to enable the basic provider additionally. I'm not necessarily suggesting that we change this, just noting it to see if you had any thoughts.

Realistically the token provider is not something folks will wire together manually for curl requests. They could use the Bearer header for programmatic integrations using the upcoming api token feature that allows for long term api tokens, or they might choose to back some sort of hacked oauth2 setup on top of this provider instead of basic auth.

A configuration of [token, basic] will use the token provider for login/sessions but support either Bearer or Basic headers for API requests, so best of both worlds.

@elasticmachine

This comment has been minimized.

@epixa epixa added v6.7.0 and removed v6.6.0 labels Dec 18, 2018
@epixa
Copy link
Contributor Author

epixa commented Dec 18, 2018

This does not provide an integration test to verify that a expired refresh token results in session invalidation. This would be impractical to test because the refresh window is 24h and it is hardcoded into Elasticsearch. We have unit test coverage for this behavior, so we're assuming the Elasticsearch token service handles the refresh expiration consistently.

@epixa epixa added the review label Dec 18, 2018
@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

LGTM

@epixa epixa merged commit 948932a into elastic:master Dec 19, 2018
@epixa epixa deleted the token-auth-provider branch December 19, 2018 16:13
epixa added a commit to epixa/kibana that referenced this pull request Dec 19, 2018
* [security] Token auth provider

From a user perspective, the token provider behaves similarly to the
basic provider in that it can power the native login experience and can
also be used for API calls via the authorization header (albeit with the
Bearer realm).

From a technical perspective, the token provider deals with
authentication via the token service in Elasticsearch, so while it
handles user credentials in the case of login, a temporary, refreshable
access token is stored in the session cookie instead. This means that
when you log out, not only is the cookie invalidated, but the token
itself cannot be reused.

* token provider integration tests

* include token api integration tests by default

* remove unused ProviderOptions from typedef

* assert that valid login sets an authorization header

* unit tests for refresh token and failure cases

* integration tests for headers and sessions

* clean up login/logout tests for consistent setup functions

* test for header rejection scenarios
epixa added a commit that referenced this pull request Dec 21, 2018
* [security] Token auth provider

From a user perspective, the token provider behaves similarly to the
basic provider in that it can power the native login experience and can
also be used for API calls via the authorization header (albeit with the
Bearer realm).

From a technical perspective, the token provider deals with
authentication via the token service in Elasticsearch, so while it
handles user credentials in the case of login, a temporary, refreshable
access token is stored in the session cookie instead. This means that
when you log out, not only is the cookie invalidated, but the token
itself cannot be reused.

* token provider integration tests

* include token api integration tests by default

* remove unused ProviderOptions from typedef

* assert that valid login sets an authorization header

* unit tests for refresh token and failure cases

* integration tests for headers and sessions

* clean up login/logout tests for consistent setup functions

* test for header rejection scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement review Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v6.7.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants