Skip to content

Commit

Permalink
Fix unknown name "auth" issue when using Instance and Resource Princi…
Browse files Browse the repository at this point in the history
…pal auth (#11)
  • Loading branch information
gmfeinberg authored Sep 8, 2022
1 parent 4cf359d commit 6aa273a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Change Log
All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <http://keepachangelog.com/>`_.
====================
5.3.5 - 2022-08-09
====================

Fixed
_____

* Cloud only. Fixed references to the OCI "auth" package from iam.py that could lead to the error, "name 'auth' is not defined."

====================
5.3.4 - 2022-06-13
Expand Down
15 changes: 9 additions & 6 deletions src/borneo/iam/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
try:
from oci.signer import Signer
from oci.auth.signers import SecurityTokenSigner
from oci.auth.signers import EphemeralResourcePrincipalSigner
from oci.auth.signers import InstancePrincipalsSecurityTokenSigner
from oci.auth.signers import get_resource_principals_signer
from oci.config import from_file
oci = 'yes'
except ImportError:
Expand Down Expand Up @@ -255,7 +258,7 @@ def get_resource_principal_claim(self, key):
:rtype: str
"""
if not isinstance(self._provider,
auth.signers.EphemeralResourcePrincipalSigner):
EphemeralResourcePrincipalSigner):
raise IllegalArgumentException(
'Only ephemeral resource principal support.')
return self._provider.get_claim(key)
Expand Down Expand Up @@ -330,9 +333,9 @@ def create_with_instance_principal(iam_auth_uri=None, region=None,
"""
SignatureProvider._check_oci()
if iam_auth_uri is None:
provider = auth.signers.InstancePrincipalsSecurityTokenSigner()
provider = InstancePrincipalsSecurityTokenSigner()
else:
provider = auth.signers.InstancePrincipalsSecurityTokenSigner(
provider = InstancePrincipalsSecurityTokenSigner(
federation_endpoint=iam_auth_uri)
if region is not None:
provider.region = region.get_region_id()
Expand Down Expand Up @@ -366,7 +369,7 @@ def create_with_resource_principal(logger=None):
"""
SignatureProvider._check_oci()
signature_provider = SignatureProvider(
auth.signers.get_resource_principals_signer())
get_resource_principals_signer())
return (signature_provider if logger is None else
signature_provider.set_logger(logger))

Expand Down Expand Up @@ -410,10 +413,10 @@ def _refresh_task(self):
# refresh security token before create new signature
if (isinstance(
self._provider,
auth.signers.InstancePrincipalsSecurityTokenSigner) or
InstancePrincipalsSecurityTokenSigner) or
isinstance(
self._provider,
auth.signers.EphemeralResourcePrincipalSigner)):
EphemeralResourcePrincipalSigner)):
self._provider.refresh_security_token()

self.get_signature_details_internal()
Expand Down
2 changes: 1 addition & 1 deletion src/borneo/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# https://oss.oracle.com/licenses/upl/
#

__version__ = '5.3.4'
__version__ = '5.3.5'

0 comments on commit 6aa273a

Please sign in to comment.