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

#51 Support access token auth #55

Merged
merged 4 commits into from
Oct 13, 2021
Merged

Conversation

LeJeanbono
Copy link
Contributor

@LeJeanbono LeJeanbono commented Oct 8, 2021

Can you tag for #hacktoberfest please @Elendev ?

Copy link
Owner

@Elendev Elendev left a comment

Choose a reason for hiding this comment

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

Hello @LeJeanbono, first of all, thanks for your contribution!

I like how you've handled the token and the small refactoring.

Nevertheless I have one small suggestion below, what do you think?

Comment on lines 44 to 62
protected function postFile($file, $username = null, $password = null)
{
$url = $this->getUrl() . '.' . pathinfo($file, PATHINFO_EXTENSION) . '?properties=composer.version=' . $this->getConfiguration()->getVersion();

$options = [
'debug' => $this->getIO()->isVeryVerbose(),
'body' => fopen($file, 'r')
];

$options = [];
if (!empty($username) && !empty($password)) {
$options['auth'] = [$username, $password];
}

$this->apiCall($file, $options);
}

/**
* Post with access token auth
*/
protected function postFileWithToken($file, $token)
{
$options = [];
$options['headers']['Authorization'] = 'Bearer ' . $token;
$this->apiCall($file, $options);
}
Copy link
Owner

Choose a reason for hiding this comment

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

I'm under the impression that both postFile and postFileWithToken's body should be moved to the AbstractProvider.php since they share exactly the same code, now that you've pushed the options into apiCall.
What do you think?

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 !

@LeJeanbono
Copy link
Contributor Author

Here we are @Elendev !

@Elendev
Copy link
Owner

Elendev commented Oct 13, 2021

@LeJeanbono sorry I forgot to activate the workflow for this PR earlier, there is a small code sniffing issue.
Can I let you run vendor/bin/php-cs-fixer fix src to automatically fix the code styling?
After that I'll gladly merge your PR and release a new version 👍

Thanks!

@Elendev Elendev merged commit 9ce4076 into Elendev:master Oct 13, 2021
LeJeanbono added a commit to LeJeanbono/composer-push that referenced this pull request Oct 15, 2021
@LeJeanbono LeJeanbono deleted the artifact_token branch October 30, 2021 08:18
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.

2 participants