dropwizard/dropwizard — pull request #439 by tagdyn (2013-12-14 01:44:22+00:00)
Title: Delegating Auth Provider for Dual Authentication Types (HTTP BASIC and OAuth 2 Bearer)

Ran into a situation where I wanted one endpoint to be protected by both HTTP BASIC and OAuth 2 simultaneously. It doesn't appear that you can call environment.addProvider() twice, one for HTTP BASIC and one for OAuth. So, I whipped up this delegating auth provider class that is constructed with two Authenticators: one for HTTP BASIC and one for OAuth. The code merely looks at the HTTP Authorization header to determine if there is a bearer token there, delegating the authentication accordingly to either the OAuth (if there is a bearer token) or BASIC authenticator (fallback if not bearer token)

Would this be a welcome contribution to the project? I also authored a unit test to confirm that the delegation works as expected.