From 7888de8f4d62332bc785327225977313ab01ad8e Mon Sep 17 00:00:00 2001 From: Carl Reiner Date: Thu, 8 May 2025 11:48:53 -0700 Subject: [PATCH 1/3] Remove oob fallback --- lib/aws/google.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/aws/google.rb b/lib/aws/google.rb index dd235ed..b98c465 100644 --- a/lib/aws/google.rb +++ b/lib/aws/google.rb @@ -108,7 +108,7 @@ def silence_output end def get_oauth_code(client, options) - raise 'fallback' unless @port && !@port.zero? + raise ArgumentError.new('Missing port for local oauth server') unless @port && !@port.zero? require 'launchy' require 'webrick' @@ -135,20 +135,17 @@ def get_oauth_code(client, options) end end while server_thread.alive? - raise 'fallback' if !launchy.alive? && !launchy.value.success? + unless launchy.alive? && launchy.value.success? + server.shutdown + raise RuntimeError.new('Failed to launch browser with Launchy') + end sleep 0.1 end end - code || raise('fallback') - rescue StandardError + code || raise('Local Google Oauth failed to get code') + ensure trap('INT', 'DEFAULT') - # Fallback to out-of-band authentication if browser launch failed. - client.redirect_uri = 'oob' - return ENV['OAUTH_CODE'] if ENV['OAUTH_CODE'] - - raise RuntimeError, 'Open the following URL in a browser to get a code,' \ - "export to $OAUTH_CODE and rerun:\n#{client.authorization_uri(options)}", [] end def refresh From 94e57e4963062fd61fd5d9a821198bccb94b0093 Mon Sep 17 00:00:00 2001 From: Carl Reiner Date: Fri, 9 May 2025 15:24:10 -0700 Subject: [PATCH 2/3] remove launchy liveness check --- lib/aws/google.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/aws/google.rb b/lib/aws/google.rb index b98c465..8694b7a 100644 --- a/lib/aws/google.rb +++ b/lib/aws/google.rb @@ -112,20 +112,24 @@ def get_oauth_code(client, options) require 'launchy' require 'webrick' + code = nil server = WEBrick::HTTPServer.new( Port: @port, Logger: WEBrick::Log.new(STDOUT, 0), AccessLog: [] ) + server.mount_proc '/' do |req, res| code = req.query['code'] res.status = 202 res.body = 'Login successful, you may close this browser window.' - server.stop + server.shutdown end + trap('INT') { server.shutdown } client.redirect_uri = "http://localhost:#{@port}" + silence_output do launchy = Launchy.open(client.authorization_uri(options).to_s) server_thread = Thread.new do @@ -134,15 +138,10 @@ def get_oauth_code(client, options) ensure server.shutdown end end - while server_thread.alive? - unless launchy.alive? && launchy.value.success? - server.shutdown - raise RuntimeError.new('Failed to launch browser with Launchy') - end - - sleep 0.1 - end + + server_thread.join end + code || raise('Local Google Oauth failed to get code') ensure trap('INT', 'DEFAULT') From 3421368fe8b3f165980d088d5ee56fb285b4b727 Mon Sep 17 00:00:00 2001 From: Darin Webb Date: Wed, 14 May 2025 10:51:58 -0500 Subject: [PATCH 3/3] version 0.2.3 --- lib/aws/google/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aws/google/version.rb b/lib/aws/google/version.rb index cb5cb00..9b5269a 100644 --- a/lib/aws/google/version.rb +++ b/lib/aws/google/version.rb @@ -1,5 +1,5 @@ module Aws class Google - VERSION = '0.2.2'.freeze + VERSION = '0.2.3'.freeze end end