Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-rack-oauth2 for openSUSE:Factory checked in at 2022-10-29 20:17:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-rack-oauth2 (Old) and /work/SRC/openSUSE:Factory/.rubygem-rack-oauth2.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-rack-oauth2" Sat Oct 29 20:17:19 2022 rev:16 rq:1032162 version:2.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-rack-oauth2/rubygem-rack-oauth2.changes 2022-10-13 15:45:09.299090455 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-rack-oauth2.new.2275/rubygem-rack-oauth2.changes 2022-10-29 20:18:31.734665295 +0200 @@ -1,0 +2,13 @@ +Fri Oct 28 05:04:14 UTC 2022 - Stephan Kulow <co...@suse.com> + +updated to version 2.2.0 + see installed CHANGELOG.md + + ## [2.1.0] - 2022-10-10 + + ### Added + + - accept local_http_config on Rack::OAuth2::Client#access_token! & revoke! to support custom headers etc. by @nov in https://github.com/nov/rack-oauth2/pull/93 + + +------------------------------------------------------------------- Old: ---- rack-oauth2-2.1.0.gem New: ---- rack-oauth2-2.2.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-rack-oauth2.spec ++++++ --- /var/tmp/diff_new_pack.Mpe5Aw/_old 2022-10-29 20:18:32.162667575 +0200 +++ /var/tmp/diff_new_pack.Mpe5Aw/_new 2022-10-29 20:18:32.170667618 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-rack-oauth2 -Version: 2.1.0 +Version: 2.2.0 Release: 0 %define mod_name rack-oauth2 %define mod_full_name %{mod_name}-%{version} ++++++ rack-oauth2-2.1.0.gem -> rack-oauth2-2.2.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2022-10-09 17:04:27.000000000 +0200 +++ new/CHANGELOG.md 2022-10-11 08:45:59.000000000 +0200 @@ -1,5 +1,11 @@ ## [Unreleased] +## [2.1.0] - 2022-10-10 + +### Added + +- accept local_http_config on Rack::OAuth2::Client#access_token! & revoke! to support custom headers etc. by @nov in https://github.com/nov/rack-oauth2/pull/93 + ## [2.0.1] - 2022-10-09 ### Fixed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/VERSION new/VERSION --- old/VERSION 2022-10-09 17:04:27.000000000 +0200 +++ new/VERSION 2022-10-11 08:45:59.000000000 +0200 @@ -1 +1 @@ -2.1.0 \ No newline at end of file +2.2.0 \ No newline at end of file Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rack/oauth2/access_token/legacy.rb new/lib/rack/oauth2/access_token/legacy.rb --- old/lib/rack/oauth2/access_token/legacy.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/lib/rack/oauth2/access_token/legacy.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,19 +0,0 @@ -module Rack - module OAuth2 - class AccessToken - class Legacy < AccessToken - def initialize(attributes = {}) - super - self.expires_in = ( - self.expires_in || - attributes[:expires] - )&.to_i - end - - def authenticate(request) - request.headers["Authorization"] = "OAuth #{access_token}" - end - end - end - end -end \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rack/oauth2/access_token.rb new/lib/rack/oauth2/access_token.rb --- old/lib/rack/oauth2/access_token.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/lib/rack/oauth2/access_token.rb 2022-10-11 08:45:59.000000000 +0200 @@ -39,5 +39,4 @@ require 'rack/oauth2/access_token/authenticator' require 'rack/oauth2/access_token/bearer' -require 'rack/oauth2/access_token/legacy' require 'rack/oauth2/access_token/mtls' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rack/oauth2/client.rb new/lib/rack/oauth2/client.rb --- old/lib/rack/oauth2/client.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/lib/rack/oauth2/client.rb 2022-10-11 08:45:59.000000000 +0200 @@ -68,8 +68,8 @@ @forced_token_type = token_type.to_s end - def access_token!(*args, &local_http_config) - headers, params, http_client, options = authenticated_context_from(*args, &local_http_config) + def access_token!(*args) + headers, params, http_client, options = authenticated_context_from(*args) params[:scope] = Array(options.delete(:scope)).join(' ') if options[:scope].present? params.merge! @grant.as_json params.merge! options @@ -78,12 +78,14 @@ absolute_uri_for(token_endpoint), Util.compact_hash(params), headers - ) + ) do |req| + yield req if block_given? + end end end - def revoke!(*args, &local_http_config) - headers, params, http_client, options = authenticated_context_from(*args, &local_http_config) + def revoke!(*args) + headers, params, http_client, options = authenticated_context_from(*args) params.merge! case when access_token = options.delete(:access_token) @@ -111,7 +113,9 @@ absolute_uri_for(revocation_endpoint), Util.compact_hash(params), headers - ) + ) do |req| + yield req if block_given? + end end end @@ -126,9 +130,9 @@ _endpoint_.to_s end - def authenticated_context_from(*args, &local_http_config) + def authenticated_context_from(*args) headers, params = {}, {} - http_client = Rack::OAuth2.http_client(&local_http_config) + http_client = Rack::OAuth2.http_client # NOTE: # Using Array#extract_options! for backward compatibility. @@ -209,24 +213,19 @@ end def handle_success_response(response) - token_hash = JSON.parse(response.body).with_indifferent_access + token_hash = response.body.with_indifferent_access case (@forced_token_type || token_hash[:token_type])&.downcase when 'bearer' AccessToken::Bearer.new(token_hash) - when nil - AccessToken::Legacy.new(token_hash) else raise 'Unknown Token Type' end - rescue JSON::ParserError - # NOTE: Facebook support (They don't use JSON as token response) - AccessToken::Legacy.new Rack::Utils.parse_nested_query(response.body).with_indifferent_access end def handle_error_response(response) - error = JSON.parse(response.body).with_indifferent_access + error = response.body.with_indifferent_access raise Error.new(response.status, error) - rescue JSON::ParserError + rescue Faraday::ParsingError, NoMethodError raise Error.new(response.status, error: 'Unknown', error_description: response.body) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/rack/oauth2.rb new/lib/rack/oauth2.rb --- old/lib/rack/oauth2.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/lib/rack/oauth2.rb 2022-10-11 08:45:59.000000000 +0200 @@ -44,6 +44,7 @@ Faraday.new(headers: {user_agent: agent_name}) do |faraday| faraday.request :url_encoded faraday.request :json + faraday.response :json faraday.response :logger, Rack::OAuth2.logger, {bodies: true} if debugging? faraday.adapter Faraday.default_adapter local_http_config&.call(faraday) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2022-10-09 17:04:27.000000000 +0200 +++ new/metadata 2022-10-11 08:45:59.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: rack-oauth2 version: !ruby/object:Gem::Version - version: 2.1.0 + version: 2.2.0 platform: ruby authors: - nov matake autorequire: bindir: bin cert_chain: [] -date: 2022-10-09 00:00:00.000000000 Z +date: 2022-10-11 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rack @@ -201,7 +201,6 @@ - lib/rack/oauth2/access_token.rb - lib/rack/oauth2/access_token/authenticator.rb - lib/rack/oauth2/access_token/bearer.rb -- lib/rack/oauth2/access_token/legacy.rb - lib/rack/oauth2/access_token/mtls.rb - lib/rack/oauth2/client.rb - lib/rack/oauth2/client/error.rb @@ -250,18 +249,14 @@ - rack-oauth2.gemspec - spec/helpers/time.rb - spec/helpers/webmock_helper.rb -- spec/mock_response/blank +- spec/mock_response/blank.txt - spec/mock_response/errors/invalid_request.json - spec/mock_response/resources/fake.txt - spec/mock_response/tokens/_Bearer.json - spec/mock_response/tokens/bearer.json -- spec/mock_response/tokens/legacy.json -- spec/mock_response/tokens/legacy.txt -- spec/mock_response/tokens/legacy_without_expires_in.txt - spec/mock_response/tokens/unknown.json - spec/rack/oauth2/access_token/authenticator_spec.rb - spec/rack/oauth2/access_token/bearer_spec.rb -- spec/rack/oauth2/access_token/legacy_spec.rb - spec/rack/oauth2/access_token_spec.rb - spec/rack/oauth2/client/error_spec.rb - spec/rack/oauth2/client/grant/authorization_code_spec.rb @@ -321,18 +316,14 @@ test_files: - spec/helpers/time.rb - spec/helpers/webmock_helper.rb -- spec/mock_response/blank +- spec/mock_response/blank.txt - spec/mock_response/errors/invalid_request.json - spec/mock_response/resources/fake.txt - spec/mock_response/tokens/_Bearer.json - spec/mock_response/tokens/bearer.json -- spec/mock_response/tokens/legacy.json -- spec/mock_response/tokens/legacy.txt -- spec/mock_response/tokens/legacy_without_expires_in.txt - spec/mock_response/tokens/unknown.json - spec/rack/oauth2/access_token/authenticator_spec.rb - spec/rack/oauth2/access_token/bearer_spec.rb -- spec/rack/oauth2/access_token/legacy_spec.rb - spec/rack/oauth2/access_token_spec.rb - spec/rack/oauth2/client/error_spec.rb - spec/rack/oauth2/client/grant/authorization_code_spec.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/helpers/webmock_helper.rb new/spec/helpers/webmock_helper.rb --- old/spec/helpers/webmock_helper.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/helpers/webmock_helper.rb 2022-10-11 08:45:59.000000000 +0200 @@ -28,7 +28,13 @@ def response_for(response_file, options = {}) response = {} - response[:body] = File.new(File.join(File.dirname(__FILE__), '../mock_response', response_file)) + format = options[:format] || :json + if format == :json + response[:headers] = { + 'Content-Type': 'application/json' + } + end + response[:body] = File.new(File.join(File.dirname(__FILE__), '../mock_response', "#{response_file}.#{format}")) if options[:status] response[:status] = options[:status] end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mock_response/tokens/legacy.json new/spec/mock_response/tokens/legacy.json --- old/spec/mock_response/tokens/legacy.json 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/mock_response/tokens/legacy.json 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +0,0 @@ -{ - "access_token":"access_token", - "refresh_token":"refresh_token", - "expires_in":3600 -} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mock_response/tokens/legacy.txt new/spec/mock_response/tokens/legacy.txt --- old/spec/mock_response/tokens/legacy.txt 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/mock_response/tokens/legacy.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -access_token=access_token&expires=3600 \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mock_response/tokens/legacy_without_expires_in.txt new/spec/mock_response/tokens/legacy_without_expires_in.txt --- old/spec/mock_response/tokens/legacy_without_expires_in.txt 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/mock_response/tokens/legacy_without_expires_in.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -access_token=access_token \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/rack/oauth2/access_token/authenticator_spec.rb new/spec/rack/oauth2/access_token/authenticator_spec.rb --- old/spec/rack/oauth2/access_token/authenticator_spec.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/rack/oauth2/access_token/authenticator_spec.rb 2022-10-11 08:45:59.000000000 +0200 @@ -12,15 +12,6 @@ end end - context 'when Legacy token is given' do - let(:token) do - Rack::OAuth2::AccessToken::Legacy.new( - access_token: 'access_token' - ) - end - it_behaves_like :authenticator - end - context 'when Bearer token is given' do let(:token) do Rack::OAuth2::AccessToken::Bearer.new( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/rack/oauth2/access_token/legacy_spec.rb new/spec/rack/oauth2/access_token/legacy_spec.rb --- old/spec/rack/oauth2/access_token/legacy_spec.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/rack/oauth2/access_token/legacy_spec.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe Rack::OAuth2::AccessToken::Legacy do - let :token do - Rack::OAuth2::AccessToken::Legacy.new( - access_token: 'access_token' - ) - end - let(:resource_endpoint) { 'https://server.example.com/resources/fake' } - let(:request) { Faraday::Request.new(:post, URI.parse(resource_endpoint), '', {hello: "world"}, {}) } - - describe '#to_s' do - subject { token } - its(:to_s) { should == token.access_token } - end - - describe '.authenticate' do - it 'should set Authorization header' do - expect(request.headers).to receive(:[]=).with('Authorization', 'OAuth access_token') - token.authenticate(request) - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/rack/oauth2/client_spec.rb new/spec/rack/oauth2/client_spec.rb --- old/spec/rack/oauth2/client_spec.rb 2022-10-09 17:04:27.000000000 +0200 +++ new/spec/rack/oauth2/client_spec.rb 2022-10-11 08:45:59.000000000 +0200 @@ -93,7 +93,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', request_header: { 'Authorization' => 'Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=' } @@ -109,7 +109,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', request_header: { 'Authorization' => 'Basic aHR0cHMlM0ElMkYlMkZjbGllbnQuZXhhbXBsZS5jb206Y2xpZW50X3NlY3JldA==' } @@ -127,7 +127,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', request_header: { 'Authorization' => 'Basic aHR0cHM6Ly9jbGllbnQuZXhhbXBsZS5jb206Y2xpZW50X3NlY3JldA==' } @@ -143,7 +143,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { client_assertion: /^eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9\..+/, # NOTE: HS256 client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER, @@ -171,7 +171,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { client_assertion: /^eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9\..+/, # NOTE: RS256 client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER, @@ -198,7 +198,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { client_assertion: /^eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9\..+/, # NOTE: ES256 client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER, @@ -225,7 +225,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { client_assertion: 'any.jwt.assertion', client_assertion_type: Rack::OAuth2::URN::ClientAssertionType::JWT_BEARER, @@ -244,7 +244,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { client_id: 'client_id', client_secret: 'client_secret', @@ -262,7 +262,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { client_id: 'client_id', client_secret: 'client_secret', @@ -282,7 +282,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { grant_type: 'client_credentials', scope: 'a b' @@ -298,7 +298,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', params: { grant_type: 'client_credentials', resource: 'something' @@ -314,14 +314,14 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json', + 'tokens/bearer', request_header: { 'Authorization' => 'Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=', 'X-Foo' => 'bar' } ) client.access_token! do |request| - request.headers.merge! 'X-Foo' => 'bar' + request.headers['X-Foo'] = 'bar' end end end @@ -332,7 +332,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/bearer.json' + 'tokens/bearer' ) end it { should be_instance_of Rack::OAuth2::AccessToken::Bearer } @@ -347,7 +347,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/_Bearer.json' + 'tokens/_Bearer' ) end it { should be_instance_of Rack::OAuth2::AccessToken::Bearer } @@ -355,62 +355,13 @@ end end - context 'when no-type token is given (JSON)' do - before do - client.authorization_code = 'code' - mock_response( - :post, - 'https://server.example.com/oauth2/token', - 'tokens/legacy.json' - ) - end - it { should be_instance_of Rack::OAuth2::AccessToken::Legacy } - its(:token_type) { should == :legacy } - its(:access_token) { should == 'access_token' } - its(:refresh_token) { should == 'refresh_token' } - its(:expires_in) { should == 3600 } - - context 'when token_type is forced' do - before do - client.force_token_type! :bearer - end - it { should be_instance_of Rack::OAuth2::AccessToken::Bearer } - its(:token_type) { should == :bearer } - end - end - - context 'when no-type token is given (key-value)' do - before do - mock_response( - :post, - 'https://server.example.com/oauth2/token', - 'tokens/legacy.txt' - ) - end - it { should be_instance_of Rack::OAuth2::AccessToken::Legacy } - its(:token_type) { should == :legacy } - its(:access_token) { should == 'access_token' } - its(:expires_in) { should == 3600 } - - context 'when expires_in is not given' do - before do - mock_response( - :post, - 'https://server.example.com/oauth2/token', - 'tokens/legacy_without_expires_in.txt' - ) - end - its(:expires_in) { should be_nil } - end - end - context 'when unknown-type token is given' do before do client.authorization_code = 'code' mock_response( :post, 'https://server.example.com/oauth2/token', - 'tokens/unknown.json' + 'tokens/unknown' ) end it do @@ -423,7 +374,7 @@ mock_response( :post, 'https://server.example.com/oauth2/token', - 'errors/invalid_request.json', + 'errors/invalid_request', status: 400 ) end @@ -439,6 +390,7 @@ :post, 'https://server.example.com/oauth2/token', 'blank', + format: 'txt', status: 400 ) end @@ -456,6 +408,7 @@ :post, 'https://server.example.com/oauth2/revoke', 'blank', + format: 'txt', status: 200, body: { token: 'access_token', @@ -467,7 +420,7 @@ } ) client.revoke!(access_token: 'access_token') do |request| - request.headers.merge! 'X-Foo' => 'bar' + request.headers['X-Foo'] = 'bar' end end end @@ -478,6 +431,7 @@ :post, 'https://server.example.com/oauth2/revoke', 'blank', + format: 'txt', status: 200, body: { token: 'access_token', @@ -496,6 +450,7 @@ :post, 'https://server.example.com/oauth2/revoke', 'blank', + format: 'txt', status: 200, body: { token: 'refresh_token', @@ -523,7 +478,7 @@ mock_response( :post, 'https://server.example.com/oauth2/revoke', - 'errors/invalid_request.json', + 'errors/invalid_request', status: 400 ) end