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

Allow optional SSL client authentication setting #6440

Merged

Conversation

rhr323
Copy link
Contributor

@rhr323 rhr323 commented Feb 22, 2023

Elasticsearch supports a few different settings for client authentication settings for https. This PR allows xpack.security.http.ssl.client_authentication to be set to either optional or none, but it will keep emitting an unsupported warning in case it is set to required.

Fixes: #6369

@botelastic botelastic bot added the triage label Feb 22, 2023
@rhr323 rhr323 force-pushed the allow-optional-client-authentication-setting branch from e6c30de to 740e013 Compare February 22, 2023 12:27

func validateClientAuthentication(config *common.CanonicalConfig, index int) field.ErrorList {
type ClientAuthSetting struct {
Value string `config:"xpack.security.http.ssl.client_authentication"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if there is an easier / generic way to access a setting given the key as string, so we don't need to define a struct for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could expose func (c *Config) String(name string, idx int, opts ...Option) (string, error) in the CanonicalConfig wrapper:

func (c *CanonicalConfig) String(name string) (string, error) {
	return c.asUCfg().String(name, -1, Options...)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this resolve path separators correctly ? I.e. xpack.security.http... I don't remember.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it works as expected! I added the wrapper and a few basic test cases.

@rhr323 rhr323 force-pushed the allow-optional-client-authentication-setting branch from 740e013 to e1a26c4 Compare February 22, 2023 12:31
@@ -22,7 +22,6 @@ The following Elasticsearch settings are managed by ECK:
* `xpack.security.authc.reserved_realm.enabled`
* `xpack.security.enabled`
* `xpack.security.http.ssl.certificate`
* `xpack.security.http.ssl.client_authentication`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it's best to leave this our from the list of ECK managed settings, or if we should explain what values are supported / not supported.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably add new section "Partially restricted settings" and say xpack.security.http.ssl.client_authentication (supported values none, optional)

@thbkrkr thbkrkr added the >enhancement Enhancement of existing functionality label Feb 22, 2023
@botelastic botelastic bot removed the triage label Feb 22, 2023
pkg/controller/elasticsearch/validation/warnings_test.go Outdated Show resolved Hide resolved

func validateClientAuthentication(config *common.CanonicalConfig, index int) field.ErrorList {
type ClientAuthSetting struct {
Value string `config:"xpack.security.http.ssl.client_authentication"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could expose func (c *Config) String(name string, idx int, opts ...Option) (string, error) in the CanonicalConfig wrapper:

func (c *CanonicalConfig) String(name string) (string, error) {
	return c.asUCfg().String(name, -1, Options...)
}

pkg/controller/elasticsearch/validation/warnings.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/validation/warnings.go Outdated Show resolved Hide resolved
@rhr323 rhr323 force-pushed the allow-optional-client-authentication-setting branch from e1a17a6 to ff32292 Compare February 23, 2023 08:59
* `xpack.security.http.ssl.enabled`
* `xpack.security.http.ssl.key`
* `xpack.security.transport.ssl.certificate`
* `xpack.security.transport.ssl.enabled`
* `xpack.security.transport.ssl.key`
* `xpack.security.transport.ssl.verification_mode`

The following Elasticsearch settings are not supported by ECK:

* `xpack.security.http.ssl.client_authentication`: `required`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is also good 👍

@thbkrkr thbkrkr added the v2.7.0 label Feb 23, 2023
Copy link
Contributor

@thbkrkr thbkrkr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

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

Nice work!

@rhr323 rhr323 merged commit 70939e0 into elastic:main Feb 23, 2023
@rhr323 rhr323 deleted the allow-optional-client-authentication-setting branch February 23, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v2.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional client authentication should be supported
3 participants