-
Notifications
You must be signed in to change notification settings - Fork 568
feat(translate-v2): enable self-signed JWT by default #33974
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
Open
quartzmo
wants to merge
1
commit into
googleapis:main
Choose a base branch
from
quartzmo:translate-v2-ssjwt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+49
−12
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,8 @@ gemspec | |
|
|
||
| gem "google-cloud-core", path: "../google-cloud-core" | ||
| gem "google-cloud-errors", path: "../google-cloud-errors" | ||
| gem "google-style", "~> 1.30.1" | ||
| gem "google-style", "~> 1.31.1" | ||
| gem "ostruct" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: add a version, like ~> 0.6.3 |
||
| gem "minitest", "~> 5.16" | ||
| gem "minitest-focus", "~> 1.1" | ||
| gem "minitest-rg", "~> 5.2" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,7 @@ module V2 | |
| # translation = translate.translate "Hello world!", to: "la" | ||
| # translation.text #=> "Salve mundi!" | ||
| # | ||
| def self.new project_id: nil, credentials: nil, key: nil, scope: nil, retries: nil, timeout: nil, endpoint: nil | ||
| def self.new project_id: nil, credentials: nil, key: nil, scope: nil, retries: nil, timeout: nil, endpoint: nil, enable_self_signed_jwt: nil | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docstring for |
||
| project_id ||= default_project_id | ||
|
|
||
| configuration = translation_config | ||
|
|
@@ -116,10 +116,18 @@ def self.new project_id: nil, credentials: nil, key: nil, scope: nil, retries: n | |
| end | ||
|
|
||
| scope ||= configuration&.scope | ||
| credentials ||= default_credentials scope: scope | ||
|
|
||
| if enable_self_signed_jwt.nil? | ||
| # Use self-signed JWT if the endpoint is unchanged from default (nil or default host). | ||
| # This logic is adapted from gapic-generator-ruby templates, | ||
| # simplified here since the default host is known to be global. | ||
| enable_self_signed_jwt = endpoint.nil? || endpoint == Service::API_HOST | ||
| end | ||
|
|
||
| credentials ||= default_credentials scope: scope, enable_self_signed_jwt: enable_self_signed_jwt | ||
|
|
||
| unless credentials.is_a? Google::Auth::Credentials | ||
| credentials = Google::Cloud::Translate::V2::Credentials.new credentials, scope: scope | ||
| credentials = Google::Cloud::Translate::V2::Credentials.new credentials, { scope: scope, enable_self_signed_jwt: enable_self_signed_jwt } | ||
| end | ||
|
|
||
| project_id = resolve_project_id project_id, credentials | ||
|
|
@@ -143,13 +151,13 @@ def self.default_project_id | |
|
|
||
| ## | ||
| # @private Default credentials. | ||
| def self.default_credentials scope: nil | ||
| def self.default_credentials scope: nil, enable_self_signed_jwt: nil | ||
| translation_config&.credentials || | ||
| Google::Cloud::Config.credentials_from_env( | ||
| "TRANSLATE_CREDENTIALS", "TRANSLATE_CREDENTIALS_JSON", "TRANSLATE_KEYFILE", "TRANSLATE_KEYFILE_JSON" | ||
| ) || | ||
| Google::Cloud.configure.credentials || | ||
| Google::Cloud::Translate::V2::Credentials.default(scope: scope) | ||
| Google::Cloud::Translate::V2::Credentials.default({ scope: scope, enable_self_signed_jwt: enable_self_signed_jwt }) | ||
| end | ||
|
|
||
| ## | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
1.32 please