net.leanix.dropkit.oauth.OAuth2DynamicFeature Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leanix-dropkit Show documentation
Show all versions of leanix-dropkit Show documentation
Base functionality for leanIX dropwizard-based services
package net.leanix.dropkit.oauth;
import net.leanix.dropkit.oauth.models.User;
import com.google.inject.Inject;
import io.dropwizard.auth.AuthDynamicFeature;
import io.dropwizard.auth.AuthValueFactoryProvider;
import io.dropwizard.auth.oauth.OAuthCredentialAuthFilter;
import io.dropwizard.setup.Environment;
import javax.ws.rs.ext.Provider;
@Provider
public class OAuth2DynamicFeature extends AuthDynamicFeature {
@Inject
// OAuth2Authenticator could be replaced by an additional dummy subclass
// (UserAuthenticator extends OAuth2Authenticator)
// to avoid the extra need to bind and authenticator
public OAuth2DynamicFeature(OAuth2Authenticator authenticator, Environment environment) {
super(new OAuthCredentialAuthFilter.Builder()
.setAuthenticator(authenticator)
.setPrefix("Bearer")
.buildAuthFilter());
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy