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

Send 401 Unauthorized with WWW-Authenticate: Basic header to enable HTTP authentication via URL #7682

Closed
morganchristiansson opened this issue Jul 8, 2016 · 14 comments
Labels
enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@morganchristiansson
Copy link

morganchristiansson commented Jul 8, 2016

We want to display authenticated Kibana dashboards on TV monitors that cycle through URLs to display various dashboards and data.
We've considered a number of different approaches to enable authentication and settled on passing credentials in URL like this: https://user:[email protected]/.

Now this doesn't work because the webserver needs to send HTTP/1.1 401 Unauthorized with WWW-Authenticate: Basic header or the browser won't send its Authorization header.

From reviewing the shield plugin source code I've discovered that Shield accepts credentials via Authorization: header but it's not possible to trigger a 401 Unauthorized with WWW-Authenticate header to make the browser send it.

As such we've implemented a workaround where nginx will respond to requests without Authorization: header:

map $remote_user $realm {
    '' 'Kibana with Shield';
    default off;
}

server {
    ....

    location /shield/ {
        auth_basic $realm;
        auth_basic_user_file /dev/null;

        rewrite              ^/shield/(.*) /$1 break;
        proxy_pass           http://localhost:5602;
        ....
    }
}

This enables authorization with HTTP auth and Kibana will parse the Authorization header correctly and grant access.

It would be great if Kibana with Shield could send this response could be made to return 401 Unauthorized with WWW-Authenticate: Basic header instead of rendering the current ajax based login screen.

@morganchristiansson
Copy link
Author

morganchristiansson commented Jul 8, 2016

Also due to phishing security this approach doesn't work in several browsers, the browser will display a warning or error to alert the user about potential phishing alerts. Some of the browsers can be configured to allow it. See http://kb.mozillazine.org/Network.http.phishy-userpass-length

As such alternative methods of authentication may be needed for other users. For example sending credentials or authentication token through URL parameters would work universally regardless of browser.

For us the Samsung SmartTV builtin browser supports credentials in URL and Firefox can be configured to support it by changing the network.http.phishy-userpass-length setting.

@Bargs
Copy link
Contributor

Bargs commented Jul 8, 2016

@morganchristiansson The Kibana security plugin supports sessions with cookies. What's the disadvantage to logging in via the login form, and relying on the existing session functionality in the Security plugin? Session timeout is configurable if that's the issue: https://www.elastic.co/guide/en/shield/2.3/kibana.html#shield-ui-settings

From reviewing the shield plugin source code I've discovered that Shield accepts credentials via Authorization: header but it's not possible to trigger a 401 Unauthorized with WWW-Authenticate header to make the browser send it.

I don't think we'll ever support credentials passed via the URL. Support for the authorization header mainly exists for programmatic access. In the future, I imagine we'll implement some sort of token based system for API access.

@gmoskovicz
Copy link
Contributor

@Bargs if using ngnix proxy and sending the headers, shouldn't Kibana just pass this headers to Elasticsearch and then authenticate the user?

@Bargs
Copy link
Contributor

Bargs commented Jul 8, 2016

Headers will work, but putting credentials in the URL will not.

@morganchristiansson
Copy link
Author

It's needed to display graphs and dashboards on tv monitors around the office. It is not possible to interactively login on them, so url authentication is needed

@Bargs
Copy link
Contributor

Bargs commented Jul 19, 2016

@lukasolson any thoughts on this? Do we have any alternative that might be helpful?

@lukasolson
Copy link
Member

The simple solution for this case is to disable the shield Kibana plugin. If you're not using the login/logout capabilities, it shouldn't be of much use anyway. And if you disable the plugin, it should fall back to basic auth. Let me know if that helps!

@gmoskovicz
Copy link
Contributor

For this, i guess that it is needed a secondary Kibana instance pointing to the same Elasticsearch cluster. I think that one doesn't want to remove the plugin in the main Kibana instance that people will be logging, right?

@morganchristiansson
Copy link
Author

@gmoskovicz Yeah that solution would be fine. However we already have secondary instance, so this would be tertiary instance. And managing multiple instances is a bit of a hassle.

We now need 3 kibana instances:

  • no-shield login, anonymous access (we want public access within the company)
  • shield authenticated access (we want to allow authenticated access)
  • no-shield, authenticated access (for TV monitors we want to allow public pre-authenticated access)

If configuring multiple Kibana profiles/backend connections from a single instance (like the Marvel plugin supports multiple clusters) then that might work for us.

@lukasolson
Copy link
Member

@Bargs From my understanding, passing the credentials in the url as @morganchristiansson suggested will result in them being passed as basic auth headers in most (if not all) browsers.

@Bargs
Copy link
Contributor

Bargs commented Jul 22, 2016

@lukasolson In the OP @morganchristiansson said this:

We've considered a number of different approaches to enable authentication and settled on passing credentials in URL like this: https://user:[email protected]/.

Now this doesn't work because the webserver needs to send HTTP/1.1 401 Unauthorized with WWW-Authenticate: Basic header or the browser won't send it's Authorization header.

I'm guess this is because we're redirecting to the login page? @morganchristiansson can you confirm that's what's happening? Also, what browser are you using?

@morganchristiansson
Copy link
Author

morganchristiansson commented Jul 25, 2016

There's nowhere in the kibana or shield code where a HTTP/1.1 401 Unauthorized response with a WWW-Authenticate: Basic header is sent, so most/all browsers will refuse to send the Authorization: Basic xxx header with the provided credentials.

If an Authorization header is sent, kibana&shield parses and recognizes it correctly. So my nginx hack to send HTTP/1.1 401 Unauthorized response with a WWW-Authenticate: Basic header when no Authorization header is sent by the browser enabled the browser to attempt authentication with the Authorization: Basic xxx header.

@morganchristiansson
Copy link
Author

A simple solution would be a new login URL.

https://kibana.app/shield/login**-http-auth**?next=%2Fapp%2Fkibana#/disc....

This would then respond with 401 response and WWW-Authenticate header and allow login.

@lukasolson lukasolson changed the title Send 401 Unauthorized with WWW-Authenticate: Basic header to enable HTTP authentication Send 401 Unauthorized with WWW-Authenticate: Basic header to enable HTTP authentication via URL Jul 25, 2016
@chrisronline chrisronline added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc and removed :Management labels Oct 31, 2017
@epixa
Copy link
Contributor

epixa commented Apr 2, 2018

I'm going to close this because current versions of X-Pack security should handle basic auth by default. Feel free to drop a comment here if the issue is still present.

@epixa epixa closed this as completed Apr 2, 2018
@epixa epixa added enhancement New value added to drive a business result and removed release_note:enhancement labels May 7, 2018
cee-chen added a commit that referenced this issue Jun 18, 2024
`v94.6.0` ⏩ `v95.0.0-backport.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

##
[`v95.0.0-backport.0`](https://github.com/elastic/eui/releases/v95.0.0-backport.0)

**This is a backport release only intended for use by Kibana.**

- Updated `EuiSteps` to support a new `titleSize="xxs"` style, which
outputs the same title font size but smaller unnumbered step indicators
([#7813](elastic/eui#7813))
- Updated `EuiStepsHorizontal` to support a new `size="xs"` style, which
outputs smaller unnumbered step indicators
([#7813](elastic/eui#7813))
- Updated `EuiStepNumber` to support new `titleSize="none"` which omits
rendering step numbers, and will only render icons
([#7813](elastic/eui#7813))

## [`v95.0.0`](https://github.com/elastic/eui/releases/v95.0.0)

- Added `move` glyph to `EuiIcon`
([#7789](elastic/eui#7789))
- Updated `EuiBasicTable` and `EuiInMemoryTable`s with `selection` - the
header row checkbox will now render an indeterminate state if some (but
not all) rows are selected
([#7817](elastic/eui#7817))

**Bug fixes**

- Fixed an `EuiDataGrid` visual bug when using `lineCount` row heights
where the clamped text was still visible for some font sizes
([#7793](elastic/eui#7793))
- Fixed `EuiSearchBar`'s filter configs to always respect `autoClose:
false` ([#7806](elastic/eui#7806))

**Breaking changes**

- Removed deprecated `EUI_CHARTS_THEME_DARK`, `EUI_CHARTS_THEME_LIGHT`
and `EUI_SPARKLINE_THEME_PARTIAL` exports
([#7682](elastic/eui#7682))
- Removed deprecated `euiPalettePositive` and `euiPaletteNegative`. Use
`euiPaletteGreen` and `euiPaletteRed` instead
([#7808](elastic/eui#7808))
- Removed `type="inList"` from `EuiCheckbox`. Simply omit passing a
`label` prop to render this style of checkbox
([#7814](elastic/eui#7814))
- Removed the unused `compressed` prop from `EuiCheckbox` and
`EuiRadio`. This prop was not doing anything on individual components.
([#7818](elastic/eui#7818))

**CSS-in-JS conversions**

- Converted `EuiCheckboxGroup` to Emotion
([#7818](elastic/eui#7818))
- Converted `EuiRadioGroup` to Emotion
([#7818](elastic/eui#7818))

---------

Co-authored-by: Cee Chen <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Cee Chen <[email protected]>
bhapas pushed a commit to bhapas/kibana that referenced this issue Jun 18, 2024
`v94.6.0` ⏩ `v95.0.0-backport.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

##
[`v95.0.0-backport.0`](https://github.com/elastic/eui/releases/v95.0.0-backport.0)

**This is a backport release only intended for use by Kibana.**

- Updated `EuiSteps` to support a new `titleSize="xxs"` style, which
outputs the same title font size but smaller unnumbered step indicators
([elastic#7813](elastic/eui#7813))
- Updated `EuiStepsHorizontal` to support a new `size="xs"` style, which
outputs smaller unnumbered step indicators
([elastic#7813](elastic/eui#7813))
- Updated `EuiStepNumber` to support new `titleSize="none"` which omits
rendering step numbers, and will only render icons
([elastic#7813](elastic/eui#7813))

## [`v95.0.0`](https://github.com/elastic/eui/releases/v95.0.0)

- Added `move` glyph to `EuiIcon`
([elastic#7789](elastic/eui#7789))
- Updated `EuiBasicTable` and `EuiInMemoryTable`s with `selection` - the
header row checkbox will now render an indeterminate state if some (but
not all) rows are selected
([elastic#7817](elastic/eui#7817))

**Bug fixes**

- Fixed an `EuiDataGrid` visual bug when using `lineCount` row heights
where the clamped text was still visible for some font sizes
([elastic#7793](elastic/eui#7793))
- Fixed `EuiSearchBar`'s filter configs to always respect `autoClose:
false` ([elastic#7806](elastic/eui#7806))

**Breaking changes**

- Removed deprecated `EUI_CHARTS_THEME_DARK`, `EUI_CHARTS_THEME_LIGHT`
and `EUI_SPARKLINE_THEME_PARTIAL` exports
([elastic#7682](elastic/eui#7682))
- Removed deprecated `euiPalettePositive` and `euiPaletteNegative`. Use
`euiPaletteGreen` and `euiPaletteRed` instead
([elastic#7808](elastic/eui#7808))
- Removed `type="inList"` from `EuiCheckbox`. Simply omit passing a
`label` prop to render this style of checkbox
([elastic#7814](elastic/eui#7814))
- Removed the unused `compressed` prop from `EuiCheckbox` and
`EuiRadio`. This prop was not doing anything on individual components.
([elastic#7818](elastic/eui#7818))

**CSS-in-JS conversions**

- Converted `EuiCheckboxGroup` to Emotion
([elastic#7818](elastic/eui#7818))
- Converted `EuiRadioGroup` to Emotion
([elastic#7818](elastic/eui#7818))

---------

Co-authored-by: Cee Chen <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Cee Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

7 participants