michaeljmarshall commented on code in PR #19849:
URL: https://github.com/apache/pulsar/pull/19849#discussion_r1151454165


##########
pulsar-broker-auth-oidc/src/main/java/org/apache/pulsar/broker/authentication/oidc/OpenIDProviderMetadataCache.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+package org.apache.pulsar.broker.authentication.oidc;
+
+import static 
org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID.CACHE_EXPIRATION_SECONDS;
+import static 
org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID.CACHE_EXPIRATION_SECONDS_DEFAULT;
+import static 
org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID.CACHE_SIZE;
+import static 
org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID.CACHE_SIZE_DEFAULT;
+import static 
org.apache.pulsar.broker.authentication.oidc.AuthenticationProviderOpenID.incrementFailureMetric;
+import static 
org.apache.pulsar.broker.authentication.oidc.ConfigUtils.getConfigValueAsInt;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.github.benmanes.caffeine.cache.AsyncCacheLoader;
+import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nonnull;
+import javax.naming.AuthenticationException;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.asynchttpclient.AsyncHttpClient;
+
+/**
+ * Class used to cache metadata responses from OpenID Providers.
+ */
+class OpenIDProviderMetadataCache {
+
+    private final ObjectReader reader = new 
ObjectMapper().readerFor(OpenIDProviderMetadata.class);
+
+    /**
+     * A loader for the cache that retrieves the metadata from the issuer's 
/.well-known/openid-configuration endpoint.
+     * @return a connection to the issuer's /.well-known/openid-configuration 
endpoint
+     * @throws AuthenticationException if the URL is malformed or there is an 
exception while opening the connection
+     */
+    private AsyncCacheLoader<String, OpenIDProviderMetadata> 
getLoader(AsyncHttpClient client) {
+        return (issuer, executor) ->
+                // TODO OIDC spec 
https://openid.net/specs/openid-connect-discovery-1_0.html#NormalizationSteps
+                // calls for normalization according to RFC3986. Is that 
important to verify here?
+                client
+                    .prepareGet(issuer + "/.well-known/openid-configuration")

Review Comment:
   This is fixed by one of the commits I pushed up just now. I used the 
solution you referenced 
[here](https://github.com/apache/pulsar/issues/7952#issuecomment-686827234). 
Also, I think the problematic issuer is actually Auth0 based on my third point 
[here](https://github.com/datastax/pulsar-openid-connect-plugin/pull/5#issuecomment-906741706).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to