https://github.com/filosganga/http4s-aws
AWS V4 authentication for Http4s
https://github.com/filosganga/http4s-aws
aws aws-signature-v4 cats cats-effect http4s http4s-modules
Last synced: about 1 year ago
JSON representation
AWS V4 authentication for Http4s
- Host: GitHub
- URL: https://github.com/filosganga/http4s-aws
- Owner: filosganga
- License: apache-2.0
- Created: 2020-03-07T13:36:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-07T14:05:44.000Z (about 6 years ago)
- Last Synced: 2025-02-07T16:25:43.712Z (over 1 year ago)
- Topics: aws, aws-signature-v4, cats, cats-effect, http4s, http4s-modules
- Language: Scala
- Size: 32.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS Signature V4 implementation for http4s
Provides an http4s client middleware that authenticates requests with AWS Auth Signature V4.
## Getting started
To get started with sbt, simply add the following line to your build.sbt file.
````sbt
libraryDependencies += "com.github.fd4s" %% "http4s-aws" % ""
````
Example of use with S3:
````scala
import scala.concurrent.ExecutionContext.{global => ec}
import cats.implicits._
import cats.effect._
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain
import org.http4s.{Service => _, _}
import org.http4s.Method._
import org.http4s.client._
import org.http4s.client.dsl.io._
import org.http4s.client.blaze._
import com.github.fd4s.http4s.aws._
import com.github.fd4s.http4s.aws.model._
implicit val cs: ContextShift[IO] = IO.contextShift(ec)
BlazeClientBuilder[IO](ec)
.resource
.map { client =>
AwsSigner(
CredentialsProvider.fromAwsCredentialProvider[IO](
new DefaultAWSCredentialsProviderChain()
),
Region.`eu-west-1`,
Service.s3
)(client)
}
.use { client =>
for {
url <- IO.fromEither(Uri.fromString("hhttps://test.s3-eu-west-1.amazonaws.com/test.txt"))
req <- GET(url)
res <- client.expect[String](req)
} yield res
}
.unsafeRunSync()
````
Happy coding!