-
Notifications
You must be signed in to change notification settings - Fork 167
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
Conversation
lib/kubeclient/exec_credentials.rb
Outdated
return if has_client_credentials | ||
|
||
has_token = status.key?('token') | ||
raise 'exec plugin didn\'t return a token' unless has_token |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lib/kubeclient/config.rb
Outdated
@@ -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'] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. Done.
This is great, thanks! |
Add support for client-type ExecCredentials
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well played 😉. Released now.
This library currently supports
token
-type ExecCredentials, but there is actually another flavor for TLS client auth. With this flavor, thestatus
field includes PEM-encodedclientKeyData
andclientCertificateData
rather than atoken
. 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 auser
.