Skip to content

Commit

Permalink
docs: Include note about validating externally-provided credentials (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma authored Jan 22, 2025
1 parent 96f5058 commit 2147b31
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ well as a web variant tailored toward Rack-based applications.
The authorizers are intended for authorization use cases. For sign-on,
see [Google Identity Platform](https://developers.google.com/identity/)

## Important notes

If you accept a credential configuration (credential JSON/File/Stream) from an
external source for authentication to Google Cloud, you must validate it before
providing it to any Google API or library. Providing an unvalidated credential
configuration to Google APIs can compromise the security of your systems and data.
For more information, refer to [Validate credential configurations from external
sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).

### Example (Web)

```ruby
Expand Down
8 changes: 8 additions & 0 deletions lib/googleauth/credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ module Auth
# In most cases, it is subclassed by API-specific credential classes that
# can be instantiated by clients.
#
# **Important:** If you accept a credential configuration (credential
# JSON/File/Stream) from an external source for authentication to Google
# Cloud, you must validate it before providing it to any Google API or
# library. Providing an unvalidated credential configuration to Google APIs
# can compromise the security of your systems and data. For more
# information, refer to [Validate credential configurations from external
# sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
#
# ## Options
#
# Credentials classes are configured with options that dictate default
Expand Down
12 changes: 11 additions & 1 deletion lib/googleauth/default_credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ module Auth
class DefaultCredentials
extend CredentialsLoader

# override CredentialsLoader#make_creds to use the class determined by
##
# Override CredentialsLoader#make_creds to use the class determined by
# loading the json.
#
# **Important:** If you accept a credential configuration (credential
# JSON/File/Stream) from an external source for authentication to Google
# Cloud, you must validate it before providing it to any Google API or
# library. Providing an unvalidated credential configuration to Google
# APIs can compromise the security of your systems and data. For more
# information, refer to [Validate credential configurations from external
# sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
#
def self.make_creds options = {}
json_key_io = options[:json_key_io]
if json_key_io
Expand Down

0 comments on commit 2147b31

Please sign in to comment.