-
Notifications
You must be signed in to change notification settings - Fork 8
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
New feature: Allow authentication by personal tokens #53
Changes from all commits
ea79c0c
c006cb7
1306f86
f535d9b
58a56d1
5283255
c55a2bf
0c44af3
e7f0960
63031db
273d5f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,7 +241,7 @@ impl<U: UserProvider + PackageProvider + Send + Sync + 'static> Handler<U> { | |
|
||
// fetch metadata from the provider | ||
let metadata = Arc::clone(&self.gitlab) | ||
.fetch_metadata_for_release(path, crate_version) | ||
.fetch_metadata_for_release(path, crate_version, self.user()?) | ||
.await?; | ||
|
||
// transform the `cargo metadata` output to the cargo index | ||
|
@@ -285,7 +285,10 @@ impl<U: UserProvider + PackageProvider + Send + Sync + 'static> Handler<U> { | |
|
||
// fetch the impersonation token for the user we'll embed | ||
// the `dl` string. | ||
let token = self.gitlab.fetch_token_for_user(self.user()?).await?; | ||
let token = match &self.user()?.token { | ||
None => self.gitlab.fetch_token_for_user(self.user()?).await?, | ||
Some(token) => token.clone(), | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clippy will probably complain about this since it can be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the review! It seems like clippy didn't have a problem with this particular line but, however, with two other lines in my code. I fixed them accordingly. |
||
|
||
// generate the config for the user, containing the download | ||
// url template from gitlab and the impersonation token embedded | ||
|
@@ -402,7 +405,7 @@ impl<U: UserProvider + PackageProvider + Send + Sync + 'static> thrussh::server: | |
info!( | ||
"Successfully authenticated for GitLab user `{}` by {}", | ||
&user.username, | ||
if by_ssh_key { "SSH Key" } else { "Build Token" }, | ||
if by_ssh_key { "SSH Key" } else { "Build or Personal Token" }, | ||
); | ||
self.user = Some(Arc::new(user)); | ||
self.finished_auth(Auth::Accept).await | ||
|
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.
Could you leave these lines in please? A CI token would still be required to build
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.
Ok. I removed them because embedding the CI token into the registry's URL does not work anymore with the newest cargo version. (Please correct me if I oversee something.)
I changed the commit such that these lines remain and a note regarding newer versions of cargo is added.
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.
That is true, these instructions were wrong as established in #28 but it was never corrected