Skip to content

[4.0][API][com_actionslogs] keep track of API requests#27094

Merged
wilsonge merged 21 commits intojoomla:4.0-devfrom
alikon:patch-122
Mar 24, 2020
Merged

[4.0][API][com_actionslogs] keep track of API requests#27094
wilsonge merged 21 commits intojoomla:4.0-devfrom
alikon:patch-122

Conversation

@alikon
Copy link
Copy Markdown
Contributor

@alikon alikon commented Nov 17, 2019

Summary of Changes

listen event onAfterDispatch to keep track of API requests on actionlogs

Testing Instructions

make some requests GET for example:
/api/index.php/v1/plugins
/api/index.php/v1/users
/api/index.php/v1/config/application
/api/index.php/v1/content/article
....
etc...

test other verbs as welll

Expected result

API requests logged
something like
Screenshot from 2019-11-17 11-12-02

Actual result

N/A

Documentation Changes Required

maybe

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.0-dev labels Nov 17, 2019
Comment thread plugins/actionlog/joomla/joomla.php Outdated
Comment thread plugins/actionlog/joomla/joomla.php Outdated
@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Nov 17, 2019

Does this REALLY need a new event? Couldn’t onAfterDispatch work just as well here? You’d just need to check context if using that event.

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Nov 17, 2019

yes again 😄
there is no need for a new event onAfterDispatch does already the job

Comment thread plugins/actionlog/joomla/joomla.php Outdated
Comment thread plugins/actionlog/joomla/joomla.php Outdated
@wilsonge
Copy link
Copy Markdown
Contributor

Looks good to me. Just needs some tests

Comment thread plugins/actionlog/joomla/joomla.php Outdated
@Quy
Copy link
Copy Markdown
Contributor

Quy commented Dec 3, 2019

Please fix conflicts.

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Dec 3, 2019

conflict solved

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Dec 3, 2019

User admin performed a GET on index.php/v1/modules/site?language=%2A&state=0

* is displayed as %2A

Comment thread plugins/actionlog/joomla/joomla.php Outdated
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
'url' => $this->app->get('uri.route'),
'url' => urldecode($this->app->get('uri.route')),
Copy link
Copy Markdown
Contributor

@Quy Quy Dec 3, 2019

Choose a reason for hiding this comment

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

This can output potential XSS.

Copy link
Copy Markdown
Contributor Author

@alikon alikon Dec 4, 2019

Choose a reason for hiding this comment

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

any suggestions ?
what about

urldecode(htmlspecialchars($this->app->get('uri.route'), ENT_QUOTES, 'UTF-8'));

@alikon alikon added the GSoC label Jan 15, 2020
@alikon alikon closed this Feb 12, 2020
@alikon alikon reopened this Feb 20, 2020
@alikon alikon removed the GSoC label Feb 23, 2020
@chmst
Copy link
Copy Markdown
Contributor

chmst commented Mar 20, 2020

Tested with different words, for example

api-test-actionlogs

@chmst
Copy link
Copy Markdown
Contributor

chmst commented Mar 20, 2020

I have tested this item ✅ successfully on afb8f8f


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27094.

@wilsonge
Copy link
Copy Markdown
Contributor

Having thought about this I think we probably want to have an additional flag for this API setting. Because in the case you have mobile apps using the API actively you're going to end up having too many entries in action logs. But you might well still want other actions logged in the component.

@N6REJ
Copy link
Copy Markdown
Contributor

N6REJ commented Mar 20, 2020

Tests ran:
image

Results:
image

I have tested this item ✅ successfully on afb8f8f


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27094.

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Mar 21, 2020

ok i've fine grained the api logging
Screenshot from 2020-03-21 09-35-45

now you can disable the api logging
you can enable only some verbs to be logged
and of course only on some "Events"

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Mar 21, 2020

@chmst, @N6REJ another round of tests please

Comment thread administrator/language/en-GB/com_actionlogs.ini Outdated
Comment thread administrator/language/en-GB/com_actionlogs.ini Outdated
alikon and others added 2 commits March 23, 2020 19:30
Co-Authored-By: Quy <quy@fluxbb.org>
Co-Authored-By: Quy <quy@fluxbb.org>
Comment thread plugins/actionlog/joomla/joomla.php Outdated
Comment thread administrator/components/com_actionlogs/config.xml
alikon and others added 2 commits March 24, 2020 07:34
Co-Authored-By: Quy <quy@fluxbb.org>
@Razzo1987
Copy link
Copy Markdown
Contributor

Razzo1987 commented Mar 24, 2020

I have tested this item ✅ successfully on 4a38077

GET: ok
POST: ok
DELETE: ok
PUT: not tested (if someone have an example I try it)
PATCH: non listed in "Verds to log" ( I test this example: https://docs.joomla.org/J4.x:Joomla_Core_APIs#Update_Article)

J API


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27094.

@wilsonge wilsonge merged commit c3aa06a into joomla:4.0-dev Mar 24, 2020
@wilsonge
Copy link
Copy Markdown
Contributor

Thanks!

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Mar 24, 2020

thanks folks + thanks to covid19 for lockdown
😄

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

Labels

Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants