adutra commented on code in PR #2244: URL: https://github.com/apache/polaris/pull/2244#discussion_r2270969200
########## getting-started/keycloak/README.md: ########## @@ -0,0 +1,208 @@ +<!-- + 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. +--> + +# Getting Started with Apache Polaris, External Authentication and Keycloak + +## Overview + +This example uses Keycloak as the identity provider for Polaris. The "iceberg" realm is automatically created and +configured from the `iceberg-realm.json` file. + +This Keycloak realm contains 1 client definition: `client1:s3cr3t`. It is configured to return tokens with the following +fixed claims: + +- `principal_id`: the principal ID of the user. It is always set to zero (0) in this example. +- `principal_name`: the principal name of the user. It is always set to "root" in this example. +- `principal_roles`: the principal roles of the user. It is always set to `["server_admin", "catalog_admin"]` in this + example. + +This is obviously not a realistic configuration. In a real-world scenario, you would configure Keycloak to return the +actual principal ID, name and roles of the user. Note that principals and principal roles must have been created in +Polaris beforehand, and the principal ID, name and roles must match the ones returned by Keycloak. + +Polaris is configured with 3 realms: + +- `realm-internal`: This is the default realm, and is configured to use the internal authentication only. It accepts + token issues by Polaris itself only. +- `realm-external`: This realm is configured to use an external identity provider (IDP) for authentication only. It + accepts tokens issued by Keycloak only. +- `realm-mixed`: This realm is configured to use both the internal and external authentication. It accepts tokens + issued by both Polaris and Keycloak. + +For more information about how to configure Polaris with external authentication, see the +[Polaris documentation](https://polaris.apache.org/in-dev/unreleased/external-idp/). + +## Starting the Example + +1. Build the Polaris server image if it's not already present locally: + + ```shell + ./gradlew \ + :polaris-server:assemble \ + :polaris-server:quarkusAppPartsBuild --rerun \ + -Dquarkus.container-image.build=true + ``` + +2. Start the docker compose group by running the following command from the root of the repository: + + ```shell + docker compose -f getting-started/keycloak/docker-compose.yml up Review Comment: I don't have any errors. Note that it's normal to have this error message in the logs when using mixed authentication: ``` polaris-1 | 2025-08-12 19:27:27,344 ERROR [org.apa.pol.ser.aut.JWTBroker] [,realm-mixed] [,,,] (vert.x-eventloop-thread-13) Failed to verify the token with error: com.auth0.jwt.exceptions.JWTDecodeException: The token was expected to have 3 parts, but got 0. polaris-1 | at com.auth0.jwt.TokenUtils.wrongNumberOfParts(TokenUtils.java:45) polaris-1 | at com.auth0.jwt.TokenUtils.splitToken(TokenUtils.java:23) polaris-1 | at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:37) polaris-1 | at com.auth0.jwt.JWTVerifier.verify(JWTVerifier.java:451) polaris-1 | at org.apache.polaris.service.auth.JWTBroker.verify(JWTBroker.java:68) polaris-1 | at org.apache.polaris.service.auth.QuarkusProducers_ProducerMethod_tokenBroker_7hHN0Q-B8m1s4cAHbPAL_pDNaO0_ClientProxy.verify(Unknown Source) polaris-1 | at org.apache.polaris.service.quarkus.auth.internal.InternalAuthenticationMechanism.authenticate(InternalAuthenticationMechanism.java:98) ``` This is because the token was a Keycloak token, and so the internal token broker could not validate it. This other message, however, is not normal: ``` polaris-1 | 2025-08-12 17:36:43,836 ERROR [io.qua.oid.run.OidcProviderClientImpl] [,realm-mixed] [,,,] (vert.x-eventloop-thread-5) Request http://keycloak:8080/realms/iceberg/protocol/openid-connect/token/introspect has failed ``` I wonder if you have some docker network issue? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org