-
Notifications
You must be signed in to change notification settings - Fork 74
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 an mfaToken option to the credentials binding #160
base: master
Are you sure you want to change the base?
Conversation
@weaversam8 It is also legal to specify Personally, I think allowing people to specify the role as part of the actual credentials themselves was a mistake, and so having your new Also, I don't think your code will work as written. The type of |
I'm not sure I agree. The user running a job may have assume different roles based on their access level within an organization, but those different roles may provide equivalent permissions to perform the actions the job requires. This scenario is especially likely if these AWS credentials are user credentials in Jenkins. Regardless of whether we agree on that point, unless you think it's also in-scope for this PR to remove the ability to specify a role as part of the credentials, you're right in that we need to clarify this parameter (and potentially create an additional parameter, if the original role assumption requires MFA.) Suggestion: split the parameter into two params
I've validated that this code works by compiling from source and loading this plugin on a Jenkins instance for testing. The configuration I'm using is:
|
In this situation you can have entirely separate IAM users. The role itself is not really a secret. In fact, specifying it as part of the secret in Jenkins means that refreshing the credentials cannot work, if the closure in question takes significant time. (This is also true if you specify
I am not suggesting removing that functionality. From your issue description it already doesn't work properly with MFA tokens, so continuing to not support that wouldn't really be a change.
If you pass Lines 137 to 152 in c748e81
|
Ah, sorry. To clarify: I'm not arguing that the role itself is a secret and should be treated as such. My point is that some users workflows (involving entirely separate IAM users) may mean that two different users can't assume the same role. Imagine a job required the If we require the role assumption to be provided in the job itself and only in the job itself, in the scenario where two users both want to run a job, if the role they need to adopt is different, you'd have to supply it as an additional job parameter, which is undesirable. In contrast, if the job knows it needs a particular role (instead of needing a particular set of permissions) then I think that's the situation where you'd want to supply a
Agreed, it wouldn't be a change, however my primary motivation for submitting this PR was to support adopting the role specified in the credential (which fits my scenario for using this plugin.) You pointed out (rightfully) that I didn't consider
Ah, thank you. I had missed this. I might rewrite the Is there anything that the |
Closes #16.
This plugin has support for specifying AWS Credentials with an MFA device serial #, but doesn't actually expose a method of obtaining a session token from a pipeline if your credentials are configured as such.
This PR adds a new
mfaToken
option to theAmazonWebServicesCredentialsBinding
class, which enables an approach like this in a pipeline. (This is a scripted pipeline example, but it should also work for declarative.)In the above example,
deployCredentialsId
is a parameter to the pipeline (ideally pointing to AWS credentials attached to a specific user rather than system level credentials, which is why the parameter is interpolated as a template string. See JENKINS-58170 for more info on this.)The
mfaCode
variable is a parameter to the pipeline as well. This enables developers invoking a job to provide an MFA code from their authenticator device when starting the job, ensuring MFA still requires a human element.This is a draft pull request. While I've built this plugin and verified it works with some basic manual testing, there are still a few unanswered questions that I'll need some assistance with:
provider
ever be any type other thanAmazonWebServicesCredentials
? If so we may need a different solution. If not, why is this variable typed asAWSCredentialsProvider
and not something else?PR submission checklist