Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hanabix/akka-stream-oauth2
Some useful graph shapes of akka-stream for OAuth2
https://github.com/hanabix/akka-stream-oauth2
akka akka-stream oauth2 scala
Last synced: about 5 hours ago
JSON representation
Some useful graph shapes of akka-stream for OAuth2
- Host: GitHub
- URL: https://github.com/hanabix/akka-stream-oauth2
- Owner: hanabix
- License: apache-2.0
- Created: 2018-06-14T09:15:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-28T08:20:41.000Z (11 months ago)
- Last Synced: 2023-11-29T04:42:14.522Z (11 months ago)
- Topics: akka, akka-stream, oauth2, scala
- Language: Scala
- Homepage:
- Size: 166 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CI](https://github.com/hanabix/akka-stream-oauth2/actions/workflows/ci.yml/badge.svg)](https://github.com/hanabix/akka-stream-oauth2/actions/workflows/ci.yml) [![Publish](https://github.com/hanabix/akka-stream-oauth2/actions/workflows/sbt-release.yml/badge.svg)](https://github.com/hanabix/akka-stream-oauth2/actions/workflows/sbt-release.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/b08b7b211d174c1c9c9c5923e3f1ed7d)](https://www.codacy.com/gh/hanabix/akka-stream-oauth2/dashboard?utm_source=github.com&utm_medium=referral&utm_content=hanabix/akka-stream-oauth2&utm_campaign=Badge_Grade) [![Coverage Status](https://coveralls.io/repos/github/hanabix/akka-stream-oauth2/badge.svg)](https://coveralls.io/github/hanabix/akka-stream-oauth2) [![Maven Central](https://img.shields.io/maven-central/v/com.github.zhongl/akka-stream-oauth2-core_2.13)](https://search.maven.org/artifact/com.github.zhongl/akka-stream-oauth2-core_2.13)
**akka-stream-oauth2** provides some useful graph shapes of [akka-stream](https://doc.akka.io/docs/akka/current/stream/index.html) for OAuth2.
## Dependencies
```scala
libraryDependencies += "com.github.zhongl" %% "akka-stream-oauth2-" %
```## Usage
A simple web application it's authencation based on `Wechat Work`.
```scala
val ignore: HttpRequest => Boolean = ???
val oauth2: OAuth2[AccessToken] = WeWork { ??? }
val routes: Route = { ??? }
val graph = GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._val guard = b.add(Guard.graph(oauth2, ignore))
val merge = b.add(Merge[Future[HttpResponse]](2))
val serve = b.add(Flow.fromFunction(Route.asyncHandler(routes)))// format: OFF
guard.out0 ~> serve ~> merge
guard.out1 ~> merge
// format: ONFlowShape(guard.in, merge.out)
}
val parallelism: Int = ???
val flow = Flow[HttpRequest].via(graph).mapAsync(parallelism)(identity)
val f = http.bindAndHandle(flow, "0.0.0.0", 8080)
gracefulShutdown(f)
```