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

Allow login to automatically pull from env vars #2884

Merged
merged 11 commits into from
Mar 24, 2023

Conversation

ThomasLaPiana
Copy link
Contributor

@ThomasLaPiana ThomasLaPiana commented Mar 21, 2023

Closes #2786

Code Changes

  • add the user.username and user.password fields to the config
  • update fides user login to pull from the config automatically if the options aren't specified, finally falling back on prompting if not provided as an option and not in the config
  • update fides user create to use username and password arguments instead of options, display assigned roles upon successful creation
  • add the username and password to the development config file

Steps to Confirm

  • confirm that the user.username and user.password fields are set in the fides.toml:
    • run fides user login and confirm "it just works"
    • run fides user login -u notarealuser and confirm it breaks
  • remove the user.username and user.password fields from the fides.toml
    • run fides user login and confirm it prompts for them
  • fides user create newuser Testpassword1! is successful and shows the assigned roles (always owner currently)

Pre-Merge Checklist

Description Of Changes

This PR is designed to make logging in via the CLI more user-friendly. It allows users to set a username and password via the config file (and therefore via env vars if so inclined) that will get automatically used during the login process.

It should be noted that username/password are considered discrete values here, so one may configure their username via the config file and it will still prompt for the password

Login Logic Update

The new priority list is as follows:

  1. If a username/password option is provided directly, use that value
  2. If no flags are provided, check the config (which would automatically load env vars as well, such as FIDES__USER__USERNAME)
  3. If no option was provided and the config is empty, prompt the user for the value

Example Config Section

[user]
username = "root_user"
password = "password

@ThomasLaPiana ThomasLaPiana self-assigned this Mar 21, 2023
@cypress
Copy link

cypress bot commented Mar 21, 2023

Passing run #978 ↗︎

0 3 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge edd3e43 into dfabd1d...
Project: fides Commit: 068752d230 ℹ️
Status: Passed Duration: 00:33 💡
Started: Mar 24, 2023 4:51 AM Ended: Mar 24, 2023 4:52 AM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +19.33 🎉

Comparison is base (50b836c) 67.30% compared to head (edd3e43) 86.63%.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2884       +/-   ##
===========================================
+ Coverage   67.30%   86.63%   +19.33%     
===========================================
  Files         299      299               
  Lines       16814    16831       +17     
  Branches     2148     2148               
===========================================
+ Hits        11316    14581     +3265     
+ Misses       5093     1841     -3252     
- Partials      405      409        +4     
Impacted Files Coverage Δ
src/fides/cli/utils.py 65.89% <ø> (ø)
src/fides/cli/commands/user.py 100.00% <100.00%> (ø)
src/fides/cli/options.py 95.60% <100.00%> (+3.39%) ⬆️
src/fides/core/config/__init__.py 95.50% <100.00%> (+13.48%) ⬆️
src/fides/core/config/user_settings.py 100.00% <100.00%> (ø)
src/fides/core/user.py 97.33% <100.00%> (+0.03%) ⬆️

... and 133 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ThomasLaPiana ThomasLaPiana marked this pull request as ready for review March 23, 2023 10:27
Copy link
Contributor

@TheAndrewJackson TheAndrewJackson left a comment

Choose a reason for hiding this comment

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

I like this improvement! Everything worked great 🚀

src/fides/core/user.py Outdated Show resolved Hide resolved
@ThomasLaPiana ThomasLaPiana merged commit da065f8 into main Mar 24, 2023
@ThomasLaPiana ThomasLaPiana deleted the ThomasLaPiana-login-from-env branch March 24, 2023 05:11
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.

Allow fides user login to pull from env vars
3 participants