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

[THREESCALE-2755] Return "auth failed" instead of "limits exceeded" for disabled metrics #1066

Merged
merged 3 commits into from
Jun 12, 2019

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Jun 11, 2019

Fixes THREESCALE-2755

See the JIRA epic for a more detailed description: THREESCALE-2752

This uses the new 3scale-limit-max-value header returned by apisonator: 3scale/apisonator#103

@davidor davidor requested a review from a team as a code owner June 11, 2019 15:42
Copy link
Contributor

@eloycoto eloycoto left a comment

Choose a reason for hiding this comment

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

minor nitpick :-)

-- This header is set only when enabled via the '3scale-options' header of the
-- request.
local function limit_max_value(response_headers)
return response_headers and response_headers['3scale-limit-max-value']
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change here to return tonumber(response_headers['3scale-limit-max-value'])

Copy link
Contributor

Choose a reason for hiding this comment

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

It would still need to be tonumber(response_headers and response_headers['3scale-limit-max-value']).

-- APIcast, we want to distinguish between limits exceeded vs disabled
-- metric. That's why we reset the reason. The generic auth fail (403) will
-- be returned.
if tonumber(limit_max) == 0 and unauthorized_reason == 'limits_exceeded' then
Copy link
Contributor

Choose a reason for hiding this comment

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

If we return the number in the limit_max_value, here tonumber is not needed at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 👍

spec/proxy_spec.lua Show resolved Hide resolved
@davidor davidor force-pushed the disabled-metrics branch from 54993ba to 5931571 Compare June 12, 2019 08:57
@davidor davidor requested a review from eloycoto June 12, 2019 08:59
@eloycoto eloycoto merged commit 22f5274 into master Jun 12, 2019
@davidor davidor deleted the disabled-metrics branch June 12, 2019 10:37
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

Successfully merging this pull request may close these issues.

3 participants