Enforcing comment author via API
Posted: Tue Dec 08, 2020 3:40 am
Using the API I'm able to add comments to hosts and services as per the External command https://assets.nagios.com/downloads/nag ... ernalcmds/. This all works fine.
When you add comments via the GUI the Author is fixed to whichever account you login as (as it should be). However, when adding comments via the external command method the author is just a string argument and can be whoever or whatever you want. As a feature request it would be better if Author was set to the API token's account name (by querying user accounts). My thought is that the command (e.g. ADD_HOST_COMMENT) could remain as it is, so that the same functionality could exist, but if the command was submitted to the Nagios server via the API then it would enforce that the owner of the API token would become the author.
Another option would be to allow an API token to be queried via the API in order to retrieve the account information. I could use this method to enforce the author within my code. It doesn't stop anyone from circumventing this by creating their own API call but it's an option.
Your thoughts?
When you add comments via the GUI the Author is fixed to whichever account you login as (as it should be). However, when adding comments via the external command method the author is just a string argument and can be whoever or whatever you want. As a feature request it would be better if Author was set to the API token's account name (by querying user accounts). My thought is that the command (e.g. ADD_HOST_COMMENT) could remain as it is, so that the same functionality could exist, but if the command was submitted to the Nagios server via the API then it would enforce that the owner of the API token would become the author.
Another option would be to allow an API token to be queried via the API in order to retrieve the account information. I could use this method to enforce the author within my code. It doesn't stop anyone from circumventing this by creating their own API call but it's an option.
Your thoughts?