valepakh commented on code in PR #1569: URL: https://github.com/apache/ignite-3/pull/1569#discussion_r1111641110
########## gradle/libs.versions.toml: ########## @@ -38,6 +38,8 @@ threetenbp = "1.5.2" micronaut = "3.7.4" micronautPicocli = "4.1.0" micronautJunit5 = "3.4.0" +micronautSecurity="3.9.2" Review Comment: This dependency actually brings the micronaut 3.7.5 and junit 5.9.1, hence the need for public `@BeforeAll` methods, maybe we should increase these versions explicitly? ########## modules/rest/src/main/java/org/apache/ignite/internal/rest/auth/DelegatingAuthenticationProvider.java: ########## @@ -0,0 +1,126 @@ +/* + * 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.ignite.internal.rest.auth; + +import io.micronaut.http.HttpRequest; +import io.micronaut.security.authentication.AuthenticationProvider; +import io.micronaut.security.authentication.AuthenticationRequest; +import io.micronaut.security.authentication.AuthenticationResponse; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.stream.Collectors; +import org.apache.ignite.configuration.NamedListView; +import org.apache.ignite.configuration.notifications.ConfigurationListener; +import org.apache.ignite.configuration.notifications.ConfigurationNotificationEvent; +import org.apache.ignite.internal.logger.IgniteLogger; +import org.apache.ignite.internal.logger.Loggers; +import org.apache.ignite.internal.rest.configuration.AuthConfiguration; +import org.apache.ignite.internal.rest.configuration.AuthProviderView; +import org.apache.ignite.internal.rest.configuration.AuthView; +import org.jetbrains.annotations.Nullable; +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import reactor.core.publisher.FluxSink; + +/** + * Implementation of {@link AuthenticationProvider}. Creates a list of {@link Authenticator} according to provided {@link AuthConfiguration} + * and updates them on configuration changes. Delegates {@link AuthenticationRequest} to the list of {@link Authenticator}. + */ +public class DelegatingAuthenticationProvider implements AuthenticationProvider, ConfigurationListener<AuthView> { + + private static final IgniteLogger LOG = Loggers.forClass(DelegatingAuthenticationProvider.class); + + private final AtomicBoolean authEnabled = new AtomicBoolean(false); + private final ReadWriteLock rwLock = new ReentrantReadWriteLock(); + private final Lock readLock = rwLock.readLock(); + private final Lock writeLock = rwLock.writeLock(); + + private List<Authenticator> authenticators = new CopyOnWriteArrayList<>(); + + public DelegatingAuthenticationProvider() {} Review Comment: No-arg constructor 'DelegatingAuthenticationProvider()' is redundant -- 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]
