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

Add support for client-type ExecCredentials #453

Merged
merged 3 commits into from
Aug 3, 2020
Merged

Add support for client-type ExecCredentials #453

merged 3 commits into from
Aug 3, 2020

Conversation

sczizzo
Copy link
Contributor

@sczizzo sczizzo commented Jul 30, 2020

This library currently supports token-type ExecCredentials, but there is actually another flavor for TLS client auth. With this flavor, the status field includes PEM-encoded clientKeyData and clientCertificateData rather than a token. Reference:

This PR adds support for TLS client auth while maintaining support for token ExecCredentials. To accomplish this, the credentials provided by the status field, regardless of flavor, are passed around as if it were a user.

return if has_client_credentials

has_token = status.key?('token')
raise 'exec plugin didn\'t return a token' unless has_token
Copy link
Collaborator

Choose a reason for hiding this comment

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

At this point, I think you can say it returned neither token nor a client certificate.

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. Also added check to ensure a token XOR client creds are returned.

@@ -142,16 +149,15 @@ def fetch_user_key_data(user)
File.read(ext_file_path(user['client-key']))
elsif user.key?('client-key-data')
Base64.decode64(user['client-key-data'])
elsif user.key?('clientKeyData')
user['clientKeyData']
Copy link
Collaborator

@cben cben Jul 31, 2020

Choose a reason for hiding this comment

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

It's slightly confusing to have 2 similarly named keys, one base64, one not.
Although both spellings come from k8s.

The reuse of user is clever but WDYT of putting it in a sub-field instead?

user.exec_result = ExecCredentials.run(exec_opts)

It does mean you'll have to check .token in 2 places, but I think the data flow will be more readable.

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 like it. Done.

@cben
Copy link
Collaborator

cben commented Jul 31, 2020

This is great, thanks!
Please add a CHANGELOG entry.

@cben cben changed the base branch from master to v4.y August 3, 2020 17:53
@cben cben changed the base branch from v4.y to master August 3, 2020 17:53
@cben cben merged commit dcccc6a into ManageIQ:master Aug 3, 2020
cben added a commit that referenced this pull request Aug 3, 2020
Add support for client-type ExecCredentials
@cben cben mentioned this pull request Aug 3, 2020
@@ -4,6 +4,10 @@ Notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
Kubeclient release versioning follows [SemVer](https://semver.org/).

## 4.9.0 - 2020-08-03
Copy link
Collaborator

Choose a reason for hiding this comment

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

Well played 😉. Released now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants