-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Aws auth config (#350) * Added missing providers * Adds headers * Scalafmt * A * Creds provider config reader * Added monix aws label on conf * Adds back parquet and benchmark modules * Uri reader * Aws config documentation * Add config fail scenarios * Add more failed scenarions in test * Aggregates awsAuth module in root
- Loading branch information
Showing
12 changed files
with
773 additions
and
16 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
aws-auth/src/main/scala/monix/connect.aws.auth/AppConf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2020-2020 by The Monix Connect Project Developers. | ||
* See the project homepage at: https://connect.monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.connect.aws.auth | ||
|
||
import monix.execution.internal.InternalApi | ||
import pureconfig._ | ||
import pureconfig.error.ConfigReaderFailures | ||
import pureconfig.generic.auto._ | ||
|
||
@InternalApi | ||
private[connect] final case class AppConf(monixAws: MonixAwsConf) | ||
|
||
@InternalApi | ||
private[connect] object AppConf { | ||
import MonixAwsConf.Implicits._ | ||
val load: Either[ConfigReaderFailures, AppConf] = ConfigSource.default.load[AppConf] | ||
val loadOrThrow = ConfigSource.default.loadOrThrow[AppConf] | ||
} |
66 changes: 66 additions & 0 deletions
66
aws-auth/src/main/scala/monix/connect.aws.auth/AwsCredentialsConf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2020-2020 by The Monix Connect Project Developers. | ||
* See the project homepage at: https://connect.monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.connect.aws.auth | ||
|
||
import monix.execution.internal.InternalApi | ||
import software.amazon.awssdk.auth.credentials.{ | ||
AnonymousCredentialsProvider, | ||
AwsBasicCredentials, | ||
AwsCredentialsProvider, | ||
AwsSessionCredentials, | ||
DefaultCredentialsProvider, | ||
EnvironmentVariableCredentialsProvider, | ||
InstanceProfileCredentialsProvider, | ||
ProfileCredentialsProvider, | ||
StaticCredentialsProvider, | ||
SystemPropertyCredentialsProvider | ||
} | ||
|
||
@InternalApi | ||
private[connect] final case class AwsCredentialsConf( | ||
provider: Provider.Type, | ||
profileName: Option[String], | ||
static: Option[StaticCredentialsConf]) { | ||
val credentialsProvider: AwsCredentialsProvider = { | ||
provider match { | ||
case Provider.Anonymous => AnonymousCredentialsProvider.create() | ||
case Provider.Default => DefaultCredentialsProvider.create() | ||
case Provider.Environment => EnvironmentVariableCredentialsProvider.create() | ||
case Provider.Instance => InstanceProfileCredentialsProvider.create() | ||
case Provider.Profile => { | ||
profileName match { | ||
case Some(name) => ProfileCredentialsProvider.create(name) | ||
case None => ProfileCredentialsProvider.create() | ||
} | ||
} | ||
case Provider.Static => | ||
static match { | ||
case Some(creeds) => | ||
StaticCredentialsProvider.create { | ||
creeds.sessionToken match { | ||
case None => AwsBasicCredentials.create(creeds.accessKeyId, creeds.secretAccessKey) | ||
case Some(token) => AwsSessionCredentials.create(creeds.accessKeyId, creeds.secretAccessKey, token) | ||
} | ||
} | ||
case None => DefaultCredentialsProvider.create() | ||
} | ||
case Provider.System => SystemPropertyCredentialsProvider.create() | ||
case _ => DefaultCredentialsProvider.create() | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
aws-auth/src/main/scala/monix/connect.aws.auth/HttpClientConf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2020-2020 by The Monix Connect Project Developers. | ||
* See the project homepage at: https://connect.monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.connect.aws.auth | ||
|
||
import monix.execution.internal.InternalApi | ||
import software.amazon.awssdk.http.async.SdkAsyncHttpClient | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
@InternalApi | ||
private[connect] final case class HttpClientConf( | ||
maxConcurrency: Option[Int], | ||
maxPendingConnectionAcquires: Option[Int], | ||
connectionAcquisitionTimeout: Option[FiniteDuration], | ||
connectionMaxIdleTime: Option[FiniteDuration], | ||
connectionTimeToLive: Option[FiniteDuration], | ||
useIdleConnectionReaper: Boolean, | ||
readTimeout: Option[FiniteDuration], | ||
writeTimeout: Option[FiniteDuration]) |
46 changes: 46 additions & 0 deletions
46
aws-auth/src/main/scala/monix/connect.aws.auth/MonixAwsConf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2020-2020 by The Monix Connect Project Developers. | ||
* See the project homepage at: https://connect.monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.connect.aws.auth | ||
|
||
import monix.execution.internal.InternalApi | ||
import software.amazon.awssdk.regions.Region | ||
import pureconfig._ | ||
import pureconfig.generic.auto._ | ||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider | ||
import java.net.URI | ||
|
||
import scala.language.implicitConversions | ||
|
||
@InternalApi | ||
private[connect] final case class MonixAwsConf( | ||
region: Region, | ||
credentials: AwsCredentialsProvider, | ||
endpoint: Option[URI], | ||
httpClient: Option[HttpClientConf]) | ||
|
||
@InternalApi | ||
private[connect] object MonixAwsConf { | ||
|
||
object Implicits { | ||
implicit val credentialsProviderReader: ConfigReader[AwsCredentialsProvider] = | ||
ConfigReader[AwsCredentialsConf].map { credentialsConf => credentialsConf.credentialsProvider } | ||
implicit val providerReader: ConfigReader[Provider.Type] = ConfigReader[String].map(Provider.fromString(_)) | ||
implicit val regionReader: ConfigReader[Region] = ConfigReader[String].map(Region.of(_)) | ||
implicit val uriReader: ConfigReader[URI] = ConfigReader[String].map(URI.create(_)) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
aws-auth/src/main/scala/monix/connect.aws.auth/Provider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2020-2020 by The Monix Connect Project Developers. | ||
* See the project homepage at: https://connect.monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.connect.aws.auth | ||
|
||
import monix.execution.internal.InternalApi | ||
|
||
@InternalApi | ||
private[connect] object Provider extends Enumeration { | ||
|
||
type Type = Value | ||
val Anonymous, Default, Environment, Instance, System, Profile, Static = Value | ||
|
||
def fromString(str: String): Provider.Value = { | ||
str.toLowerCase match { | ||
case "anonymous" => Anonymous | ||
case "default" => Default | ||
case "environment" => Environment | ||
case "instance" => Instance | ||
case "profile" => Profile | ||
case "static" => Static | ||
case "system" => System | ||
case _ => Default | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
aws-auth/src/main/scala/monix/connect.aws.auth/StaticCredentialsConf.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2020-2020 by The Monix Connect Project Developers. | ||
* See the project homepage at: https://connect.monix.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package monix.connect.aws.auth | ||
|
||
import monix.execution.internal.InternalApi | ||
|
||
@InternalApi | ||
private[connect] final case class StaticCredentialsConf( | ||
accessKeyId: String, | ||
secretAccessKey: String, | ||
sessionToken: Option[String]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
|
||
monix-aws: { | ||
|
||
credentials { | ||
|
||
// Required - Specifies the aws credentials provider | ||
// Posible values: [anonymous, default, environment, instance, system, profile, static] | ||
provider: "default" | ||
|
||
// Optional - settings that only applies when `provider` is set to 'static'. | ||
// | ||
// If that's the case, `acces-key-id` and `secret-access-key` to create basic credentials: | ||
// `software.amazon.awssdk.auth.credentials.AwsBasicCredentials` | ||
// | ||
// On the other hand, if the optional value `secret-access-key` is defined, it will use session credentials: | ||
// `software.amazon.awssdk.auth.credentials.SessionStaticCredentialsProvider` | ||
// https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/AWSSessionCredentials.html | ||
// | ||
# static { | ||
# | ||
# // Required - within static settings. | ||
# access-key-id: "" | ||
# // Required - within static settings. | ||
# | ||
# secret-access-key: "" | ||
# | ||
# // Optional - when defined, will create `SessionStaticCredentialsProvider` | ||
# session-token: "" | ||
# | ||
# } | ||
} | ||
|
||
// Required - Indicates the AWS region, should be in lowercase and use hyphens. | ||
// Just like using `software.amazon.awssdk.regions.Region.of(_)` | ||
// Examples: [ap-south-1, us-gov-east-1, af-south-1, eu-west-2, aws-global] | ||
region: "eu-west-1" | ||
|
||
// Optional - string to overrides endpoint url | ||
# endpoint: "localhost:4566" | ||
|
||
// Optional - settings for the underlying async http client | ||
# http-client: { | ||
# max-concurrency: 10 | ||
# max-pending-connection-acquires: 1000 | ||
# connection-acquisition-timeout: 2 minutes | ||
# connection-time-to-live: 1 minute | ||
# use-idle-connection-reaper: false | ||
# read-timeout: 100 seconds | ||
# write-timeout: 100 seconds | ||
# } | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.