Skip to content

Commit 0e7bec1

Browse files
authored
Add InsecureSkipVerify to Minio Client for Storage (#23166)
Allows using Minio with untrusted certificates Closes #23128 Signed-off-by: Yarden Shoham <[email protected]>
1 parent 303b72c commit 0e7bec1

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

Diff for: custom/conf/app.example.ini

+6
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,9 @@ ROUTER = console
18711871
;;
18721872
;; Minio enabled ssl only available when STORAGE_TYPE is `minio`
18731873
;MINIO_USE_SSL = false
1874+
;;
1875+
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
1876+
;MINIO_INSECURE_SKIP_VERIFY = false
18741877

18751878
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18761879
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2552,6 +2555,9 @@ ROUTER = console
25522555
;;
25532556
;; Minio enabled ssl only available when STORAGE_TYPE is `minio`
25542557
;MINIO_USE_SSL = false
2558+
;;
2559+
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
2560+
;MINIO_INSECURE_SKIP_VERIFY = false
25552561

25562562
;[proxy]
25572563
;; Enable the proxy, all requests to external via HTTP will be affected

Diff for: docs/content/doc/advanced/config-cheat-sheet.en-us.md

+6
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ Default templates for project boards:
854854
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when STORAGE_TYPE is `minio`
855855
- `MINIO_BASE_PATH`: **attachments/**: Minio base path on the bucket only available when STORAGE_TYPE is `minio`
856856
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio`
857+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
857858

858859
## Log (`log`)
859860

@@ -1268,6 +1269,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`.
12681269
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
12691270
- `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
12701271
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
1272+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
12711273

12721274
## Storage (`storage`)
12731275

@@ -1280,6 +1282,7 @@ Default storage configuration for attachments, lfs, avatars and etc.
12801282
- `MINIO_BUCKET`: **gitea**: Minio bucket to store the data only available when `STORAGE_TYPE` is `minio`
12811283
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
12821284
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
1285+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
12831286

12841287
And you can also define a customize storage like below:
12851288

@@ -1298,6 +1301,8 @@ MINIO_BUCKET = gitea
12981301
MINIO_LOCATION = us-east-1
12991302
; Minio enabled ssl only available when STORAGE_TYPE is `minio`
13001303
MINIO_USE_SSL = false
1304+
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
1305+
MINIO_INSECURE_SKIP_VERIFY = false
13011306
```
13021307

13031308
And used by `[attachment]`, `[lfs]` and etc. as `STORAGE_TYPE`.
@@ -1318,6 +1323,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`.
13181323
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
13191324
- `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
13201325
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
1326+
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
13211327

13221328
## Proxy (`proxy`)
13231329

Diff for: docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

+2
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ MINIO_BUCKET = gitea
431431
MINIO_LOCATION = us-east-1
432432
; Minio enabled ssl only available when STORAGE_TYPE is `minio`
433433
MINIO_USE_SSL = false
434+
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
435+
MINIO_INSECURE_SKIP_VERIFY = false
434436
```
435437

436438
然后你在 `[attachment]`, `[lfs]` 等中可以把这个名字用作 `STORAGE_TYPE` 的值。

Diff for: modules/setting/storage.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func getStorage(rootCfg ConfigProvider, name, typ string, targetSec *ini.Section
4141
sec.Key("MINIO_BUCKET").MustString("gitea")
4242
sec.Key("MINIO_LOCATION").MustString("us-east-1")
4343
sec.Key("MINIO_USE_SSL").MustBool(false)
44+
sec.Key("MINIO_INSECURE_SKIP_VERIFY").MustBool(false)
4445

4546
if targetSec == nil {
4647
targetSec, _ = rootCfg.NewSection(name)

Diff for: modules/storage/minio.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ package storage
55

66
import (
77
"context"
8+
"crypto/tls"
89
"io"
10+
"net/http"
911
"net/url"
1012
"os"
1113
"path"
@@ -42,13 +44,14 @@ const MinioStorageType Type = "minio"
4244

4345
// MinioStorageConfig represents the configuration for a minio storage
4446
type MinioStorageConfig struct {
45-
Endpoint string `ini:"MINIO_ENDPOINT"`
46-
AccessKeyID string `ini:"MINIO_ACCESS_KEY_ID"`
47-
SecretAccessKey string `ini:"MINIO_SECRET_ACCESS_KEY"`
48-
Bucket string `ini:"MINIO_BUCKET"`
49-
Location string `ini:"MINIO_LOCATION"`
50-
BasePath string `ini:"MINIO_BASE_PATH"`
51-
UseSSL bool `ini:"MINIO_USE_SSL"`
47+
Endpoint string `ini:"MINIO_ENDPOINT"`
48+
AccessKeyID string `ini:"MINIO_ACCESS_KEY_ID"`
49+
SecretAccessKey string `ini:"MINIO_SECRET_ACCESS_KEY"`
50+
Bucket string `ini:"MINIO_BUCKET"`
51+
Location string `ini:"MINIO_LOCATION"`
52+
BasePath string `ini:"MINIO_BASE_PATH"`
53+
UseSSL bool `ini:"MINIO_USE_SSL"`
54+
InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"`
5255
}
5356

5457
// MinioStorage returns a minio bucket storage
@@ -90,8 +93,9 @@ func NewMinioStorage(ctx context.Context, cfg interface{}) (ObjectStorage, error
9093
log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath)
9194

9295
minioClient, err := minio.New(config.Endpoint, &minio.Options{
93-
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
94-
Secure: config.UseSSL,
96+
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
97+
Secure: config.UseSSL,
98+
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}},
9599
})
96100
if err != nil {
97101
return nil, convertMinioErr(err)

0 commit comments

Comments
 (0)