AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
321 stars 131 forks source link

No Authentication Error Message In Case Authentication Fails #423

Open bormm opened 3 years ago

bormm commented 3 years ago

Description

In case wrong login data is given, the cmdlets only return for example the issue was not found but do not give a correct error message.

Steps To Reproduce

In case wrong login data is given to "New-JiraSession -Credential ..." there is no error message given. Only if I pass a invalid token, a error is returned about "plain Basic authentication with passwords is deprecated". For example a valid token for the wrong mail address is accepted without any message. If you work a lot with JiraPS, then you will notice that there is no "Microsoft.PowerShell.Commands.WebRequestSession" object returned in case the credentials are wrong. But that's it. The Invoke-WebRequest gets a "Client must be authenticated to access this resource." exception, but that does not result in an error message.

Later calls are unable to detect the wrong credentials, maybe because they are not passed again to the server: For example "Get-JiraIssue "issueid"", results in "Issue does not exist or you do not have permission to see it." Calling Get-JiraProject results in "No project could be found with key ''." It will never mentioned the authentication failed.

Expected behavior

New-JiraSession should return an error in case jira does not accept the authentication data.

Screenshots

Your Environment

JiraPS 2.14.3

Name Value


PSVersion 7.0.3 PSEdition Core GitCommitId 7.0.3 OS Microsoft Windows 10.0.19041 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

lipkau commented 3 years ago

I can look into this at some point. But it's Jira REST who responds with 404 (Not Found) when you are not authorized. This is API's best practice for avoiding scraping data without authorization.