Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication on wallet api route. #477

Merged
merged 9 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/it/resources/template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ scorex {
}
restApi {
bindAddress = "0.0.0.0:9051"
apiKeyHash = null
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ scorex {
}
restApi {
bindAddress = "0.0.0.0:9052"
apiKeyHash = "1111"
}
}
2 changes: 1 addition & 1 deletion src/main/scala/org/ergoplatform/api/WalletApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e
withWalletOp(op)(ApiResponse.apply[T])
}

override val route: Route = (pathPrefix("wallet") & withCors) {
override val route: Route = (pathPrefix("wallet") & withCors & withAuth) {
balancesRoute ~
unconfirmedBalanceRoute ~
addressesRoute ~
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ ergo {
}
}

scorex {
restApi {
apiKeyHash = null
}
}

akka {
test {
timefactor = 2 # duration scale factor to prevent spurious test failures on the heavily loaded CI servers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ergoplatform.api.routes

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.testkit.ScalatestRouteTest
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport
import io.circe.syntax._
Expand All @@ -19,11 +20,11 @@ class WalletApiRouteSpec extends FlatSpec

val prefix = "/wallet"

val ergoSettings = ErgoSettings.read(None)
implicit val requestEncoder = new PaymentRequestEncoder(ergoSettings)
val route = WalletApiRoute(readersRef, nodeViewRef, settings).route
val ergoSettings: ErgoSettings = ErgoSettings.read(Some("src/test/resources/application.conf"))
val route: Route = WalletApiRoute(readersRef, nodeViewRef, settings).route

private implicit val ergoAddressEncoder = new ErgoAddressEncoder(ergoSettings)
implicit val requestEncoder: PaymentRequestEncoder = new PaymentRequestEncoder(ergoSettings)
implicit val ergoAddressEncoder: ErgoAddressEncoder = new ErgoAddressEncoder(ergoSettings)

it should "generate transaction" in {
val amount = 100L
Expand Down