-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Better credential workflow #444
Conversation
`google_clien_email` is an auth option that was leftover from PKCS12 key days and is no longer required as it is baked into all json keys and is no longer supplied to any auth method
- Separate different auth streams into private methods - Separated some logic into helper methods - Switch to File.read when loading up JSON key - Do not decode/re-encode JSON keys when loading up auth - Add a warning if we’re falling back on Google Application Default auth
lib/fog/google/shared.rb
Outdated
validate_json_credentials(json_key) | ||
|
||
::Google::Auth::ServiceAccountCredentials.make_creds( | ||
:json_key_io => StringIO.new(json_key), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
lib/fog/google/shared.rb
Outdated
def process_application_default_auth(options) | ||
begin | ||
return ::Google::Auth.get_application_default(options[:google_api_scope_url]) | ||
rescue RuntimeError => e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/UselessAssignment: Useless assignment to variable - e.
# @param [Hash] options - client options hash | ||
# @return [Google::Auth::DefaultCredentials] - google auth object | ||
def process_application_default_auth(options) | ||
begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RedundantBegin: Redundant begin block detected.
lib/fog/google/shared.rb
Outdated
|
||
if auth.nil? | ||
raise Fog::Errors::Error.new( | ||
"Failed to configure authentication for Fog client.\n" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
lib/fog/google/shared.rb
Outdated
auth = ::Google::Auth.get_application_default( | ||
options[:google_api_scope_url] | ||
Fog::Logger.warning( | ||
"Didn't detect any explicit auth settings, " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
Codecov Report
@@ Coverage Diff @@
## master #444 +/- ##
==========================================
- Coverage 85.31% 85.27% -0.05%
==========================================
Files 339 339
Lines 5829 5840 +11
==========================================
+ Hits 4973 4980 +7
- Misses 856 860 +4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Temikus Looks much easier to follow. I noted one configuration edge-case that I could reproduce.
I have a few more documentation nits that I haven't added so feel free to tag me once you're ready for a second set of eyes.
application_default -> google_application_default to follow convention
lib/fog/google/shared.rb
Outdated
return process_application_default_auth(options) | ||
rescue | ||
raise Fog::Errors::Error.new( | ||
"Fallback auth failed, could not configure authentication for Fog client.\n" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
) | ||
begin | ||
return process_application_default_auth(options) | ||
rescue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/RescueStandardError: Avoid rescuing without specifying an error class.
lib/fog/google/shared.rb
Outdated
# @return [Google::Auth::DefaultCredentials] - google auth object | ||
def process_fallback_auth(options) | ||
Fog::Logger.warning( | ||
"Didn't detect any client auth settings, " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
@Mavin Reworked a bit according to your comments, now only fallback has a more user-friendly message covering the exceptions underneath but explicit application default auth will not rescue any exceptions. PTAL and thanks again for the review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation nits
lib/fog/google/shared.rb
Outdated
# @option options [Google::Auth|Signet] :google_auth Manually created authorization to use | ||
# @option options [String] :google_client_email A @developer.gserviceaccount.com email address to use | ||
# @option options [String] :google_key_location The location of a pkcs12 key file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm not sure how ruby docs work but can this be removed since they have been deprecated for a while?
lib/fog/google/shared.rb
Outdated
# @option options [Google::Auth|Signet] :google_auth Manually created authorization to use | ||
# @option options [String] :google_client_email A @developer.gserviceaccount.com email address to use | ||
# @option options [String] :google_key_location The location of a pkcs12 key file | ||
# @option options [String] :google_key_string The content of the pkcs12 key file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and :google_client
:LGTM: Now merge and release so I can get to work on mitchellh/vagrant-google#194 😁 |
@Mavin will roll out the RC sometime today. Thank you so much for your input and review! |
This PR centers around:
google_client_email
parameter everywhere