{"id":20632356,"url":"https://github.com/finagle/finagle-oauth2","last_synced_at":"2025-05-12T14:53:05.350Z","repository":{"id":17144851,"uuid":"19911485","full_name":"finagle/finagle-oauth2","owner":"finagle","description":"OAuth2 Server-Side Provider for Finagle","archived":false,"fork":false,"pushed_at":"2024-07-29T14:43:47.000Z","size":140,"stargazers_count":84,"open_issues_count":32,"forks_count":22,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-09T08:55:44.967Z","etag":null,"topics":["finagle","finch","oauth","oauth2","scala"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"looknd/AlloyTicker","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/finagle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-18T13:47:26.000Z","updated_at":"2024-10-28T16:30:07.000Z","dependencies_parsed_at":"2024-12-26T00:06:51.333Z","dependency_job_id":"514502bd-1615-4011-87c1-75c97afcb44d","html_url":"https://github.com/finagle/finagle-oauth2","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finagle%2Ffinagle-oauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finagle%2Ffinagle-oauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finagle%2Ffinagle-oauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finagle%2Ffinagle-oauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/finagle","download_url":"https://codeload.github.com/finagle/finagle-oauth2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253759173,"owners_count":21959712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finagle","finch","oauth","oauth2","scala"],"created_at":"2024-11-16T14:15:56.034Z","updated_at":"2025-05-12T14:53:05.324Z","avatar_url":"https://github.com/finagle.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://img.shields.io/travis/finagle/finagle-oauth2/master.svg)](https://travis-ci.org/finagle/finagle-oauth2)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.finagle/finagle-oauth2_2.12.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.finagle/finagle-oauth2_2.12)\n\nOAuth2 Provider for Finagle\n---------------------------\n\nThis is a [Finagle]-friendly version of [scala-oauth2-provider].\n\n## User Guide\n\n 1. Implement `com.twitter.finagle.oauth2.DataHandler` using your own data store (in-memory, DB, etc).\n 2. Use `com.twitter.finagle.OAuth2` API to authorize requests and issue access tokens.\n\n\u003e A service that emits OAuth2 access tokens based on request's credentials.\n\n```scala\nimport com.twitter.finagle.OAuth2\nimport com.twitter.finagle.oauth2.{OAuthError, DataHandler}\n\nimport com.twitter.finagle.http.{Request, Response, Version, Status}\nimport com.twitter.finagle.Service\nimport com.twitter.util.Future\n\nval dataHandler: DataHandler[?] = ???\n\nobject TokenService extends Service[Request, Response] with OAuth2 {\n  def apply(req: Request): Future[Response] =\n    issueAccessToken(req, dataHandler).flatMap { token =\u003e\n      val rep = Response(Version.Http11, Status.Ok)\n      rep.setContentString(token.accessToken)\n      Future.value(rep)\n    } handle {\n      case e: OAuthError =\u003e e.toResponse\n    }\n}\n```\n\n\u003e A service that checks whether the request contains a valid token.\n\n```scala\nimport com.twitter.finagle.OAuth2\nimport com.twitter.finagle.oauth2.{OAuthError, DataHandler}\n\nimport com.twitter.finagle.http.{Request, Response, Version, Status}\nimport com.twitter.finagle.Service\nimport com.twitter.util.Future\n\nobject ProtectedService extends Service[Request, Response] with OAuth2 {\n  def apply(req: Request): Future[Response] =\n    authorize(req, dataHandler).flatMap { authInfo =\u003e\n      val rep = Response(Version.Http11, Status.Ok)\n      rep.setContentString(s\"Hello ${authInfo.user}!\")\n      Future.value(rep)\n    } handle {\n      case e: OAuthError =\u003e e.toResponse\n    }\n}\n```\n\n[Finagle]: https://github.com/twitter/finagle\n[scala-oauth2-provider]: https://github.com/nulab/scala-oauth2-provider\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffinagle%2Ffinagle-oauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffinagle%2Ffinagle-oauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffinagle%2Ffinagle-oauth2/lists"}