Skip to content

Commit

Permalink
Deprecate rest.authorization-url in favor of oauth2-server-uri
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrluis committed Jul 24, 2024
1 parent 861c563 commit 05b430e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions pyiceberg/catalog/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
CommitTableRequest,
CommitTableResponse,
CreateTableTransaction,
PropertyUtil,
StagedTable,
Table,
TableIdentifier,
Expand All @@ -71,6 +72,7 @@
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder, assign_fresh_sort_order_ids
from pyiceberg.typedef import EMPTY_DICT, UTF8, IcebergBaseModel, Identifier, Properties
from pyiceberg.types import transform_dict_value_to_str
from pyiceberg.utils.deprecated import deprecated

if TYPE_CHECKING:
import pyarrow as pa
Expand Down Expand Up @@ -118,7 +120,8 @@ class Endpoints:
SIGV4 = "rest.sigv4-enabled"
SIGV4_REGION = "rest.signing-region"
SIGV4_SERVICE = "rest.signing-name"
AUTH_URL = "rest.authorization-url"
DEPRECATED_AUTH_URL = "rest.authorization-url"
OAUTH2_SERVER_URI = "oauth2-server-uri"
HEADER_PREFIX = "header."

NAMESPACE_SEPARATOR = b"\x1f".decode(UTF8)
Expand Down Expand Up @@ -290,7 +293,14 @@ def url(self, endpoint: str, prefixed: bool = True, **kwargs: Any) -> str:

@property
def auth_url(self) -> str:
if url := self.properties.get(AUTH_URL):
if self.properties.get(DEPRECATED_AUTH_URL):
deprecated(
deprecated_in="0.7.0",
removed_in="0.8.0",
help_message=f"The property {DEPRECATED_AUTH_URL} is deprecated. Please use {OAUTH2_SERVER_URI} instead",
)(lambda: None)()

if url := PropertyUtil.get_first_property_value(self.properties, DEPRECATED_AUTH_URL, OAUTH2_SERVER_URI):
return url
else:
return self.url(Endpoints.get_token, prefixed=False)
Expand Down
4 changes: 2 additions & 2 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import pyiceberg
from pyiceberg.catalog import PropertiesUpdateSummary, load_catalog
from pyiceberg.catalog.rest import AUTH_URL, RestCatalog
from pyiceberg.catalog.rest import OAUTH2_SERVER_URI, RestCatalog
from pyiceberg.exceptions import (
AuthorizationExpiredError,
NamespaceAlreadyExistsError,
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_token_200_w_auth_url(rest_mock: Mocker) -> None:
)
# pylint: disable=W0212
assert (
RestCatalog("rest", uri=TEST_URI, credential=TEST_CREDENTIALS, **{AUTH_URL: TEST_AUTH_URL})._session.headers[
RestCatalog("rest", uri=TEST_URI, credential=TEST_CREDENTIALS, **{OAUTH2_SERVER_URI: TEST_AUTH_URL})._session.headers[
"Authorization"
]
== f"Bearer {TEST_TOKEN}"
Expand Down

0 comments on commit 05b430e

Please sign in to comment.