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

feat(auth): Update get_client_ssl_credentials to support X.509 workload certs #1558

Merged
merged 14 commits into from
Aug 7, 2024

Conversation

andyrzhao
Copy link
Contributor

@andyrzhao andyrzhao commented Jul 11, 2024

This PR adds support for loading X.509 workload cert in addition to existing context_aware_metadata based cert.

@andyrzhao andyrzhao requested review from a team as code owners July 11, 2024 21:48
Comment on lines 27 to 36
return (
_mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH)
is not None
) or (
_mtls_helper._check_config_path(
_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH
)
is not None
)
return metadata_path is not None

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you refactor this to an early return flow?

This is hard to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this?
if _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None:
return true
elif _mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None:
return true
else:
return false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if _mtls_helper._check_config_path(_mtls_helper.CONTEXT_AWARE_METADATA_PATH) is not None:
    return true
if _mtls_helper._check_config_path(_mtls_helper.CERTIFICATE_CONFIGURATION_DEFAULT_PATH) is not None:
    return true
return false

Slightly tweaked

@clundin25 clundin25 added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:run Add this label to force Kokoro to re-run the tests. labels Jul 31, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 31, 2024
@clundin25 clundin25 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 7, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 7, 2024
@arithmetic1728 arithmetic1728 added owlbot:run Add this label to trigger the Owlbot post processor. automerge Merge the pull request once unit tests and other checks pass. and removed automerge Merge the pull request once unit tests and other checks pass. owlbot:run Add this label to trigger the Owlbot post processor. labels Aug 7, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 7, 2024
@arithmetic1728 arithmetic1728 merged commit 18c2ec1 into googleapis:main Aug 7, 2024
14 checks passed
arithmetic1728 pushed a commit that referenced this pull request Aug 24, 2024
* chore: Add aiohttp requirements test constraint. (#1566)

See #1565
for more information.

* chore(main): release 2.33.0 (#1560)

* chore(main): release 2.33.0

* fix: retry token request on retryable status code (#1563)

* fix: retry token request on retryable status code

* feat(auth): Update get_client_ssl_credentials to support X.509 workload certs (#1558)

* feat(auth): Update get_client_ssl_credentials to support X.509 workload certs

* feat(auth): Update has_default_client_cert_source

* feat(auth): Fix formatting

* feat(auth): Fix test__mtls_helper.py

* feat(auth): Fix function name in tests

* chore: Refresh system test creds.

* feat(auth): Fix style

* feat(auth): Fix casing

* feat(auth): Fix linter issue

* feat(auth): Fix coverage issue

---------

Co-authored-by: Carl Lundin <clundin@google.com>
Co-authored-by: Carl Lundin <108372512+clundin25@users.noreply.github.com>

* chore: Update ECP deps. (#1583)

* chore(main): release 2.34.0 (#1574)

* cleanup: minor code cleanup

* fix lint issues

---------

Co-authored-by: Carl Lundin <108372512+clundin25@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Tom Milligan <tom.milligan@uipath.com>
Co-authored-by: Andy Zhao <andyzhao@google.com>
Co-authored-by: Carl Lundin <clundin@google.com>
ohmayr added a commit that referenced this pull request Sep 16, 2024
* chore: initial setup for async auth sessions api (#1571)

* chore: initial setup for async auth sessions api

* fix whitespace

* add init file

* update file names to aiohttp

* update import statement

* feat: Implement asynchronous timeout context manager (#1569)

* feat: implement async timeout guard

* add docstring

* clean whitespace

* update import file name

* add missing return statement

* update test cases

* update test cases

* include underlying timeout exception in trace

* avoid the cost of actual time

* feat: Implement asynchronous `AuthorizedSession` api response class (#1575)

* feat: implement asynchronous response class for AuthorizedSessions API

* check if aiohttp is installed and avoid tests dependency

* update content to be async

* update docstring to be specific to aiohttp

* add type checking and avoid leaking underlying API responses

* add test case for iterating chunks

* add read method to response interface

* address PR comments

* fix lint issues

* feat: Implement asynchronous `AuthorizedSession` api request class (#1579)

* feat: implement request class for asynchoronous AuthorizedSession API

* add type checking and address TODOs

* remove default values from interface methods

* aiohttp reponse close method must not be awaited

* cleanup

* update Request class docstring

* feat: Implement asynchronous `AuthorizedSession` class (#1580)

* feat: Implement Asynchronous AuthorizedSession class

* add comment for implementing locks within refresh

* move timeout guard to sessions

* add unit tests and code cleanup

* implement async exponential backoff iterator

* cleanup

* add testing for http methods and cleanup

* update number of retries to 3

* refactor test cases

* fix linter and mypy issues

* fix pytest code coverage

* fix: avoid leaking api error for closed session

* add error handling for response

* cleanup default values and add test coverage

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* cleanup: minor code cleanup (#1589)

* chore: Add aiohttp requirements test constraint. (#1566)

See #1565
for more information.

* chore(main): release 2.33.0 (#1560)

* chore(main): release 2.33.0

* fix: retry token request on retryable status code (#1563)

* fix: retry token request on retryable status code

* feat(auth): Update get_client_ssl_credentials to support X.509 workload certs (#1558)

* feat(auth): Update get_client_ssl_credentials to support X.509 workload certs

* feat(auth): Update has_default_client_cert_source

* feat(auth): Fix formatting

* feat(auth): Fix test__mtls_helper.py

* feat(auth): Fix function name in tests

* chore: Refresh system test creds.

* feat(auth): Fix style

* feat(auth): Fix casing

* feat(auth): Fix linter issue

* feat(auth): Fix coverage issue

---------

Co-authored-by: Carl Lundin <clundin@google.com>
Co-authored-by: Carl Lundin <108372512+clundin25@users.noreply.github.com>

* chore: Update ECP deps. (#1583)

* chore(main): release 2.34.0 (#1574)

* cleanup: minor code cleanup

* fix lint issues

---------

Co-authored-by: Carl Lundin <108372512+clundin25@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Andy Zhao <andyzhao@google.com>
Co-authored-by: Carl Lundin <clundin@google.com>

* update secrets from forked repo

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: arithmetic1728 <58957152+arithmetic1728@users.noreply.github.com>
Co-authored-by: Carl Lundin <108372512+clundin25@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Andy Zhao <andyzhao@google.com>
Co-authored-by: Carl Lundin <clundin@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants