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

vdk-control-cli: Adopt new vdk-control-api-auth library #840

Merged
merged 1 commit into from
May 20, 2022

Conversation

doks5
Copy link
Contributor

@doks5 doks5 commented May 19, 2022

With the release of the vdk-control-api-auth library, we now have a
stand-alone authentication package that is to be used by all Versatile
Data Kit components that need to authenticate against a third-party
service.

This change adopts the new authentication package in vdk-control-cli,
and is now used when issuing vdk login commands.

Additionally, authentication logic in vdk-control-cli which is overlapping
with such logic in vdk-control-api-auth is removed.

Testing Done: Installed the new changes locally and ran vdk login to verify
that the browser redirecs work as expected. Also, ran a docker container with
the latest changes to verify that authentication is possible even when there
is no access to a browser.

Signed-off-by: Andon Andonov [email protected]

@doks5 doks5 force-pushed the person/andonova/vdk-auth branch from e55e23b to d530a8a Compare May 19, 2022 11:44
@doks5 doks5 force-pushed the person/andonova/vdk-auth branch 2 times, most recently from c1e144d to 77f201d Compare May 20, 2022 11:40
With the release of the vdk-control-api-auth library, we now have a
stand-alone authentication package that is to be used by all Versatile
Data Kit components that need to authenticate against a third-party
service.

This change adopts the new authentication package in vdk-control-cli,
and is now used when issuing `vdk login` commands.

Additionally, authentication logic in vdk-control-cli which is overlapping
with such logic in vdk-control-api-auth is removed.

Testing Done: Installed the new changes locally and ran `vdk login` to verify
that the browser redirecs work as expected. Also, ran a docker container with
the latest changes to verify that authentication is possible even when there
is no access to a browser.

Signed-off-by: Andon Andonov <[email protected]>
@doks5 doks5 force-pushed the person/andonova/vdk-auth branch from 77f201d to 9858382 Compare May 20, 2022 12:03
@doks5 doks5 merged commit b2f2c9f into main May 20, 2022
@doks5 doks5 deleted the person/andonova/vdk-auth branch May 20, 2022 12:13
click.echo("Login Successful")
except VDKAuthException as e:
if (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Parsing error messages is not a good practice. You should not look at what we do in Impala as a good example. We have no control over what Expcetion Impala raises so we have to parse them there. We do within vdk-control-api-auth library. We should use error codes or enums or exception hierarchy to handle this .

try:
apikey_auth.authenticate()
except VDKAuthException as e:
click.echo(f"Login failed. Error was: {e.message}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

That does not seem correct. If auth fails we should exit with non 0 exit code. This will only print the failure and will exit with 0 . Why not let the exception propagate or wrap it in UserError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, though I believe we didn't exit with non-0 status before either.

Copy link
Contributor Author

@doks5 doks5 May 26, 2022

Choose a reason for hiding this comment

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

I opted out of propagating the exception, as that would be displayed in the user's terminal, and I was not sure if this would be good UX. Also, we have never showed exception messages in terminal for failed login, so doing it now seems like a regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants