GithubHelp home page GithubHelp logo

kong-client-ruby's Issues

Cannot redefine api_url

Hello,

As said in the doc, it should be possible to override the default kong_url with this code

Kong::Client.api_url = 'http://your-kong-url:8001'

However, this does not work. The api_url attribute is changed, but the Excon http_client is not updated as it is called only once in Kong::Client#initialize

This results in using the default kong url http://localhost:8001 and not the one set in api_url attribute

LoadError: cannot load such file -- gems/kong-0.3.3/lib/kong/service

When I try to load the last version (0.3.3) of the gem, installed from rubygems, it launches the below error:

$ bundle exec rake assets:precompile
rake aborted!
LoadError: cannot load such file -- /Users/x/.rvm/gems/ruby-2.5.0@global/gems/kong-0.3.3/lib/kong/service
/Users/x/.rvm/gems/ruby-2.5.0@global/gems/kong-0.3.3/lib/kong.rb:5:in `require_relative'
/Users/x/.rvm/gems/ruby-2.5.0@global/gems/kong-0.3.3/lib/kong.rb:5:in `<top (required)>'
...
(See full trace by running task with --trace)

The file lib/kong.rb installed on my machine is pretty different from the one in the repository.

Unable to retrieve JWTs with a Consumer that only has a custom_id

If I create a Kong consumer using only a custom_id (so have no username) I'm unable to retrieve that consumers JWTs using Kong::Consumer.find_by_custom_id("foo").jwts.

I did some digging and in lib/kong/consumer.rb line 94, the client call to get the JWTs is usingclient.get("#{@api_end_point}#{self.username}/jwt") but because username is nil nothing is returned.

Should (or could) this be more like client.get("#{@api_end_point}#{self.username || self.custom_id}/jwt")?

Cannot delete a consumer without a custom_id

Hello,

I tried to call the delete method on a consumer object but it crashed :
Kong::Error: {"message":"An unexpected error occurred"}

The SQL log of my kong server displays :

db_1      | ERROR:  operator does not exist: text = boolean at character 270
db_1      | HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
db_1      | STATEMENT:  SELECT COUNT(*) FROM oauth2_tokens LEFT OUTER JOIN ttls ON (oauth2_tokens.id = ttls.primary_uuid_value) WHERE
db_1      | 	    (ttls.primary_key_value IS NULL OR (ttls.table_name = 'oauth2_tokens' AND expire_at > CURRENT_TIMESTAMP(0) at time zone 'utc')) AND "authenticated_userid" = TRUE

After some investigation, I found what caused the issue : https://github.com/kontena/kong-client-ruby/blob/master/lib/kong/consumer.rb#L68

Since the consumer object I'm working on, does not have a custom_id attribute set, this method send {authenticated_userid:nil } as params which will then be encoded as "authenticated_userid" and then seems to be evaluted to TRUE in PostgreSQL.

I don't know what would be the best way to solve this issue :

  • Edit the Kong::Client#encode_params method to return "param_name=null" in case of nil values.
  • Not sending the authenticated_userid param if custom_id is nil in Kong::Consumer#oauth_tokens method

What do you think ?

Thank you for your work on this gem by the way :)

Cannot set methods when creating API

When adding an API in Kong v0.11.0 there is a semi-optional value methods which is a comma-separated list of HTTP methods that point to the API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.