Commit 0e629c9e authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

remove unnecessary authorizer

parent 4f1b0148
......@@ -18,7 +18,6 @@ import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.auth.AuthDynamicFeature;
import io.dropwizard.auth.AuthValueFactoryProvider;
import io.dropwizard.auth.Authorizer;
import io.dropwizard.auth.basic.BasicCredentialAuthFilter;
import io.dropwizard.jersey.setup.JerseyEnvironment;
import io.dropwizard.setup.Bootstrap;
......@@ -58,9 +57,6 @@ public class CTFApplication extends Application<ApplicationConfiguration>
environment.jersey().register(new AuthDynamicFeature(
new BasicCredentialAuthFilter.Builder<User>()
.setAuthenticator(injector.getInstance(ExampleAuthenticator.class))
.setAuthorizer(new ExampleAuthorizer())
.setRealm("SUPER SECRET STUFF")
//.setPrefix("Not-So-Basic")
.buildAuthFilter()));
environment.jersey().register(RolesAllowedDynamicFeature.class);
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));
......@@ -87,16 +83,6 @@ public class CTFApplication extends Application<ApplicationConfiguration>
applicationConfiguration.getAdmins().forEach(usersRepository::add);
}
//todo: remove
public class ExampleAuthorizer implements Authorizer<User>
{
@Override
public boolean authorize(User user, String role)
{
return user.getName().equals("good-guy") && role.equals("ADMIN");
}
}
private Injector createInjector(ApplicationConfiguration applicationConfiguration)
{
return Guice.createInjector(new ApplicationModule(applicationConfiguration));
......
......@@ -32,7 +32,8 @@ public abstract class Repository<T>
datastore.getCollection(getRepositoryType()).drop();
}
Class getRepositoryType() {
Class getRepositoryType()
{
try {
return Class.forName((((ParameterizedType) this.getClass().getGenericSuperclass())
.getActualTypeArguments()[0]).getTypeName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment