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

RateLimiting functionality does not work #61

Open
TriggerAu opened this issue Oct 31, 2024 · 4 comments
Open

RateLimiting functionality does not work #61

TriggerAu opened this issue Oct 31, 2024 · 4 comments

Comments

@TriggerAu
Copy link
Contributor

In the documentation it talks to how the powershell module handles rate limiting using two configuration attributes
https://github.com/okta/okta-powershell-cli?tab=readme-ov-file#rate-limiting

There is a code file to handle this behaviour, but it is never accessed in my testing: https://github.com/okta/okta-powershell-cli/blob/main/src/Okta.PowerShell/Client/OktaRetryApi.ps1

In the APIClient calls here:

if ($SkipCertificateCheck -eq $true) {
if ($null -eq $Configuration["Proxy"]) {
# skip certification check, no proxy
$RawResponse = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck `
-UserAgent $OktaUserAgent
} else {
# skip certification check, use proxy
$RawResponse = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-SkipCertificateCheck `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials `
-UserAgent $OktaUserAgent
}
} else {
if ($null -eq $Configuration["Proxy"]) {
# perform certification check, no proxy
$RawResponse = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-UserAgent $OktaUserAgent
} else {
# perform certification check, use proxy
$RawResponse = Invoke-WebRequest -Uri $UriBuilder.Uri `
-Method $Method `
-Headers $HeaderParameters `
-Body $RequestBody `
-ErrorAction Stop `
-UseBasicParsing `
-Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) `
-ProxyUseDefaultCredentials `
-UserAgent $OktaUserAgent

they are set with an ErrorAction of Stop and the IWR method also throws fatal errors based on the server response, so the code to retry or not is never reached.

In Powershell 7 - where I am working - there is a -SkipHTTPErrorCheck that can help handle this, but I haven't yet had the time to dig deeper on this one

@laura-rodriguez
Copy link
Collaborator

HI @TriggerAu,

Thanks for reporting this issue. I filed an internal ticket that the team will review and prioritize accordingly.

Internal Ref: OKTA-825260

TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Nov 1, 2024
…and OktaRetryApi classes

* The OktaApiClient class was not correctly handling a non 200 response code
* The OktaRetryApi class was searching for a header field using incorrect classes
* The OktaRetryApi class was trying to parse a Unix Epoch number as a string date
* Also added a verbose message so teh user knows how long they waiting for the retry
TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Nov 1, 2024
TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Nov 1, 2024
TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Nov 1, 2024
TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Nov 1, 2024
@TriggerAu
Copy link
Contributor Author

Fix is up in PR

TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Nov 1, 2024
@laura-rodriguez
Copy link
Collaborator

Thank you for your contribution @TriggerAu!

Can you please review and sign the Okta Individual Contributor License Agreement?

@TriggerAu
Copy link
Contributor Author

TriggerAu commented Nov 1, 2024

Can you please review and sign the Okta Individual Contributor License Agreement?

Hey @laura-rodriguez I did give that a read a while back and chatted with my companies Okta Account Manager. As everything Ive PRed to date is in the Bug/"Obvious Fix" category - typos, datatypes, etc - it didn't seem to fit.

If there's something extra lets organise a chat with our account team

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

No branches or pull requests

2 participants