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

Improving flows and rules around user creation #1272

Merged
merged 1 commit into from
Jan 27, 2020

Conversation

nahumcohen
Copy link
Contributor

What does this PR do?
Improves flows and rules around user creation.

How should this be manually tested?

Install appliance once this is merged to master.

Has the Version and Changelog been updated?

The version has not the Changelog has updated.

Questions:

Does this work have automated integration and unit tests?
yes
Can we make a blog post, video, or animated GIF of this?
no
Has this change been documented (Readme, docs, etc.)?
no
Does the knowledge base need an update?
no

lib/util/password.rb Outdated Show resolved Hide resolved
spec/util_spec.rb Outdated Show resolved Hide resolved
orenbm
orenbm previously requested changes Jan 22, 2020
Copy link
Member

@orenbm orenbm left a comment

Choose a reason for hiding this comment

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

Left some comments

app/models/role.rb Outdated Show resolved Hide resolved
app/domain/errors.rb Outdated Show resolved Hide resolved
app/controllers/credentials_controller.rb Outdated Show resolved Hide resolved
@micahlee
Copy link
Contributor

Thanks @nahumcohen! This is looking good, just a couple comments for you.

The Code Climate issues also look relatively easy to address (syntax formatting issues). Would you mind taking care of those as well?

Thanks!

Copy link
Contributor

@jvanderhoof jvanderhoof left a comment

Choose a reason for hiding this comment

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

Let's get the password format validation moved into the Role class before we merge.

@jvanderhoof
Copy link
Contributor

@nahumcohen, once we get the validation moved into the Role class, let's get a couple of unit test in place to validate functionality.

@nahumcohen nahumcohen force-pushed the user_creation_improving_flows branch from bf2468a to 9894098 Compare January 22, 2020 17:04
app/domain/errors.rb Show resolved Hide resolved
app/domain/errors.rb Outdated Show resolved Hide resolved
app/domain/errors.rb Outdated Show resolved Hide resolved
app/controllers/credentials_controller.rb Outdated Show resolved Hide resolved
lib/util/password.rb Outdated Show resolved Hide resolved
lib/util/password.rb Outdated Show resolved Hide resolved
lib/util/password.rb Outdated Show resolved Hide resolved
lib/util/password.rb Outdated Show resolved Hide resolved
@nahumcohen nahumcohen force-pushed the user_creation_improving_flows branch 2 times, most recently from 1acd160 to d853ee4 Compare January 23, 2020 13:25
app/models/credentials.rb Outdated Show resolved Hide resolved
app/controllers/credentials_controller.rb Outdated Show resolved Hide resolved
app/controllers/credentials_controller.rb Outdated Show resolved Hide resolved
@micahlee
Copy link
Contributor

@nahumcohen, thanks for making these updates! This is looking good.

These last code climate issues look like they're worth fixing, and then I think this should be good to go!

@nahumcohen nahumcohen force-pushed the user_creation_improving_flows branch from d853ee4 to 7102708 Compare January 26, 2020 12:34
@nahumcohen nahumcohen self-assigned this Jan 26, 2020
@nahumcohen nahumcohen requested review from uCatu and removed request for uCatu January 26, 2020 13:09
Copy link
Contributor

@uCatu uCatu left a comment

Choose a reason for hiding this comment

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

Hi - see comments lets talk tomorrow :)

@nahumcohen nahumcohen force-pushed the user_creation_improving_flows branch from 7102708 to af07f86 Compare January 27, 2020 12:43
head 204
rescue Sequel::ValidationFailed => e
# render json with unprocessable_entity only for insufficient_password_complexity otherwise, raise an error
insufficientMsg = Errors::Conjur::InsufficientPasswordComplexity.new.to_s
Copy link

Choose a reason for hiding this comment

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

Use snake_case for variable names.

@nahumcohen nahumcohen force-pushed the user_creation_improving_flows branch from af07f86 to 35f8594 Compare January 27, 2020 13:12
@nahumcohen nahumcohen force-pushed the user_creation_improving_flows branch from 35f8594 to cb38c3d Compare January 27, 2020 13:57
@codeclimate
Copy link

codeclimate bot commented Jan 27, 2020

Code Climate has analyzed commit cb38c3d and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 88.4% (0.0% change).

View more on Code Climate.

@uCatu uCatu merged commit 29721f8 into master Jan 27, 2020
@@ -63,8 +70,7 @@ def validate

validates_presence [ :api_key ]

errors.add(:password, 'must not be blank') if @plain_password && @plain_password.empty?
errors.add(:password, 'cannot contain a newline') if @plain_password && @plain_password.index("\n")
errors.add(:password, ::Errors::Conjur::InsufficientPasswordComplexity.new.to_s) if @plain_password && (@plain_password.index("\n") || @plain_password !~ VALID_PASSWORD_REGEX)
Copy link
Contributor

@jvanderhoof jvanderhoof Jan 27, 2020

Choose a reason for hiding this comment

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

Let's use the Sequel Gem validation: https://github.com/jeremyevans/sequel/blob/master/doc/validations.rdoc#validates_format
It would be something like:

validates_format VALID_PASSWORD_REGEX, : plain_password, message: ::Errors::Conjur::InsufficientPasswordComplexity.new.to_s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The scope of validate method includes both api_key and plain_password. If we add validate_format it will not separate between the two use-cases.

See existing password validation logic is to verify existence of plain_password parameter, and only after, verify complexity, blank & new line.

We also wanted to utilize validates_presence, but neglect the idea for the same reason above.

@jvanderhoof jvanderhoof deleted the user_creation_improving_flows branch March 25, 2020 21:56
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.

5 participants