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

[DBPW 5/5] Use AutoMTLS with DB plugins #10008

Merged
merged 5 commits into from
Sep 23, 2020
Merged

[DBPW 5/5] Use AutoMTLS with DB plugins #10008

merged 5 commits into from
Sep 23, 2020

Conversation

pcman312
Copy link
Contributor

Overview

This PR is part of a larger feature adding support for password policies into the combined database engine. This feature is being split into multiple PRs to make for smaller reviews & earlier feedback.

Uses go-plugin's AutoMTLS feature for DB v5 plugins. This adds a new function RunConfig to the pluginutil package alongside Run and RunMetadataMode. This function follows the functional options pattern which will allow us to specify future changes to the RunConfig function (such as allowing the user to configure other fields) without actually changing the function signature.

Related PRs

Original password policies PR
1/X - Database interface & gRPC
2/X - Middleware
3/X - Plugin management
4/X - DB engine

cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", PluginMetadataModeEnv, "false"))

// Get a CA TLS Certificate
certBytes, key, err := generateCert()
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 want to avoid creating these certs and then response wrapping them if we are using AutoMTLS, right?

Copy link
Contributor Author

@pcman312 pcman312 Sep 21, 2020

Choose a reason for hiding this comment

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

It doesn't seem to make a difference in terms of using the plugin (i.e. it doesn't seem to break any of my tests). I can certainly make this conditional but I defer that decision that knows go-plugin better than I do.

For what it's worth, this is a copy-paste of the previous runCommon function, so nothing is changed here other than AutoMTLS and how it gets its values.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/hashicorp/go-plugin/blob/4c2f0639bfb69d99f6f21b350e87639b4df32df2/client.go#L184-L205

The client should not set TLSConfig, nor should the server set a TLSProvider, because AutoMTLS implies that a new certificate and tls configuration will be generated at startup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I also included some tests around the ClientConfig creation.

Copy link
Contributor

@briankassouf briankassouf left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@pcman312 pcman312 merged commit 32c3a9e into master Sep 23, 2020
@pcman312 pcman312 deleted the dbpw-05-automtls branch September 23, 2020 22:08
}
}

func (r *PluginRunner) RunConfig(ctx context.Context, opts ...RunOpt) (*plugin.Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This might have been derived from the runCommon terminology and to keep things as close as it was before, but it's really creating a plugin client so something like NewPluginClient would be more appropriate.

return client, nil
}

type RunOpt func(*runConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can we rename this to RunnerOpt or Options (or ClientOpt, see below)? "Run" makes it sound like this is some sort of execution func, especially since this is a typed function.

@pcman312 pcman312 changed the title [DBPW 5/X] Use AutoMTLS with DB plugins [DBPW 5/5] Use AutoMTLS with DB plugins Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants