Search in sources :

Example 1 with FalloutTokenAuthenticator

use of com.datastax.fallout.service.auth.FalloutTokenAuthenticator in project fallout by datastax.

the class FalloutServiceBase method getAuthFilters.

private List<AuthFilter<String, User>> getAuthFilters(FC conf, UserDAO userDAO) {
    List<AuthFilter<String, User>> filters = new ArrayList<>();
    // This will only be applied to methods/classes annotated with RolesAllowed
    final Authorizer<User> adminAuthorizer = (user, role) -> user.isAdmin() && role.equals("ADMIN");
    AuthFilter<String, User> oauthCredentialAuthFilter = new OAuthCredentialAuthFilter.Builder<User>().setAuthenticator(new FalloutTokenAuthenticator(userDAO, OAUTH_REALM)).setAuthorizer(adminAuthorizer).setPrefix(OAUTH_BEARER_TOKEN_TYPE).setRealm(OAUTH_REALM).buildAuthFilter();
    filters.add(oauthCredentialAuthFilter);
    AuthFilter<String, User> uiAuthFilter;
    if (conf.getAuthenticationMode() == FalloutConfiguration.AuthenticationMode.SINGLE_USER) {
        if (conf.getAdminUserCreds().isEmpty()) {
            throw new RuntimeException(String.format("Cannot use %s authentication mode without specifying %s in the environment", FalloutConfiguration.AuthenticationMode.SINGLE_USER, FalloutConfiguration.ADMIN_CREDS_ENV_VAR));
        }
        uiAuthFilter = new SingleUserAuthFilter(() -> userDAO.getUser(conf.getAdminUserCreds().get().email()));
    } else {
        uiAuthFilter = new FalloutCookieAuthFilter.Builder().setAuthenticator(new FalloutTokenAuthenticator(userDAO, COOKIE_NAME)).setAuthorizer(adminAuthorizer).setPrefix(OAUTH_BEARER_TOKEN_TYPE).setRealm(OAUTH_REALM).buildAuthFilter();
    }
    filters.add(uiAuthFilter);
    return filters;
}
Also used : RewriteHandler(org.eclipse.jetty.rewrite.handler.RewriteHandler) SwaggerBundleConfiguration(io.federecio.dropwizard.swagger.SwaggerBundleConfiguration) JacksonUtils(com.datastax.fallout.util.JacksonUtils) AuthValueFactoryProvider(io.dropwizard.auth.AuthValueFactoryProvider) Map(java.util.Map) RolesAllowedDynamicFeature(org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature) AbortableRunnableExecutorFactory(com.datastax.fallout.runner.AbortableRunnableExecutorFactory) QueuingTestRunner(com.datastax.fallout.runner.QueuingTestRunner) Path(java.nio.file.Path) ResourceReservationLocks(com.datastax.fallout.runner.ResourceReservationLocks) EnumSet(java.util.EnumSet) Duration(com.datastax.fallout.util.Duration) LocalCommandExecutor(com.datastax.fallout.ops.commands.LocalCommandExecutor) MainView(com.datastax.fallout.service.views.MainView) RewriteRegexRule(org.eclipse.jetty.rewrite.handler.RewriteRegexRule) LocalizationMessages(org.glassfish.jersey.server.internal.LocalizationMessages) NginxArtifactServlet(com.datastax.fallout.service.artifacts.NginxArtifactServlet) Verify(com.google.common.base.Verify) SingleUserAuthFilter(com.datastax.fallout.service.auth.SingleUserAuthFilter) Servlet(javax.servlet.Servlet) UserCredentials(com.datastax.fallout.runner.UserCredentialsFactory.UserCredentials) Set(java.util.Set) ScopedLogger(com.datastax.fallout.util.ScopedLogger) DefaultServerFactory(io.dropwizard.server.DefaultServerFactory) RunnableExecutorFactory(com.datastax.fallout.runner.RunnableExecutorFactory) FalloutTokenAuthenticator(com.datastax.fallout.service.auth.FalloutTokenAuthenticator) HtmlMailUserMessenger(com.datastax.fallout.util.HtmlMailUserMessenger) CheckCommand(io.dropwizard.cli.CheckCommand) FalloutExecCommand(com.datastax.fallout.service.cli.FalloutExecCommand) CommonProperties(org.glassfish.jersey.CommonProperties) User(com.datastax.fallout.service.core.User) FreemarkerViewRenderer(io.dropwizard.views.freemarker.FreemarkerViewRenderer) Bootstrap(io.dropwizard.setup.Bootstrap) ComponentFactory(com.datastax.fallout.util.component_discovery.ComponentFactory) ServerSentEvents(com.datastax.fallout.service.resources.ServerSentEvents) Exceptions(com.datastax.fallout.util.Exceptions) LiveResource(com.datastax.fallout.service.resources.server.LiveResource) TestResource(com.datastax.fallout.service.resources.server.TestResource) Supplier(java.util.function.Supplier) ViewBundle(io.dropwizard.views.ViewBundle) FalloutVersion(com.datastax.fallout.FalloutVersion) ArrayList(java.util.ArrayList) QueueMetricsManager(com.datastax.fallout.service.db.QueueMetricsManager) HttpConnectorFactory(io.dropwizard.jetty.HttpConnectorFactory) ClojureShutdown(com.datastax.fallout.harness.ClojureShutdown) DelegatingExecutorFactory(com.datastax.fallout.runner.DelegatingExecutorFactory) Environment(io.dropwizard.setup.Environment) UserGroupMapper(com.datastax.fallout.service.db.UserGroupMapper) ArtifactScrubber(com.datastax.fallout.service.artifacts.ArtifactScrubber) ReadOnlyTestRun(com.datastax.fallout.service.core.ReadOnlyTestRun) AccountResource(com.datastax.fallout.service.resources.server.AccountResource) CassandraDriverManager(com.datastax.fallout.service.db.CassandraDriverManager) Paths(java.nio.file.Paths) ForkJoinPool(java.util.concurrent.ForkJoinPool) RunnerResource(com.datastax.fallout.service.resources.runner.RunnerResource) UserMessenger(com.datastax.fallout.util.UserMessenger) PersistentPendingQueue(com.datastax.fallout.runner.queue.PersistentPendingQueue) SecurityUtil(com.datastax.fallout.service.auth.SecurityUtil) HomeResource(com.datastax.fallout.service.resources.server.HomeResource) FinishedTestRunUserNotifier(com.datastax.fallout.util.FinishedTestRunUserNotifier) TestRun(com.datastax.fallout.service.core.TestRun) IllegalStateExceptionMapper(io.dropwizard.jersey.errors.IllegalStateExceptionMapper) RedirectRegexRule(org.eclipse.jetty.rewrite.handler.RedirectRegexRule) Ensemble(com.datastax.fallout.ops.Ensemble) URI(java.net.URI) ComponentResource(com.datastax.fallout.service.resources.server.ComponentResource) PerformanceReportDAO(com.datastax.fallout.service.db.PerformanceReportDAO) Authorizer(io.dropwizard.auth.Authorizer) UserDAO(com.datastax.fallout.service.db.UserDAO) Application(io.dropwizard.Application) Cassandra(com.datastax.fallout.service.cli.Cassandra) FalloutStandaloneCommand(com.datastax.fallout.service.cli.FalloutStandaloneCommand) FalloutCookieAuthFilter(com.datastax.fallout.service.auth.FalloutCookieAuthFilter) SwaggerBundle(io.federecio.dropwizard.swagger.SwaggerBundle) ArtifactUsageAdminTask(com.datastax.fallout.service.artifacts.ArtifactUsageAdminTask) ThreadedRunnableExecutorFactory(com.datastax.fallout.runner.ThreadedRunnableExecutorFactory) MustacheViewRendererWithoutTemplatingErrors(com.datastax.fallout.util.MustacheViewRendererWithoutTemplatingErrors) AssetsBundle(io.dropwizard.assets.AssetsBundle) List(java.util.List) AuthFilter(io.dropwizard.auth.AuthFilter) TestDAO(com.datastax.fallout.service.db.TestDAO) Response(javax.ws.rs.core.Response) NamedThreadFactory(com.datastax.fallout.util.NamedThreadFactory) Managed(io.dropwizard.lifecycle.Managed) HashedWheelTimer(io.netty.util.HashedWheelTimer) Optional(java.util.Optional) ChainedAuthFilter(io.dropwizard.auth.chained.ChainedAuthFilter) ArtifactCompressorAdminTask(com.datastax.fallout.service.artifacts.ArtifactCompressorAdminTask) OAuthCredentialAuthFilter(io.dropwizard.auth.oauth.OAuthCredentialAuthFilter) GenerateNginxConf(com.datastax.fallout.service.cli.GenerateNginxConf) ServerMode(com.datastax.fallout.service.FalloutConfiguration.ServerMode) ServletRegistration(javax.servlet.ServletRegistration) CommandExecutor(com.datastax.fallout.ops.commands.CommandExecutor) Client(javax.ws.rs.client.Client) AuthDynamicFeature(io.dropwizard.auth.AuthDynamicFeature) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) SchemaMode(com.datastax.fallout.service.db.CassandraDriverManager.SchemaMode) ActiveTestRun(com.datastax.fallout.harness.ActiveTestRun) FalloutQueueCommand(com.datastax.fallout.service.cli.FalloutQueueCommand) ArtifactCompressor(com.datastax.fallout.service.artifacts.ArtifactCompressor) ActiveTestRunFactory(com.datastax.fallout.runner.ActiveTestRunFactory) IntSupplier(java.util.function.IntSupplier) CrossOriginFilter(org.eclipse.jetty.servlets.CrossOriginFilter) FalloutRunnerCommand(com.datastax.fallout.service.cli.FalloutRunnerCommand) FileUtils(com.datastax.fallout.util.FileUtils) SlackUserMessenger(com.datastax.fallout.util.SlackUserMessenger) AdminResource(com.datastax.fallout.service.resources.server.AdminResource) ReentrantLock(java.util.concurrent.locks.ReentrantLock) JettyArtifactServlet(com.datastax.fallout.service.artifacts.JettyArtifactServlet) TestRunReaper(com.datastax.fallout.service.core.TestRunReaper) DelegatingRunnableExecutorFactory(com.datastax.fallout.runner.DelegatingRunnableExecutorFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) UserCredentialsFactory(com.datastax.fallout.runner.UserCredentialsFactory) TestRunStatusUpdatePublisher(com.datastax.fallout.harness.TestRunStatusUpdatePublisher) AutoCloseableManager(io.dropwizard.lifecycle.AutoCloseableManager) DirectTestRunner(com.datastax.fallout.runner.DirectTestRunner) Consumer(java.util.function.Consumer) ArtifactWatcher(com.datastax.fallout.service.artifacts.ArtifactWatcher) TestRunDAO(com.datastax.fallout.service.db.TestRunDAO) JobLoggersFactory(com.datastax.fallout.runner.JobLoggersFactory) StatusResource(com.datastax.fallout.service.resources.server.StatusResource) DispatcherType(javax.servlet.DispatcherType) PerformanceToolResource(com.datastax.fallout.service.resources.server.PerformanceToolResource) WebTarget(javax.ws.rs.client.WebTarget) VisibleForTesting(com.google.common.annotations.VisibleForTesting) FalloutValidateCommand(com.datastax.fallout.service.cli.FalloutValidateCommand) User(com.datastax.fallout.service.core.User) FalloutTokenAuthenticator(com.datastax.fallout.service.auth.FalloutTokenAuthenticator) SingleUserAuthFilter(com.datastax.fallout.service.auth.SingleUserAuthFilter) ArrayList(java.util.ArrayList) SingleUserAuthFilter(com.datastax.fallout.service.auth.SingleUserAuthFilter) FalloutCookieAuthFilter(com.datastax.fallout.service.auth.FalloutCookieAuthFilter) AuthFilter(io.dropwizard.auth.AuthFilter) ChainedAuthFilter(io.dropwizard.auth.chained.ChainedAuthFilter) OAuthCredentialAuthFilter(io.dropwizard.auth.oauth.OAuthCredentialAuthFilter) OAuthCredentialAuthFilter(io.dropwizard.auth.oauth.OAuthCredentialAuthFilter)

Aggregations

FalloutVersion (com.datastax.fallout.FalloutVersion)1 ActiveTestRun (com.datastax.fallout.harness.ActiveTestRun)1 ClojureShutdown (com.datastax.fallout.harness.ClojureShutdown)1 TestRunStatusUpdatePublisher (com.datastax.fallout.harness.TestRunStatusUpdatePublisher)1 Ensemble (com.datastax.fallout.ops.Ensemble)1 CommandExecutor (com.datastax.fallout.ops.commands.CommandExecutor)1 LocalCommandExecutor (com.datastax.fallout.ops.commands.LocalCommandExecutor)1 AbortableRunnableExecutorFactory (com.datastax.fallout.runner.AbortableRunnableExecutorFactory)1 ActiveTestRunFactory (com.datastax.fallout.runner.ActiveTestRunFactory)1 DelegatingExecutorFactory (com.datastax.fallout.runner.DelegatingExecutorFactory)1 DelegatingRunnableExecutorFactory (com.datastax.fallout.runner.DelegatingRunnableExecutorFactory)1 DirectTestRunner (com.datastax.fallout.runner.DirectTestRunner)1 JobLoggersFactory (com.datastax.fallout.runner.JobLoggersFactory)1 QueuingTestRunner (com.datastax.fallout.runner.QueuingTestRunner)1 ResourceReservationLocks (com.datastax.fallout.runner.ResourceReservationLocks)1 RunnableExecutorFactory (com.datastax.fallout.runner.RunnableExecutorFactory)1 ThreadedRunnableExecutorFactory (com.datastax.fallout.runner.ThreadedRunnableExecutorFactory)1 UserCredentialsFactory (com.datastax.fallout.runner.UserCredentialsFactory)1 UserCredentials (com.datastax.fallout.runner.UserCredentialsFactory.UserCredentials)1 PersistentPendingQueue (com.datastax.fallout.runner.queue.PersistentPendingQueue)1