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

[skip ci] Check point on token provider #25971

Closed
wants to merge 8 commits into from

Conversation

epixa
Copy link
Contributor

@epixa epixa commented Nov 20, 2018

do not merge

I'm pushing this as a testable checkpoint for the new token provider implementation.

Kibana

You will need extra privileges on the internal server user. Either compile Elasticsearch with elastic/elasticsearch#35751 and use the built-in kibana user, or update kibana.yml with a new user that has the kibana_system role plus a new role that grants access to cluster:admin/xpack/security/token/*:

curl -X POST "localhost:9200/_xpack/security/role/moar_kibana_system" --user elastic:changeme -H 'Content-Type: application/json' -d'
{
  "cluster": [
    "cluster:admin/xpack/security/token/*"
  ]
}
'

curl -X POST "localhost:9200/_xpack/security/user/newbana" --user elastic:changeme -H 'Content-Type: application/json' -d'
{
  "password" : "changeme",
  "roles" : [ "kibana_system", "moar_kibana_system" ],
  "full_name" : "New Kibana",
  "email" : "kibana@example.com"
}
'

Then add this to your kibana.yml:

xpack.security.authProviders: [token]

Elasticsearch

If you're not using TLS in your dev install of Elasticsearch, you'll need to manually enable the token service (note, this won't work for production).

xpack.security.authc.token.enabled: true

The default expiration for tokens is like 30 minutes or something, so you'll probably want to make that smaller while playing around with this if you want to verify the session renewal/refresh token logic:

xpack.security.authc.token.timeout: "20s"

@epixa epixa added the WIP Work in progress label Nov 20, 2018
@epixa epixa added the Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! label Nov 20, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security

@epixa
Copy link
Contributor Author

epixa commented Nov 20, 2018

@jkakavas @albertzaharovits This PR includes the functional token provider that'll depend on the token privileges from elastic/elasticsearch#35751.

@epixa
Copy link
Contributor Author

epixa commented Nov 20, 2018

cc @azasypkin

/**
* Utility class that knows how to decorate request with proper Basic authentication headers.
*/
export class BasicCredentials {
Copy link
Contributor Author

@epixa epixa Nov 20, 2018

Choose a reason for hiding this comment

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

Super annoying, but the linter has a rule that disallows accessing static methods on BasicCredentials before it is defined in the same file. Even though it's all static. Dumb.

Anyway, I copied and pasted BasicCredentials without changes to the top of the file so linting would stop failing

@epixa
Copy link
Contributor Author

epixa commented Nov 20, 2018

If anyone wants to give this a whirl or provide any preliminary feedback, please do. It has no tests yet, so it's probably a little buggy, but it should be feature complete. I also haven't yet attempted to use both basic and token providers at the same time.

@epixa
Copy link
Contributor Author

epixa commented Nov 21, 2018

I discovered an unexpected behavior with this change where login attempts (and authorization header handling) are duplicated between token and basic providers when they are both enabled. I propose a solution to this problem by changing the way failures are handled in the authentication flow here: #26040

@epixa
Copy link
Contributor Author

epixa commented Nov 26, 2018

My proposed solution to the unexpected behavior in the auth provider failure logic was accepted, so I'm going to proceed with breaking this down and issuing more bite-sized (and tested) PRs.

I'm thinking in this order:

  1. Change how failure works for providers
  2. Add token APIs for elasticsearch-js
  3. Overhaul login handling for basic provider with new login attempt service
  4. Add token provider

@epixa
Copy link
Contributor Author

epixa commented Dec 13, 2018

The first three PRs are in, and the final PR that introduces the token provider itself is #26997. I'm going to close this prototype PR now.

@epixa epixa closed this Dec 13, 2018
@epixa epixa deleted the token-provider branch December 13, 2018 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants