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

Auth token #248

Merged
merged 11 commits into from
Feb 22, 2024
Merged

Auth token #248

merged 11 commits into from
Feb 22, 2024

Conversation

macovedj
Copy link
Collaborator

This PR adds login and logout commands to add or delete auth tokens to your keyring and then adds them as bearer tokens to requests made to your warg server

@calvinrp calvinrp requested a review from lann February 22, 2024 14:58
let url = RegistryUrl::new(url)?;
Ok(Self {
url,
client: reqwest::Client::new(),
warg_registry_header: None,
auth_token,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd recommend using https://docs.rs/reqwest/0.11.24/reqwest/struct.ClientBuilder.html#method.default_headers to replace all the changes in this file. The first example in the method docs there is basically what you would need (plus prepending Bearer to the value).

Copy link
Collaborator

@calvinrp calvinrp Feb 22, 2024

Choose a reason for hiding this comment

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

There's a tradeoff on using the default_headers for the Client, where you might accidentally provide the auth header on a request that shouldn't have it. For instance, on the upload and download requests which may be URLs on a different host server that shouldn't have access to the auth secret.

It might be safer to forget the auth header on a request than to accidentally leak a secret. Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Think I agree with Calvin here... though if there's something in the middle, the default headers is definitely a smaller change. Went ahead and pushed the other suggestions.

src/commands.rs Outdated Show resolved Hide resolved
src/commands/login.rs Outdated Show resolved Hide resolved
@macovedj macovedj merged commit 36ba63d into main Feb 22, 2024
6 checks passed
@calvinrp calvinrp deleted the auth-token branch February 22, 2024 17:01
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.

3 participants