akamai / akamaiopen-edgegrid-ruby Goto Github PK
View Code? Open in Web Editor NEWThis library implements the Akamai OPEN EdgeGrid Authentication scheme for the ruby net/http library.
License: Apache License 2.0
This library implements the Akamai OPEN EdgeGrid Authentication scheme for the ruby net/http library.
License: Apache License 2.0
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?
can we consider moving the get_host
method out of the Object
namespace?
(maybe into Akamai::Edgegrid
... ie. called as Akamai::Edgegrid.get_host()
)
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.
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.