Skip to content
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

docs: Include note about validating externally-provided credentials #512

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading