use of io.liftwizard.dropwizard.configuration.auth.filter.AuthFilterFactory in project liftwizard by motlin.
the class ImpersonationAuthFilterFactoryTest method impersonationAuthFilter.
@Test
public void impersonationAuthFilter() throws Exception {
URL resource = Resources.getResource("config-test.json5");
File json = new File(resource.toURI());
AuthFilterFactory authFilterFactory = this.factory.build(json);
assertThat(authFilterFactory, instanceOf(ImpersonationAuthFilterFactory.class));
AuthFilter<?, ? extends Principal> authFilter = authFilterFactory.createAuthFilter();
assertThat(authFilter, instanceOf(OAuthCredentialAuthFilter.class));
}
use of io.liftwizard.dropwizard.configuration.auth.filter.AuthFilterFactory in project liftwizard by motlin.
the class AuthFilterBundle method runWithMdc.
@Override
public void runWithMdc(@Nonnull Object configuration, @Nonnull Environment environment) {
AuthFilterFactoryProvider authFilterFactoryProvider = this.safeCastConfiguration(AuthFilterFactoryProvider.class, configuration);
List<AuthFilterFactory> authFilterFactories = authFilterFactoryProvider.getAuthFilterFactories();
List<AuthFilter<?, ? extends Principal>> authFilters = this.getAuthFilters(authFilterFactories);
if (authFilters.isEmpty()) {
LOGGER.warn("{} disabled.", this.getClass().getSimpleName());
return;
}
List<String> authFilterNames = authFilters.stream().map(Object::getClass).map(Class::getSimpleName).collect(Collectors.toList());
LOGGER.info("Running {} with auth filters {}.", this.getClass().getSimpleName(), authFilterNames);
environment.jersey().register(this.getAuthDynamicFeature(authFilters));
environment.jersey().register(RolesAllowedDynamicFeature.class);
environment.jersey().register(new Binder<>(Principal.class));
Filter clearMDCFilter = this.getClearMDCFilter(authFilterFactories);
FilterHolder filterHolder = new FilterHolder(clearMDCFilter);
EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST);
environment.getApplicationContext().addFilter(filterHolder, "/*", dispatcherTypes);
LOGGER.info("Completing {}.", this.getClass().getSimpleName());
}
use of io.liftwizard.dropwizard.configuration.auth.filter.AuthFilterFactory in project liftwizard by motlin.
the class FirebaseAuthFilterFactoryTest method firebaseAuthFilter.
@Test
public void firebaseAuthFilter() throws Exception {
URL resource = Resources.getResource("config-test.json5");
File json = new File(resource.toURI());
AuthFilterFactory authFilterFactory = this.factory.build(json);
assertThat(authFilterFactory, instanceOf(FirebaseAuthFilterFactory.class));
}
Aggregations