Skip to content

Commit

Permalink
added encryption methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rzrbld committed Nov 29, 2020
1 parent e0d5014 commit 40e3a70
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 50 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Adminio-API expose metrics for [Prometheus](https://prometheus.io/) at `/metrics
| `MINIO_REGION` | set minio region | us-east-1 |
| `MINIO_ACCESS` | set minio Access Key | test |
| `MINIO_SECRET` | set minio Secret Key | testtest123 |
| `MINIO_DEFAULT_LOCK_OBLECT_ENABLE` | set minio default make bucket behaviour with locking object | false |
| `ADMINIO_CORS_DOMAIN` | set adminio-api CORS policy domain | * |
| `ADMINIO_OAUTH_ENABLE` | enable oauth over supported providers | false |
| `ADMINIO_OAUTH_PROVIDER` | oauth provider, for more information see the full list of supported providers | github |
Expand Down
117 changes: 114 additions & 3 deletions openAPI/openapi_v3.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: "3.0.0"
info:
description: "Adminio API"
version: "2.3.0"
version: "2.4.0"
title: "Adminio API"
contact:
name: "rzrbld at github.com"
Expand Down Expand Up @@ -66,6 +66,11 @@ paths:
type: string
format: string
newBucketRegion:
description: Optional parameter. if value is null value will be retrieved from ENV variable
type: string
format: string
newBucketObjectLocking:
description: Optional parameter. if value is null value will be retrieved from ENV variable
type: string
format: string
responses:
Expand Down Expand Up @@ -473,6 +478,98 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Error"
/bucket/set-encryption:
post:
summary: Set bucket encryption
operationId: setBucketEncryption
tags:
- bucket
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
bucketName:
type: string
format: string
bucketEncryptionType:
description: available options is sse-kms ans sse-s3
type: string
format: string
kmsMasterKey:
description: master key ID if use sse-kms
type: string
format: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/Success"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/bucket/get-encryption:
post:
summary: Get bucket encryption
operationId: getBucketEncryption
tags:
- bucket
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
bucketName:
type: string
format: string
responses:
'200':
description: bucket encryption
content:
application/json:
schema:
$ref: "#/components/schemas/BucketEncryption"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/bucket/remove-encryption:
post:
summary: Remove bucket encryption
operationId: removeBucketEncryption
tags:
- bucket
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
bucketName:
type: string
format: string
responses:
'200':
description: bucket encryption removed
content:
application/json:
schema:
$ref: "#/components/schemas/Success"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/list:
get:
summary: List all users
Expand Down Expand Up @@ -1125,7 +1222,20 @@ components:
type: array
items:
type: string

BucketEncryption:
type: object
properties:
XMLname:
type: object
properties:
Space:
type: string
Local:
type: string
Rules:
type: array
items:
type: object
BucketEvent:
type: object
properties:
Expand Down Expand Up @@ -1184,6 +1294,8 @@ components:
$ref: "#/components/schemas/BucketTags"
policy:
type: string
encryption:
$ref: "#/components/schemas/BucketEncryption"
BucketLifecycle:
type: string
Error:
Expand All @@ -1201,4 +1313,3 @@ components:
properties:
Success:
type: string

11 changes: 9 additions & 2 deletions src/clients/clients.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package clients

import (
minio "github.com/minio/minio-go/v6"
minio "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
madmin "github.com/minio/minio/pkg/madmin"
cnf "github.com/rzrbld/adminio-api/config"
"log"
)

var MadmClnt, MadmErr = madmin.New(cnf.Server, cnf.Maccess, cnf.Msecret, cnf.Ssl)
var MinioClnt, MinioErr = minio.New(cnf.Server, cnf.Maccess, cnf.Msecret, cnf.Ssl)

// var MinioClnt, MinioErr = minio.New(cnf.Server, cnf.Maccess, cnf.Msecret, cnf.Ssl)

var MinioClnt, MinioErr = minio.New(cnf.Server, &minio.Options{
Creds: credentials.NewStaticV4(cnf.Maccess, cnf.Msecret, ""),
Secure: cnf.Ssl,
})

func main() {
if MadmErr != nil {
Expand Down
16 changes: 9 additions & 7 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
)

var (
Server = getEnv("MINIO_HOST_PORT", "localhost:9000")
Maccess = getEnv("MINIO_ACCESS", "test")
Msecret = getEnv("MINIO_SECRET", "testtest123")
Region = getEnv("MINIO_REGION", "us-east-1")
Ssl, _ = strconv.ParseBool(getEnv("MINIO_SSL", "false"))
ServerHostPort = getEnv("ADMINIO_HOST_PORT", "localhost:8080")
AdminioCORS = getEnv("ADMINIO_CORS_DOMAIN", "*")
Server = getEnv("MINIO_HOST_PORT", "localhost:9000")
Maccess = getEnv("MINIO_ACCESS", "test")
Msecret = getEnv("MINIO_SECRET", "testtest123")
Region = getEnv("MINIO_REGION", "us-east-1")
// Enable object locking by default
DefaultObjectLocking, _ = strconv.ParseBool(getEnv("MINIO_DEFAULT_LOCK_OBLECT_ENABLE", "false"))
Ssl, _ = strconv.ParseBool(getEnv("MINIO_SSL", "false"))
ServerHostPort = getEnv("ADMINIO_HOST_PORT", "localhost:8080")
AdminioCORS = getEnv("ADMINIO_CORS_DOMAIN", "*")
// AES only supports key sizes of 16, 24 or 32 bytes.
// You either need to provide exactly that amount or you derive the key from what you type in.
ScHashKey = getEnv("ADMINIO_COOKIE_HASH_KEY", "NRUeuq6AdskNPa7ewZuxG9TrDZC4xFat")
Expand Down
17 changes: 10 additions & 7 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ require (
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/etcd-io/bbolt v1.3.3 // indirect
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/flosch/pongo2/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gavv/httpexpect v2.0.0+incompatible // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect
github.com/go-check/check v0.0.0-20200902074654-038fdea0a05b // indirect
github.com/google/go-cmp v0.5.3 // indirect
github.com/google/go-cmp v0.5.4 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/gorilla/securecookie v1.1.1
Expand Down Expand Up @@ -51,9 +52,9 @@ require (
github.com/minio/hdfs/v3 v3.0.1 // indirect
github.com/minio/lsync v1.0.1 // indirect
github.com/minio/md5-simd v1.1.1 // indirect
github.com/minio/minio v0.0.0-20201117171328-7ff8128f15ce
github.com/minio/minio v0.0.0-20201129051545-bdd094bc3927
github.com/minio/minio-go/v6 v6.0.58-0.20200612001654-a57fec8037ec
github.com/minio/minio-go/v7 v7.0.6-0.20200929220449-755b5633803a
github.com/minio/minio-go/v7 v7.0.6
github.com/minio/parquet-go v0.0.0-20200414234858-838cfa8aae61 // indirect
github.com/montanaflynn/stats v0.6.3 // indirect
github.com/moul/http2curl v1.0.0 // indirect
Expand All @@ -80,11 +81,12 @@ require (
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/square/go-jose/v3 v3.0.0-20200630053402-0a67ce9b0693 // indirect
github.com/stretchr/testify v1.6.1 // indirect
github.com/tdewolff/parse/v2 v2.5.6 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/ugorji/go v1.1.5-pre // indirect
github.com/valyala/fasthttp v1.16.0 // indirect
github.com/vmihailenco/msgpack/v4 v4.3.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.0.0-rc.5 // indirect
github.com/vmihailenco/msgpack/v5 v5.0.0 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
Expand All @@ -93,15 +95,16 @@ require (
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
go.uber.org/zap v1.15.0 // indirect
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 // indirect
golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7 // indirect
golang.org/x/sys v0.0.0-20201126233918-771906719818 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/check.v1 v1.0.0-20201128035030-22ab2dfb190c // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)
Loading

0 comments on commit 40e3a70

Please sign in to comment.