-
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.
Merge pull request #11 from ing-bank/feature/list-all-buckets
Feature/list all buckets
- Loading branch information
Showing
11 changed files
with
216 additions
and
48 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ services: | |
language: scala | ||
|
||
scala: | ||
- 2.12.6 | ||
- 2.12.7 | ||
|
||
env: | ||
global: | ||
|
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version = 1.1.6 | ||
sbt.version = 1.2.6 |
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
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
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
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
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
40 changes: 40 additions & 0 deletions
40
src/main/scala/com/ing/wbaa/airlock/proxy/api/ProxyServiceWithListAllBuckets.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 @@ | ||
package com.ing.wbaa.airlock.proxy.api | ||
|
||
import akka.http.scaladsl.marshallers.xml.ScalaXmlSupport | ||
import akka.http.scaladsl.model.HttpRequest | ||
import akka.http.scaladsl.server.Route | ||
import com.ing.wbaa.airlock.proxy.data.{ Read, S3Request, User } | ||
import akka.http.scaladsl.server.Directives._ | ||
|
||
import scala.xml.NodeSeq | ||
|
||
/** | ||
* Because aws api allows only list own buckets and we want user to see all bucket in our system | ||
* there is a hack to list bucket by radosgw-admin request | ||
* The standard aws functionality are in the ProxyService trait | ||
*/ | ||
trait ProxyServiceWithListAllBuckets extends ProxyService with ScalaXmlSupport { | ||
|
||
protected[this] def listAllBuckets: Seq[String] | ||
|
||
override protected[this] def processAuthorizedRequest(httpRequest: HttpRequest, s3Request: S3Request, userSTS: User): Route = { | ||
s3Request match { | ||
//only when list buckets is requested we show all buckets | ||
case S3Request(_, None, None, accessType) if accessType == Read => | ||
complete(getListAllMyBucketsXml()) | ||
case _ => super.processAuthorizedRequest(httpRequest, s3Request, userSTS) | ||
} | ||
} | ||
|
||
private def getListAllMyBucketsXml(user: String = "npa", createDate: String = "2018-01-01T00:00:00.000Z"): NodeSeq = { | ||
<ListAllMyBucketsResult> | ||
<Owner> | ||
<ID>{ user }</ID> | ||
<DisplayName>{ user }</DisplayName> | ||
</Owner> | ||
<Buckets> | ||
{ for (bucketName <- listAllBuckets) yield <Bucket><Name>{ bucketName }</Name><CreationDate>{ createDate }</CreationDate></Bucket> } | ||
</Buckets> | ||
</ListAllMyBucketsResult> | ||
} | ||
} |
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
Oops, something went wrong.