lib/submodules/ably-ruby/lib/ably/realtime/auth.rb in ably-rest-0.8.15 vs lib/submodules/ably-ruby/lib/ably/realtime/auth.rb in ably-rest-0.9.0

- old
+ new

@@ -52,42 +52,54 @@ # Ensures valid auth credentials are present for the library instance. This may rely on an already-known and valid token, and will obtain a new token if necessary. # # In the event that a new token request is made, the provided options are used # - # @param (see Ably::Auth#authorise) - # @option (see Ably::Auth#authorise) + # @param (see Ably::Auth#authorize) + # @option (see Ably::Auth#authorize) # # @return [Ably::Util::SafeDeferrable] # @yield [Ably::Models::TokenDetails] # # @example # # will issue a simple token request using basic auth # client = Ably::Rest::Client.new(key: 'key.id:secret') - # client.auth.authorise do |token_details| + # client.auth.authorize do |token_details| # token_details #=> Ably::Models::TokenDetails # end # - def authorise(token_params = nil, auth_options = nil, &success_callback) + def authorize(token_params = nil, auth_options = nil, &success_callback) async_wrap(success_callback) do - auth_sync.authorise(token_params, auth_options, &method(:upgrade_authentication_block).to_proc) + auth_sync.authorize(token_params, auth_options, &method(:upgrade_authentication_block).to_proc) end.tap do |deferrable| deferrable.errback do |error| client.connection.transition_state_machine :failed, reason: error if error.kind_of?(Ably::Exceptions::IncompatibleClientId) end end end - # Synchronous version of {#authorise}. See {Ably::Auth#authorise} for method definition - # @param (see Ably::Auth#authorise) - # @option (see Ably::Auth#authorise) + # @deprecated Use {#authorize} instead + def authorise(*args, &block) + logger.warn "Auth#authorise is deprecated and will be removed in 1.0. Please use Auth#authorize instead" + authorize(*args, &block) + end + + # Synchronous version of {#authorize}. See {Ably::Auth#authorize} for method definition + # @param (see Ably::Auth#authorize) + # @option (see Ably::Auth#authorize) # @return [Ably::Models::TokenDetails] # - def authorise_sync(token_params = nil, auth_options = nil) - auth_sync.authorise(token_params, auth_options, &method(:upgrade_authentication_block).to_proc) + def authorize_sync(token_params = nil, auth_options = nil) + auth_sync.authorize(token_params, auth_options, &method(:upgrade_authentication_block).to_proc) end + # @deprecated Use {#authorize_sync} instead + def authorise_sync(*args) + logger.warn "Auth#authorise_sync is deprecated and will be removed in 1.0. Please use Auth#authorize_sync instead" + authorize_sync(*args) + end + # def_delegator :auth_sync, :request_token, :request_token_sync # def_delegator :auth_sync, :create_token_request, :create_token_request_sync # def_delegator :auth_sync, :auth_header, :auth_header_sync # def_delegator :auth_sync, :auth_params, :auth_params_sync @@ -111,12 +123,12 @@ request_token_sync(token_params, auth_options) end end # Synchronous version of {#request_token}. See {Ably::Auth#request_token} for method definition - # @param (see Ably::Auth#authorise) - # @option (see Ably::Auth#authorise) + # @param (see Ably::Auth#authorize) + # @option (see Ably::Auth#authorize) # @return [Ably::Models::TokenDetails] # def request_token_sync(token_params = {}, auth_options = {}) auth_sync.request_token(token_params, auth_options) end @@ -138,20 +150,20 @@ create_token_request_sync(token_params, auth_options) end end # Synchronous version of {#create_token_request}. See {Ably::Auth#create_token_request} for method definition - # @param (see Ably::Auth#authorise) - # @option (see Ably::Auth#authorise) + # @param (see Ably::Auth#authorize) + # @option (see Ably::Auth#authorize) # @return [Ably::Models::TokenRequest] # def create_token_request_sync(token_params = {}, auth_options = {}) auth_sync.create_token_request(token_params, auth_options) end # Auth header string used in HTTP requests to Ably - # Will reauthorise implicitly if required and capable + # Will reauthorize implicitly if required and capable # # @return [Ably::Util::SafeDeferrable] # @yield [String] HTTP authentication value used in HTTP_AUTHORIZATION header # def auth_header(&success_callback) @@ -166,11 +178,11 @@ def auth_header_sync auth_sync.auth_header end # Auth params used in URI endpoint for Realtime connections - # Will reauthorise implicitly if required and capable + # Will reauthorize implicitly if required and capable # # @return [Ably::Util::SafeDeferrable] # @yield [Hash] Auth params for a new Realtime connection # def auth_params(&success_callback) @@ -195,15 +207,15 @@ def client @client end - # If authorise is called with true, this block is executed so that it + # If authorize is called with true, this block is executed so that it # can perform the authentication upgrade def upgrade_authentication_block(new_token) # This block is called if the authorisation was forced if client.connection.connected? || client.connection.connecting? - logger.debug "Realtime::Auth - authorise called with { force: true } so forcibly disconnecting transport to initiate auth upgrade" + logger.debug "Realtime::Auth - authorize was called so forcibly disconnecting transport to initiate auth upgrade" block = Proc.new do if client.connection.transport logger.debug "Realtime::Auth - current transport disconnected" client.connection.transport.disconnect else