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

‘CustomKeyCheck’ object has no attribute ‘arg_count’ #2416

Closed
pretecd opened this issue Jul 21, 2019 · 7 comments

Comments

@pretecd
Copy link

commented Jul 21, 2019

Hi all!
I'm trying to write a python plugin that replaces the key verification done by Tyk with a custom one (essentially pass the token below the chain if there is one).

Following this example, I wrote it, but I always get

Hook 'MyAuthMiddleware' returned an error: 'CustomKeyCheck' object has no attribute 'arg_count'

when an API is called.
The manifest.json is simply:

    {
      "file_list": [
    "middleware.py"
      ],
      "custom_middleware": {
    "auth_check": {
      "name": "MyAuthMiddleware"
    },
    "driver": "python"
      }
    }

If, instead, I use the @Hook decorator then I don't have this issue, but the key verification fails.
Finally, I've this issue also with the @Pre decorator.

@buger

This comment has been minimized.

Copy link
Member

commented Jul 21, 2019

Ensure that you are using Python 3.4 or 3.6, and the latest stable version of protobuf packages.

@CDPrete

This comment has been minimized.

Copy link

commented Jul 21, 2019

shouldn't those be provided already as part of the Docker image?

@buger buger added bug and removed bug labels Jul 21, 2019

@buger

This comment has been minimized.

Copy link
Member

commented Jul 21, 2019

I think this is an issue with the doc you used. Try this one https://tyk.io/docs/customise-tyk/plugins/rich-plugins/python/custom-auth-python-tutorial/

It should be @Hook instead of @CustomKeyCheck

@buger

This comment has been minimized.

Copy link
Member

commented Jul 21, 2019

Fixed docs issue

@buger buger closed this Jul 21, 2019

@CDPrete

This comment has been minimized.

Copy link

commented Jul 21, 2019

Sorry for opening this again, but if I follow that other guide, then I get that the key is invalid although my token is invalid.
It's like the token is still validated against the registered API keys (if any). Is there any way to avoid this and have then full control over the validation?

@buger

This comment has been minimized.

Copy link
Member

commented Jul 21, 2019

Have you set your API auth method to "custom auth"?
Do you have anything in logs when log_level set to "debug"?

@CDPrete

This comment has been minimized.

Copy link

commented Jul 22, 2019

Yes, I was using the custom auth.
I can set the log level to debug and let you know.

Edit:
Seems like that the line metadata['token'] = token is mandatory to make it work. Maybe it would be good to document it ;)

Although now it's not clear. From the logs seems like it's creating an API key out of the token I provide in the metadata. Is that the correct behaviour? What if I want to use an API key + my token?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.