stevevillardi / Logic.Monitor

LogicMonitor PowerShell Module for automating LM Portal tasks using APIv3
https://www.powershellgallery.com/packages/Logic.Monitor
Mozilla Public License 2.0
23 stars 3 forks source link

Issue with authenication #6

Closed jmossuk closed 2 years ago

jmossuk commented 2 years ago

Hi Steve,

I was talking to LogicMonitor support and they recommended I take a look at your PowerShell module.

I'm trying to use your PowerShell LogicMonitor modules and I'm running into a problem and I don't know why. I'm trying to connect to our instance of LogicMonitor which we are in the middle of deploying however we are unable to authenticate even though I've successfully connected using the same account using the REST API directly in PowerShell.

The error message we are getting is:- Connect-LMAccount: Unable to login to account, please ensure your access info and account name are correct: Unable to get API token info

I've tried passing just credential details as part of the Connect-LMAccount and also using the Cached Credentials and neither works.

I don't know if it's to do with the AccessKey containing these special characters - {](%~+

Any ideas?

stevevillardi commented 2 years ago

Can you let me know what version of PowerShell you are using and the role permissions assigned to the api key you are using. If you could also let me know what version of the module you are using as well that would be great.

Special characters are not a problem but I would try using an API key that has the administrator role and see if that works as most of my development has been against an account with administrator permissions since many of the commands require a varying degree of access. I can test with a lower level permission account but it will be a week or so until I’m back in the office.

My guess would be the api account you are using does not have access to hit the portal info api endpoint that the connect-lmaccount uses to get portal info and test that the key is valid. If that is the case let me know and I can make adjustments in the next update so that a non admin account does not prevent login from succeeding.

jmossuk commented 2 years ago

Hi Steve,

Thanks for getting back to me so quickly - I've tried with different versions of PowerShell (both Windows and Core).

Right now the account we are using only has the "API resource management" role assigned to it - I will try adding the Administrator role as well and let you know the outcome.

Also the version of the module is the very latest - we only downloaded it a few days ago.

jmossuk commented 2 years ago

Hi Steve,

I can confirm the problem is the role assignment, I needed to add the "Administrator" to get it to work.

stevevillardi commented 2 years ago

Ok, thanks for the update. When I get back in the office I will push out a fix. I had made a change to the connect-lmaccount command a while back to test an api endpoint to verify the key was working and thought the portal info endpoint would be open to all permissions levels. I think that if you update your resource management role to include the view permission for Account Info under the Settings section then that should also work instead of having to assign administrator access for the time being.

jmossuk commented 2 years ago

Hi Steve,

I was wondering if you had a chance to look at the issue I raised a couple of weeks ago yet and if you were able to find a permanent fix.

stevevillardi commented 2 years ago

I did look into the issue and have a plan to address which should be in the next release hopefully this week

stevevillardi commented 2 years ago

V3.7.2 has been pushed to the PSGallery if you want to try and update your module and see if the issue is resolved:

https://www.powershellgallery.com/packages/Logic.Monitor/3.7.2

Update-Module -Name Logic.Monitor -RequiredVersion 3.7.2