{"action":"created","issue":{"url":"https://api.github.com/repos/http4s/http4s/issues/850","repository_url":"https://api.github.com/repos/http4s/http4s","labels_url":"https://api.github.com/repos/http4s/http4s/issues/850/labels{/name}","comments_url":"https://api.github.com/repos/http4s/http4s/issues/850/comments","events_url":"https://api.github.com/repos/http4s/http4s/issues/850/events","html_url":"https://github.com/http4s/http4s/pull/850","id":200469076,"number":850,"title":"Make the `getChallenge` method of bundled auth middleware public","user":{"login":"ericmann","id":605474,"avatar_url":"https://avatars.githubusercontent.com/u/605474?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmann","html_url":"https://github.com/ericmann","followers_url":"https://api.github.com/users/ericmann/followers","following_url":"https://api.github.com/users/ericmann/following{/other_user}","gists_url":"https://api.github.com/users/ericmann/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmann/subscriptions","organizations_url":"https://api.github.com/users/ericmann/orgs","repos_url":"https://api.github.com/users/ericmann/repos","events_url":"https://api.github.com/users/ericmann/events{/privacy}","received_events_url":"https://api.github.com/users/ericmann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-12T20:18:23Z","updated_at":"2017-01-12T20:38:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/http4s/http4s/pulls/850","html_url":"https://github.com/http4s/http4s/pull/850","diff_url":"https://github.com/http4s/http4s/pull/850.diff","patch_url":"https://github.com/http4s/http4s/pull/850.patch"},"body":"As the Authentication middleware doesn't \"fall through\" in a stack, there is no way to allow users to authenticate with multiple different auth sources. In order to enable that kind of functionality, the existing `getChallenge` method of both `BasicAuth` and `DigestAuth` must be public so external integrations can properly invoke them.\r\n\r\nFor example, consider the use case where users can authenticate either with an api key and secret (using HTTP Basic) _or_ with an OIDC token (using Bearer authentication). Assuming there is already a `BearerAuth` object that parses and validates the OIDC token, a combined authenticator would look something like:\r\n\r\n```\r\nobject GenericAuth {\r\n  type GenericAuthenticator[A] = Credentials => Task[Option[A]]\r\n\r\n  def apply[A](realm: String, validator: GenericAuthenticator[A]): AuthMiddleware[A] = {\r\n    challenged(Service.lift { req =>\r\n      req.headers.get(Authorization) match {\r\n        case Some(Authorization(token: OAuth2BearerToken)) =>\r\n          BearerAuth.getChallenge(realm, validator, req)\r\n        case Some(Authorization(creds: BasicCredentials)) =>\r\n          BasicAuth.getChallenge(realm, validator, req)\r\n        case _ => Task.now(-\\/(Challenge(\"Basic\", realm, Map.empty)))\r\n      }\r\n    })\r\n  }\r\n}\r\n```\r\n\r\nIn order to function properly, the `getChallenge()` method of the underlying authentication middlewares _must_ be public or they cannot be invoked externally in such a way."},"comment":{"url":"https://api.github.com/repos/http4s/http4s/issues/comments/272276629","html_url":"https://github.com/http4s/http4s/pull/850#issuecomment-272276629","issue_url":"https://api.github.com/repos/http4s/http4s/issues/850","id":272276629,"user":{"login":"codecov-io","id":8655789,"avatar_url":"https://avatars.githubusercontent.com/u/8655789?v=3","gravatar_id":"","url":"https://api.github.com/users/codecov-io","html_url":"https://github.com/codecov-io","followers_url":"https://api.github.com/users/codecov-io/followers","following_url":"https://api.github.com/users/codecov-io/following{/other_user}","gists_url":"https://api.github.com/users/codecov-io/gists{/gist_id}","starred_url":"https://api.github.com/users/codecov-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codecov-io/subscriptions","organizations_url":"https://api.github.com/users/codecov-io/orgs","repos_url":"https://api.github.com/users/codecov-io/repos","events_url":"https://api.github.com/users/codecov-io/events{/privacy}","received_events_url":"https://api.github.com/users/codecov-io/received_events","type":"User","site_admin":false},"created_at":"2017-01-12T20:38:25Z","updated_at":"2017-01-12T20:38:25Z","body":"## [Current coverage](https://codecov.io/gh/http4s/http4s/pull/850?src=pr) is 70.27% (diff: 100%)\n> Merging [#850](https://codecov.io/gh/http4s/http4s/pull/850?src=pr) into [release-0.15.x](https://codecov.io/gh/http4s/http4s/branch/release-0.15.x?src=pr) will increase coverage by **0.73%**\n\n```diff\n@@           release-0.15.x       #850   diff @@\n================================================\n  Files                 211        211          \n  Lines                4629       4629          \n  Methods              4195       4195          \n  Messages                0          0          \n  Branches              434        434          \n================================================\n+ Hits                 3219       3253    +34   \n+ Misses               1410       1376    -34   \n  Partials                0          0          \n```\n\n> Powered by [Codecov](https://codecov.io?src=pr). Last update [c4e3f2d...8b158b6](https://codecov.io/gh/http4s/http4s/compare/c4e3f2d0e7a9a0f206a203b4a9dcfd4b1978b9a6...8b158b66ebe0f81ee0827d5028a3ae950ac56d0e?src=pr)"}}
{"actor":{"display_login":"codecov-io"}}