Skip to content

Commit 38cf158

Browse files
committed
Deprecate oauth/tokens endpoint
This PR implements "M1" of [this document](https://docs.google.com/document/d/1Xi5MRk8WdBWFC3N_eSmVcrLhk3yu5nJ9x_wC0ec6kVQ/), see #10537.
1 parent 7071dc1 commit 38cf158

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ project(':iceberg-core') {
373373
testImplementation libs.esotericsoftware.kryo
374374
testImplementation libs.guava.testlib
375375
testImplementation libs.awaitility
376+
testRuntimeOnly libs.logback.classic
376377
}
377378
}
378379

core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ public void initialize(String name, Map<String, String> unresolved) {
183183
String credential = props.get(OAuth2Properties.CREDENTIAL);
184184
String scope = props.getOrDefault(OAuth2Properties.SCOPE, OAuth2Properties.CATALOG_SCOPE);
185185
Map<String, String> optionalOAuthParams = OAuth2Util.buildOptionalParam(props);
186+
if (!props.containsKey(OAuth2Properties.OAUTH2_SERVER_URI)) {
187+
LOG.warn(
188+
"Iceberg REST client is missing the OAuth2 server URI configuration and defaults to {}{}. "
189+
+ "This automatic fallback will be removed in a future Iceberg release."
190+
+ "It is recommended to configure the OAuth2 endpoint using the '{}' property to be prepared. "
191+
+ "This warning will disappear if the OAuth2 endpoint is explicitly configured. "
192+
+ "See https://github.com/apache/iceberg/issues/10537",
193+
props.get(CatalogProperties.URI),
194+
ResourcePaths.tokens(),
195+
OAuth2Properties.OAUTH2_SERVER_URI);
196+
}
186197
String oauth2ServerUri =
187198
props.getOrDefault(OAuth2Properties.OAUTH2_SERVER_URI, ResourcePaths.tokens());
188199
try (RESTClient initClient = clientBuilder.apply(props)) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<configuration debug="true">
23+
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
24+
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
25+
<encoder>
26+
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
27+
</encoder>
28+
</appender>
29+
<root level="${test.log.level:-WARN}">
30+
<appender-ref ref="console"/>
31+
</root>
32+
</configuration>

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jetty = "9.4.54.v20240208"
6363
junit = "5.10.1"
6464
kafka = "3.7.0"
6565
kryo-shaded = "4.0.3"
66+
logback = "1.3.14"
6667
microprofile-openapi-api = "3.1.1"
6768
mockito = "4.11.0"
6869
mockserver = "5.15.0"
@@ -201,6 +202,7 @@ junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jun
201202
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
202203
junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit" }
203204
kryo-shaded = { module = "com.esotericsoftware:kryo-shaded", version.ref = "kryo-shaded" }
205+
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
204206
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
205207
mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito" }
206208
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }

open-api/rest-catalog-open-api.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,19 @@ paths:
134134
post:
135135
tags:
136136
- OAuth2 API
137-
summary: Get a token using an OAuth2 flow
137+
summary: Get a token using an OAuth2 flow (DEPRECATED for REMOVAL)
138138
operationId: getToken
139139
description:
140+
The `oauth/tokens` endpoint is **DEPRECATED for REMOVAL**. It is not recommended to _not_
141+
implement this endpoint, unless you are fully aware of the potential security implications.
142+
All clients are encouraged to explicitly set the configuration property `oauth2-server-uri`
143+
to the correct OAuth endpoint.
144+
See [Security improvements in the Iceberg REST specification](https://github.com/apache/iceberg/issues/10537)
145+
146+
147+
Old description follows
148+
149+
140150
Exchange credentials for a token using the OAuth2 client credentials flow or token exchange.
141151

142152

0 commit comments

Comments
 (0)