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

Make it possible to use Kibana anonymous authentication provider with ES anonymous access. #84074

Merged
merged 4 commits into from
Dec 2, 2020

Conversation

azasypkin
Copy link
Member

@azasypkin azasypkin commented Nov 23, 2020

This PR makes it possible to use Kibana authentication provider with the Elasticsearch native anonymous access. The gist of the change is that xpack.security.authc.providers.anonymous.<provider-name>.credentials supports third type of credentials: elasticsearch_anonymous_user string literal and provider will not send any Authorization headers to the Elasticsearch in this case.

Setup

  1. Configure anonymous access in Elasticsearch:
xpack.security.authc.anonymous.username: anonymous
xpack.security.authc.anonymous.roles: anonymous
  1. Configure anonymous access in Kibana without specifying any credentials:
xpack.security.authc.providers:
  basic.basic1:
    order: 0
  anonymous.anonymous1:
    order: 1
    credentials: "elasticsearch_anonymous_user"
  1. Log in as a user who has a manage_security privilege and create anonymous role with the privileges you wish anonymous users to have and you're done.

Unresolved questions/issues:

  • It seems reporting doesn't work in this configuration (investigating...) Turned out it wasn't related to this PR

Resolves #35613

@azasypkin azasypkin added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! enhancement New value added to drive a business result Feature:Security/Authentication Platform Security - Authentication release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Nov 23, 2020
@azasypkin azasypkin marked this pull request as ready for review November 25, 2020 09:20
@azasypkin azasypkin requested a review from a team as a code owner November 25, 2020 09:20
@elasticmachine
Copy link
Contributor

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

@legrego legrego self-requested a review November 30, 2020 16:35
@legrego
Copy link
Member

legrego commented Nov 30, 2020

There aren't any concrete requirements listed, but do you think this PR resolves #35613? I think from an end-user perspective it does, but we still run the "risk" of running the Kibana system account as the anonymous user (i.e. not specifying elasticsearch.username or elasticsearch.password).

I don't think this is necessarily a problem, but is potentially something we can surface in a security center or similar in the future.

Copy link
Member

@legrego legrego left a comment

Choose a reason for hiding this comment

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

Haven't tested locally yet, so up to you if you want to respond to feedback now, or wait for me to run this locally (hopefully tomorrow or Wednesday). Thanks for opening this!

Comment on lines 152 to 165
credentials: schema.maybe(
schema.oneOf([
schema.object({
username: schema.string(),
password: schema.string(),
}),
schema.object({
apiKey: schema.oneOf([
schema.object({ id: schema.string(), key: schema.string() }),
schema.string(),
]),
}),
])
),

This comment was marked as resolved.

This comment was marked as resolved.

@@ -164,7 +167,9 @@ export class AnonymousAuthenticationProvider extends BaseAuthenticationProvider
* @param state State value previously stored by the provider.
*/
private async authenticateViaAuthorizationHeader(request: KibanaRequest, state?: unknown) {
const authHeaders = { authorization: this.httpAuthorizationHeader.toString() };
const authHeaders = this.httpAuthorizationHeader
Copy link
Member

Choose a reason for hiding this comment

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

question What do you think about testing for a 401 response in the event that we've attempted to use native anonymous access against a cluster or node that isn't setup for it? We could log a more informative message that way, warning the administrator that their setup isn't configured correctly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but it seems we can/should do that for all types of anonymous authentication (if apiKey isn't valid, if username or password isn't valid and if anonymous access isn't configured)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added for all cases.

@azasypkin
Copy link
Member Author

There aren't any concrete requirements listed, but do you think this PR resolves #35613? I think from an end-user perspective it does, but we still run the "risk" of running the Kibana system account as the anonymous user (i.e. not specifying elasticsearch.username or elasticsearch.password).

Technically yes since Kibana is usable in this configuration now (ES anonymous access + Kibana with enabled security) assuming anonymous roles give enough privileges for Kibana's internal operations. Whether we provide an ideal UX or not is probably a different question and depends on user requirements that we don't have yet 🙂

I don't think this is necessarily a problem, but is potentially something we can surface in a security center or similar in the future.

Yep, agree.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@legrego legrego left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the edits!

@azasypkin azasypkin merged commit 8981d0e into elastic:master Dec 2, 2020
@azasypkin azasypkin deleted the issue-xxx-anonymous-and-es branch December 2, 2020 08:32
azasypkin added a commit to azasypkin/kibana that referenced this pull request Dec 2, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Dec 2, 2020
* master:
  [Lens] Show color in flyout instead of auto (elastic#84532)
  [Lens] Use index pattern through service instead of reading saved object (elastic#84432)
  Make it possible to use Kibana anonymous authentication provider with ES anonymous access. (elastic#84074)
  TelemetryCollectionManager: Use X-Pack strategy as an OSS overwrite (elastic#84477)
  migrate away from rest_total_hits_as_int (elastic#84508)
  [Input Control] Custom renderer (elastic#84423)
  Attempt to more granularly separate App Search vs Workplace Search vs shared GitHub notifications (elastic#84713)
  [Security Solutino][Case] Case connector alert UI (elastic#82405)
  [Maps] Support runtime fields in tooltips (elastic#84377)
  [CCR] Fix row actions in follower index and auto-follow pattern tables (elastic#84433)
  [Enterprise Search] Migrate shared Indexing Status component (elastic#84571)
  [maps] remove fields from index-pattern test artifacts (elastic#84379)
  Add routes for use in Sources Schema (elastic#84579)
  Changes UI links for drilldowns (elastic#83971)
  endpoint telemetry cloned endpoint tests (elastic#81498)
  [Fleet] Handler api key creation errors when Fleet Admin is invalid (elastic#84576)
@azasypkin
Copy link
Member Author

7.x/7.11.0: e7b7641

gmmorris added a commit to gmmorris/kibana that referenced this pull request Dec 2, 2020
* master: (72 commits)
  Make alert status fetching more resilient (elastic#84676)
  [APM] Refactor hooks and context (elastic#84615)
  Added word break styles to the texts in the item details card. (elastic#84654)
  [Search] Disable "send to background" when auto-refresh is enabled (elastic#84106)
  Add readme for new palette service (elastic#84512)
  Make all providers to preserve original URL when session expires. (elastic#84229)
  [Lens] Show color in flyout instead of auto (elastic#84532)
  [Lens] Use index pattern through service instead of reading saved object (elastic#84432)
  Make it possible to use Kibana anonymous authentication provider with ES anonymous access. (elastic#84074)
  TelemetryCollectionManager: Use X-Pack strategy as an OSS overwrite (elastic#84477)
  migrate away from rest_total_hits_as_int (elastic#84508)
  [Input Control] Custom renderer (elastic#84423)
  Attempt to more granularly separate App Search vs Workplace Search vs shared GitHub notifications (elastic#84713)
  [Security Solutino][Case] Case connector alert UI (elastic#82405)
  [Maps] Support runtime fields in tooltips (elastic#84377)
  [CCR] Fix row actions in follower index and auto-follow pattern tables (elastic#84433)
  [Enterprise Search] Migrate shared Indexing Status component (elastic#84571)
  [maps] remove fields from index-pattern test artifacts (elastic#84379)
  Add routes for use in Sources Schema (elastic#84579)
  Changes UI links for drilldowns (elastic#83971)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported enhancement New value added to drive a business result Feature:Security/Authentication Platform Security - Authentication needs_docs release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elasticsearch anonymous access and Kibana
4 participants