Git Product home page Git Product logo

akamaiopen-edgegrid-ruby's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

akamaiopen-edgegrid-ruby's Issues

Missing mandatory parameter issue

Hello, I am attempting to call an akamai SIEM endpoint using the edgegrid ruby gem.

Below is my code but I get missing mandatory parameter and unknown as to why as the akamai documentation does not have any more required params than what I am giving it already.

require 'akamai/edgegrid'
require 'net/http'
require 'uri'

baseuri = URI('https://<>.luna.akamaiapis.net/')

http = Akamai::Edgegrid::HTTP.new(
    address=baseuri.host,
    port=baseuri.port
)

http.setup_edgegrid(
    :client_token => '<>',
    :client_secret => '<>',
    :access_token => '<>',
    :max_body => 128 * 1024
)

puts "client setup complete"

# example of simple GET request
request = Net::HTTP::Get.new URI.join(baseuri.to_s, '/siem/v1/configs/33314').to_s
response = http.request(request)
puts response.body

For obvious reasons, I have redacted the host details and authorization details.

The output of the above is:

{
"type": "https://problems.cloudsecurity.akamaiapis.net/siem/v1/missing-parameters",
"title": "Missing mandatory parameter(s) or illegal parameter(s) in the request",
"instance": "https://<>/siem/v1/configs/33314",
"detail": "Missing mandatory parameter(s) or illegal parameter(s) in the request",
"method": "GET",
"serverIp": "<>",
"clientIp": "<>",
"requestId": "4a3717f6",
"requestTime": "2024-01-03T21:04:38Z"
}

Any suggestions as to what I could be doing incorrect?

Need to add base64 into the gemspec

I got the warning with Ruby 3.3.0. I assume the gemspec need to have base64 gem in it.

$HOME/vendor/bundle/ruby/3.3.0/gems/akamai-edgegrid-1.0.7/lib/akamai/edgegrid.rb:25: warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of akamai-edgegrid-1.0.7 to add base64 into its gemspec.

Net::HTTP handles URIs and Strings differently

There's a bit of a tricky issue with how Net::HTTP handles strings and URIs. If you pass it a string, as the example does:

request = Net::HTTP::Get.new(URI(baseuri + path).to_s)

then everything works fine, because the request object has a nil uri and a valid path, which the library turns into a URI inside make_data_to_sign:

url = URI(request.path)

But if you pass it a URI object instead:

request = Net::HTTP::Get.new(URI(baseuri + path))

then it breaks, because now the request object has a valid uri and a path that doesn't include the entire string. The library then fails because request.path doesn't have a scheme, so the URI that's created isn't a URI::HTTP or URI::HTTPS, it's a URI::Generic, which doesn't respond to #request_uri.

I think the right answer here is to make make_data_to_sign slightly more flexible:
url = request.uri || URI(request.path)
which should handle both cases.

Error with 401

I wrote a program to get the cidr-blocks in 2019. And then the token is stored in the /root/.edgerc.
It worked very well. However, In 2021, I received some errors about 401 error as below. The token is not expired even now.

"title": "Not authorized",\n "status": 401,\n "detail": "Inactive client token"

I noticed there were some new changes in the Python project. Does it mean the latest fixes are not applied to this project?

Thank you.

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.