Closed DOSarrest closed 7 years ago
Here is the run initialization code so far
` LdapConfiguration ldapConfiguration = configuration.getLdapConfiguration();
Authenticator<BasicCredentials, User> ldapAuthenticator = new CachingAuthenticator<>(
environment.metrics(),
new UserResourceAuthenticator(new LdapAuthenticator(ldapConfiguration)),
ldapConfiguration.getCachePolicy()
);
BasicCredentialAuthFilter<User> basicCredentialAuthFilter = new BasicCredentialAuthFilter.Builder<User>()
.setAuthenticator(ldapAuthenticator)
.setAuthorizer(new LdapAuthorizer())
.setRealm("MetricEngine")
.buildAuthFilter();
environment.jersey().register(new AuthDynamicFeature(basicCredentialAuthFilter));
environment.jersey().register(RolesAllowedDynamicFeature.class);
//If you want to use @Auth to inject a custom Principal type into your resource
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));
environment.healthChecks().register("ldap", new LdapHealthCheck<>(new UserResourceAuthenticator(new LdapCanAuthenticate(ldapConfiguration))));`
Got it working by changing AuthValueFactoryProvider to this...
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class));
Documentation should probably be updated to reflect 1.x changes though.
Agreed, I'll update the usage doc to reflect the 1.x release of Dropwizard Auth.
Please update for dropwizard 1.x. Current instructions appear to be for 0.x. After some work I have been able to get it to work for logging in, but the @Auth annotation does not provide access to the User object.
The current instructions do not appear to work at all with 1.x and results in various errors.