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

feat: record the name of the integration being used to auth requests #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamzero1
Copy link

When you have multiple integrations it isn't easy to distinguish requests between them.
This adds the integration name to the log file.
image

image

Copy link
Owner

@vladflonta vladflonta left a comment

Choose a reason for hiding this comment

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

Hi Adam,

Thank you for your contribution to this module. If you don't mind, I would ask you to also increase the package version to 1.1.0 this way I can release the code after merging.

Do you think this would be needed for versions before Magento v2.4.4 (actually magento/framework 103.0.4)? In that case we might have to branch the changes from release 0.1.1 and create the 0.2.0 version instead.

Comment on lines +180 to +192
$data = explode(',', $requestHeader['data']);
$data = array_map(function($keyValue){
list($key, $value) = explode('=', $keyValue);
return [
'key' => $key,
'value' => trim($value, '"')
];
}, $data);
$data = array_combine(
array_column($data, 'key'),
array_column($data, 'value')
);
$consumerKey = $data['oauth_consumer_key'];
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer an approach that uses existing methods for parsing the data (and in the end using less code). Do you think something in this direction would produce the same effect?

Suggested change
$data = explode(',', $requestHeader['data']);
$data = array_map(function($keyValue){
list($key, $value) = explode('=', $keyValue);
return [
'key' => $key,
'value' => trim($value, '"')
];
}, $data);
$data = array_combine(
array_column($data, 'key'),
array_column($data, 'value')
);
$consumerKey = $data['oauth_consumer_key'];
$consumerKey = array_reduce(
explode(',', $requestHeader['data']),
function($key, $keyValue) {
parse_str($keyValue, $data);
return $key ?: (array_key_exists('oauth_consumer_key', $data) ? trim(reset($data), '"') : null);
});

@adamzero1
Copy link
Author

Hey @vladflonta ,

Sorry missed your response, I'll try and pick this up this week
Nice one

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.

None yet

2 participants