bigbluebutton-api-ruby 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25726eaedf0a5b63156a7786a793f27a419e349a177419fdaecb0e0aac0295d6
4
- data.tar.gz: 6e8ec707b2f53e06ba21163d2f5d34766436e49f852991434d3aa787a4108deb
3
+ metadata.gz: d0441812c16477d28d431e085349d9b41dbb2487fa2714658d0f4257bfbfc696
4
+ data.tar.gz: d6ef204678952d1890225b2e66dd17e7aafb2a20733ffd2733b6a99c3a9383f1
5
5
  SHA512:
6
- metadata.gz: 810382ae7b2f54be6ac766e10db46a61f76a4120c84bb1a99600012266db562da53149d7ee0bde1c7a2b3939542398556a7faa85dd24153c669f04875ac90213
7
- data.tar.gz: 229132ef71db18f0a972daefb0b5b0ad49c53c63655877923323a163f99d15b383d4f0ac7344ebba61a6b5961f3a08abc2dc50a9ef217d4eccf0fcbfc2fdc527
6
+ metadata.gz: 8a62b74b9922d8eae4ad5f28be54e5975c0bbc7e267a7da457f3c307ca3199a3bf82f6acc2361e419df9c7a3277882e66cf10ba9cd52f60f23f6a3a8a8e88faa
7
+ data.tar.gz: 8630d39007e82a5d3e0fd0ea623e51138a62726e1778170d03db1150220196906b7665d9caab3e4cf9b85eeebf11445ae7302670048ee8eee4fc7f7e2773235b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## [1.9.0] - 2022-05-03
4
+ * [#56] Add support for checksum using SHA256
5
+
6
+ [#56]: https://github.com/mconf/bigbluebutton-api-ruby/pull/56
7
+ [1.9.0]: https://github.com/mconf/bigbluebutton-api-ruby/compare/v1.8.0...v1.9.0
8
+
3
9
  ## [1.8.0] - 2021-12-06
4
10
  * [#43] Add keys to every `BigBlueButtonException`, to better identify them.
5
11
  * [#42] Change `BigBlueButtonException` to inherit from `StandardError` instead of `Exception`.
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- bigbluebutton-api-ruby (1.8.0)
10
+ bigbluebutton-api-ruby (1.9.0)
11
11
  childprocess (>= 1.0.1)
12
12
  ffi (>= 1.9.24)
13
13
  json (>= 1.8.6)
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "bigbluebutton-api-ruby"
5
- s.version = "1.8.0"
5
+ s.version = "1.9.0"
6
6
  s.licenses = ["MIT"]
7
7
  s.extra_rdoc_files = ["README.md", "LICENSE", "LICENSE_003", "CHANGELOG.md"]
8
8
  s.summary = "BigBlueButton integration for ruby"
@@ -2,6 +2,7 @@ require 'net/http'
2
2
  require 'cgi'
3
3
  require 'rexml/document'
4
4
  require 'digest/sha1'
5
+ require 'digest/sha2'
5
6
  require 'rubygems'
6
7
  require 'bigbluebutton_hash_to_xml'
7
8
  require 'bigbluebutton_exception'
@@ -68,13 +69,17 @@ module BigBlueButton
68
69
  # url:: URL to a BigBlueButton server (e.g. http://demo.bigbluebutton.org/bigbluebutton/api)
69
70
  # secret:: Shared secret for this server
70
71
  # version:: API version e.g. 0.81
71
- def initialize(url, secret, version=nil, logger=nil)
72
+ # logger:: Logger object to log actions (so apps can use their own loggers)
73
+ # sha256:: Flag to use sha256 when hashing url contents for checksum
74
+ def initialize(url, secret, version=nil, logger=nil, sha256=false)
72
75
  @supported_versions = ['0.8', '0.81', '0.9', '1.0']
73
76
  @url = url
74
77
  @secret = secret
75
78
  @timeout = 10 # default timeout for api requests
76
79
  @request_headers = {} # http headers sent in all requests
77
80
  @logger = logger
81
+ @sha256 = sha256
82
+ # If logger is not informed, it defaults to STDOUT with INFO level
78
83
  if logger.nil?
79
84
  @logger = Logger.new(STDOUT)
80
85
  @logger.level = Logger::INFO
@@ -680,7 +685,7 @@ module BigBlueButton
680
685
  # checksum calc
681
686
  checksum_param = params_string + @secret
682
687
  checksum_param = method.to_s + checksum_param
683
- checksum = Digest::SHA1.hexdigest(checksum_param)
688
+ checksum = @sha256 ? Digest::SHA256.hexdigest(checksum_param) : Digest::SHA1.hexdigest(checksum_param)
684
689
 
685
690
  if method == :setConfigXML
686
691
  params_string = "checksum=#{checksum}&#{params_string}"
@@ -474,17 +474,34 @@ describe BigBlueButton::BigBlueButtonApi do
474
474
  end
475
475
 
476
476
  context "includes the checksum" do
477
- let(:params) { { :param1 => "value1", :param2 => "value2" } }
478
- let(:checksum) {
479
- # the hash can be sorted differently depending on the ruby version
480
- if params.map{ |k,v| k }.join =~ /^param1/
481
- "67882ae54f49600f56f358c10d24697ef7d8c6b2"
482
- else
483
- "85a54e28e4ec18bfdcb214a73f74d35b09a84176"
484
- end
485
- }
486
- subject { api.get_url(:join, params)[0] }
487
- it { subject.should match(/checksum=#{checksum}$/) }
477
+ context "when @sha256 is false or nil" do
478
+ let(:params) { { param1: "value1", param2: "value2" } }
479
+ let(:checksum) {
480
+ # the hash can be sorted differently depending on the ruby version
481
+ if params.map{ |k, v| k }.join =~ /^param1/
482
+ "67882ae54f49600f56f358c10d24697ef7d8c6b2"
483
+ else
484
+ "85a54e28e4ec18bfdcb214a73f74d35b09a84176"
485
+ end
486
+ }
487
+ subject { api.get_url(:join, params)[0] }
488
+ it('uses SHA1') { subject.should match(/checksum=#{checksum}$/) }
489
+ end
490
+
491
+ context "when @sha256 flag is true" do
492
+ let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger, true) }
493
+ let(:params) { { param1: "value1", param2: "value2" } }
494
+ let(:checksum) {
495
+ # the hash can be sorted differently depending on the ruby version
496
+ if params.map{ |k,v| k }.join =~ /^param1/
497
+ "0e7b1611809fad890a114dddae1a37fecf14c28971afc10ee3eac432da5b8b41"
498
+ else
499
+ "21bf2d24c27251c4b2b2f0d5dd4b966a2f16fbfc7882e102b44c6d67f728f0c8"
500
+ end
501
+ }
502
+ subject { api.get_url(:join, params)[0] }
503
+ it('uses SHA256') { subject.should match(/checksum=#{checksum}$/) }
504
+ end
488
505
  end
489
506
  end
490
507
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigbluebutton-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mconf
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-12-06 00:00:00.000000000 Z
12
+ date: 2022-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess