All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.leanix.dropkit.oauth.OAuth2DynamicFeature Maven / Gradle / Ivy

There is a newer version: 2.0.10
Show newest version
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