-
Notifications
You must be signed in to change notification settings - Fork 124
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
Conjurctl create account with password #2042
Conversation
8ffc5ae
to
753a3c2
Compare
VALID_PASSWORD_REGEX = %r{^(?=.*?[A-Z].*[A-Z]) # 2 uppercase letters | ||
(?=.*?[a-z].*[a-z]) # 2 lowercase letters | ||
(?=.*?[0-9]) # 1 digit | ||
(?=.*[ !"#$%&'()*+,-.\/:;<=>?@\[\\\]^_`{|}~]). # 1 special character |
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.
Redundant escape inside regexp literal
bin/conjur-cli.rb
Outdated
Example: | ||
|
||
$ conjurctl account create myorg | ||
$ conjurctl account create myorg [password_file] |
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.
Given it's optional, would it make since for this to be a flag (--password-file
) instead? That also has the benefit of being consistent with the server
command.
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.
this is small, but there is a difference between providing a reference to a file and to providing the file contents. should we be overloading the same flag with both use cases? maybe it would be better to have a password
flag for the password value, and a password-file
flag for a reference to a file containing the value?
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 am leaning towards just including a password
flag (which would only accept input via STDIN). If there is value in adding the flag password-file
I will be happy to add it in the future.
bin/conjur-cli.rb
Outdated
def file_input(path) | ||
if path == '-' | ||
$stdin.read.force_encoding('ASCII-8BIT') | ||
else | ||
File.read(path, mode: 'rb') | ||
end | ||
end |
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 looks like there are a number of potential failure cases here. Do these manifest in the messages you would want the user to see?
For example:
- The file doesn't exist
- The file is empty
- The
-
argument is given, but nothing is provided to STDIN
Along these lines, is there any way some of this could be unit tested? Or is there no infrastructure/fixture for that now with this CLI?
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.
If the file doesn't exist the user will see the following error:
conjurctl server --account demo --password-file /no_such_file error: No such file or directory @ rb_sysopen - /no_such_file
.
I can wrap this error if you think it would provide a better UX.
If the -
argument is given, but nothing is provided to STDIN ex.
conjurctl server --account demo --password-file
, it will hang.
However, a user could still provide input by typing in a password and then Ctrl+D.
I could add a timeout if you think this would improve the UX, but there are pros and cons to that approach as well.
We currently do not have any unit tests for conjurctl. I will look into adding a cucumber test for conjurctl account create
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.
Regarding:
If the - argument is given, but nothing is provided to STDIN ex.
conjurctl server --account demo --password-file, it will hang.
However, a user could still provide input by typing in a password and then Ctrl+D.
I could add a timeout if you think this would improve the UX, but there are pros and cons to that approach as well.
You can actually detect this without a timeout using $stdin.tty?
command | $stdin.tty? |
---|---|
echo 'password' | conjurctl ... --password-file - |
false |
conjurctl ... --password-file - < password-file.txt |
false |
conjurctl ... --password-file - |
true |
That would give you either an opportunity to interactively prompt for it, or just raise an error if the standard input isn't piped in.
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.
TIL
will this flow have test cases added for it? just wanted to flag that here, since the PR doesn't say WIP / it's not a draft - if we can add tests, we should do that before merging. also, is there a docs card? |
@izgeri I do not believe we currently have tests for the I was unable to find the docs for the |
@h-artzi I hoped we had something in the docs, but it looks like the best reference is actually the quick start :( Maybe we can create a new small section after "Next Steps" here that explains "Configuring Conjur with a pre-defined admin password"? I am uncomfortable merging this without tests, or if the scope of adding tests is too big, without and issue filed with a plan to address it that will add the appropriate tests. There are a few cukes that test On a totally separate note - is there a default value for |
fd5a194
to
9d17bad
Compare
9d17bad
to
bf310cb
Compare
364057f
to
542089d
Compare
01664eb
to
635a10f
Compare
Relative follow up tickets: |
635a10f
to
d7df439
Compare
d7df439
to
4961f34
Compare
4961f34
to
5a86e65
Compare
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.
1672553
to
fe8f44c
Compare
fe8f44c
to
3b30d11
Compare
This lets us to check password validity outside of the Credentials class
The previous command would just kill the parent process id.
3b30d11
to
2aecf28
Compare
Code Climate has analyzed commit 2aecf28 and detected 2 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 48.1% (50% is the threshold). This pull request will bring the total coverage in the repository to 89.2% (-0.2% change). View more on Code Climate. |
What does this PR do?
Enable operators to specify an admin user's password:
conjurctl account create --name demo --password-from-stdin
(STDIN)conjurctl server --account demo --password-from-stdin
(STDIN)How to manually test?
What ticket does this PR close?
Resolves #2043
Checklists
Change log
Test coverage
Documentation
README
s) were updated in this PR, and/or there is a follow-on issue to update docs, or