Skip to content

Commit

Permalink
Deprecate oauth/tokens endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
snazy committed Jul 1, 2024
1 parent 0e7aa84 commit 9e100ba
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ project(':iceberg-core') {
testImplementation libs.esotericsoftware.kryo
testImplementation libs.guava.testlib
testImplementation libs.awaitility
testRuntimeOnly libs.logback.classic
}
}

Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ public void initialize(String name, Map<String, String> unresolved) {
String credential = props.get(OAuth2Properties.CREDENTIAL);
String scope = props.getOrDefault(OAuth2Properties.SCOPE, OAuth2Properties.CATALOG_SCOPE);
Map<String, String> optionalOAuthParams = OAuth2Util.buildOptionalParam(props);
if (!props.containsKey(OAuth2Properties.OAUTH2_SERVER_URI)) {
LOG.warn(
"Iceberg REST client is missing the OAuth2 server URI configuration and defaults to {}{}. "
+ "This automatic fallback will be removed in a future Iceberg release."
+ "It is recommended to configure the OAuth2 endpoint using the '{}' property to be prepared. "
+ "This warning will disappear if the OAuth2 endpoint is explicitly configured. "
+ "See https://github.com/apache/iceberg/issues/10537",
props.get(CatalogProperties.URI),
ResourcePaths.tokens(),
OAuth2Properties.OAUTH2_SERVER_URI);
}
String oauth2ServerUri =
props.getOrDefault(OAuth2Properties.OAUTH2_SERVER_URI, ResourcePaths.tokens());
try (RESTClient initClient = clientBuilder.apply(props)) {
Expand Down
32 changes: 32 additions & 0 deletions core/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configuration debug="true">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="${test.log.level:-WARN}">
<appender-ref ref="console"/>
</root>
</configuration>
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jetty = "9.4.54.v20240208"
junit = "5.10.1"
kafka = "3.7.0"
kryo-shaded = "4.0.3"
logback = "1.3.14"
microprofile-openapi-api = "3.1.1"
mockito = "4.11.0"
mockserver = "5.15.0"
Expand Down Expand Up @@ -201,6 +202,7 @@ junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jun
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit" }
kryo-shaded = { module = "com.esotericsoftware:kryo-shaded", version.ref = "kryo-shaded" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito" }
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }
Expand Down
13 changes: 12 additions & 1 deletion open-api/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,20 @@ paths:
post:
tags:
- OAuth2 API
summary: Get a token using an OAuth2 flow
summary: Get a token using an OAuth2 flow (DEPRECATED for REMOVAL)
deprecated: true
operationId: getToken
description:
The `oauth/tokens` endpoint is **DEPRECATED for REMOVAL**. It is not recommended to _not_
implement this endpoint, unless you are fully aware of the potential security implications.
All clients are encouraged to explicitly set the configuration property `oauth2-server-uri`
to the correct OAuth endpoint.
See [Security improvements in the Iceberg REST specification](https://github.com/apache/iceberg/issues/10537)


Old description follows


Exchange credentials for a token using the OAuth2 client credentials flow or token exchange.


Expand Down

0 comments on commit 9e100ba

Please sign in to comment.