Skip to content

Commit 0f79661

Browse files
authored
Merge pull request #4 from oxyno-zeta/develop
Develop
2 parents 335b64d + a24a76a commit 0f79661

File tree

11 files changed

+1548
-272
lines changed

11 files changed

+1548
-272
lines changed

.circleci/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ jobs:
4242
keys:
4343
- go-mod-{{ checksum "go.mod" }}
4444
- run: make test
45+
- run: make coverage-report
46+
- run: mv coverage.html /tmp/artifacts
47+
- store_artifacts:
48+
path: /tmp/artifacts
49+
- run: go get github.com/mattn/goveralls
50+
- run: goveralls -coverprofile=c.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
4551
workflows:
4652
version: 2
4753
project:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
TARGETS ?= linux/amd64 darwin/amd64 linux/amd64 windows/amd64 linux/386 linux/ppc64le linux/s390x linux/arm linux/arm64
22
PROJECT_NAME := s3-proxy
33
PKG := github.com/oxyno-zeta/$(PROJECT_NAME)
4-
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
54

65
# go option
76
GO ?= go
@@ -64,11 +63,12 @@ ifndef HAS_GORELEASER
6463
endif
6564

6665
test: dep ## Run unittests
67-
$(GO) test -short -cover -coverprofile=c.out ${PKG_LIST}
66+
$(GO) test -v -coverpkg=./pkg/... -coverprofile=c.out ./pkg/...
6867

6968
.PHONY: coverage-report
7069
coverage-report:
7170
$(GO) tool cover -html=c.out -o coverage.html
71+
$(GO) tool cover -func c.out
7272

7373
.PHONY: clean
7474
clean:

conf/config-example.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ log:
2020
# targetList: templates/target-list.tpl
2121
# unauthorized: templates/unauthorized.tpl
2222

23-
# Authentication
24-
# auth:
23+
# Authentication Providers
24+
# authProviders:
2525
# oidc:
2626
# provider1:
2727
# clientID: client-id
@@ -71,7 +71,7 @@ log:
7171
# # OIDC section for access filter
7272
# oidc:
7373
# # NOTE: This list can be empty ([]) for authentication only and no group filter
74-
# authorizationAccesses: # Authorization accesses : groups or email
74+
# authorizationAccesses: # Authorization accesses : groups or email or regexp
7575
# - group: devops_users
7676
# # Basic authentication section
7777
# basic:
@@ -107,7 +107,7 @@ targets:
107107
# # OIDC section for access filter
108108
# oidc:
109109
# # NOTE: This list can be empty ([]) for authentication only and no group filter
110-
# authorizationAccesses: # Authorization accesses : groups or email
110+
# authorizationAccesses: # Authorization accesses : groups or email or regexp
111111
# - group: specific_users
112112
# # A Path must be declared for a resource filtering (a wildcard can be added to match every sub path)
113113
# - path: /directory1/*

docs/configuration.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ You can see a full example in the [Example section](#example)
77

88
## Main structure
99

10-
| Key | Type | Required | Default | Description |
11-
| -------------- | ----------------------------------------------------- | -------- | ------- | ---------------------------------- |
12-
| log | [LogConfiguration](#logconfiguration) | No | None | Log configurations |
13-
| server | [ServerConfiguration](#serverconfiguration) | No | None | Server configurations |
14-
| internalServer | [ServerConfiguration](#serverconfiguration) | No | None | Internal Server configurations |
15-
| template | [TemplateConfiguration](#templateconfiguration) | No | None | Template configurations |
16-
| targets | [[TargetConfiguration]](#targetconfiguration) | Yes | None | Targets configuration |
17-
| auth | [AuthConfiguration](#authconfiguration) | No | None | Authentication configuration |
18-
| listTargets | [ListTargetsConfiguration](#listtargetsconfiguration) | No | None | List targets feature configuration |
10+
| Key | Type | Required | Default | Description |
11+
| -------------- | --------------------------------------------------------- | -------- | ------- | -------------------------------------- |
12+
| log | [LogConfiguration](#logconfiguration) | No | None | Log configurations |
13+
| server | [ServerConfiguration](#serverconfiguration) | No | None | Server configurations |
14+
| internalServer | [ServerConfiguration](#serverconfiguration) | No | None | Internal Server configurations |
15+
| template | [TemplateConfiguration](#templateconfiguration) | No | None | Template configurations |
16+
| targets | [[TargetConfiguration]](#targetconfiguration) | Yes | None | Targets configuration |
17+
| authProviders | [AuthProvidersConfiguration](#authProvidersconfiguration) | No | None | Authentication providers configuration |
18+
| listTargets | [ListTargetsConfiguration](#listtargetsconfiguration) | No | None | List targets feature configuration |
1919

2020
## LogConfiguration
2121

@@ -114,7 +114,7 @@ You can see a full example in the [Example section](#example)
114114
| env | String | Only if path and value are not set | None | Environment variable name to use to load credential |
115115
| value | String | Only if path and env are not set | None | Credential value directly (Not recommended) |
116116

117-
## AuthConfiguration
117+
## AuthProvidersConfiguration
118118

119119
| Key | Type | Required | Default | Description |
120120
| ----- | ------------------------------------------------------------ | -------- | ------- | ------------------------------------------------- |
@@ -162,10 +162,11 @@ You can see a full example in the [Example section](#example)
162162

163163
## OIDCAuthorizationAccesses
164164

165-
| Key | Type | Required | Default | Description |
166-
| ----- | ------ | ---------------------- | ------- | ----------- |
167-
| group | String | Required without email | None | Group name |
168-
| email | String | Required without group | None | Email |
165+
| Key | Type | Required | Default | Description |
166+
| ------ | ------- | ---------------------- | ------- | ---------------------------------------------- |
167+
| group | String | Required without email | None | Group name |
168+
| email | String | Required without group | None | Email |
169+
| regexp | Boolean | No | `false` | Consider group or email as regexp for matching |
169170

170171
## ResourceBasic
171172

@@ -220,8 +221,8 @@ log:
220221
# targetList: templates/target-list.tpl
221222
# unauthorized: templates/unauthorized.tpl
222223

223-
# Authentication
224-
# auth:
224+
# Authentication Providers
225+
# authProviders:
225226
# oidc:
226227
# provider1:
227228
# clientID: client-id
@@ -265,7 +266,7 @@ log:
265266
# # OIDC section for access filter
266267
# oidc:
267268
# # NOTE: This list can be empty ([]) for authentication only and no group filter
268-
# authorizationAccesses: # Authorization accesses : groups or email
269+
# authorizationAccesses: # Authorization accesses : groups or email or regexp
269270
# - group: devops_users
270271
# # Basic authentication section
271272
# basic:
@@ -296,7 +297,7 @@ targets:
296297
# # OIDC section for access filter
297298
# oidc:
298299
# # NOTE: This list can be empty ([]) for authentication only and no group filter
299-
# authorizationAccesses: # Authorization accesses : groups or email
300+
# authorizationAccesses: # Authorization accesses : groups or email or regexp
300301
# - group: specific_users
301302
# # A Path must be declared for a resource filtering (a wildcard can be added to match every sub path)
302303
# - path: /directory1/*

pkg/bucket/requestContext.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,22 @@ func (rctx *requestContext) Get(requestPath string) {
9090
if indexDocumentEntry != nil {
9191
// Get data
9292
err = getFile(rctx, indexDocumentEntry.(*Entry).Key)
93-
// Check if error is a not found error
94-
if err == s3client.ErrNotFound {
95-
// Not found
96-
rctx.handleNotFound(rctx.httpRW, requestPath, rctx.logger, rctx.tplConfig)
93+
// Check if error exists
94+
if err != nil {
95+
// Check if error is a not found error
96+
if err == s3client.ErrNotFound {
97+
// Not found
98+
rctx.handleNotFound(rctx.httpRW, requestPath, rctx.logger, rctx.tplConfig)
99+
return
100+
}
101+
// Log error
102+
rctx.logger.Error(err)
103+
// Response with error
104+
rctx.handleInternalServerError(rctx.httpRW, err, requestPath, rctx.logger, rctx.tplConfig)
105+
// Stop
97106
return
98107
}
99-
// Log error
100-
rctx.logger.Error(err)
101-
// Response with error
102-
rctx.handleInternalServerError(rctx.httpRW, err, requestPath, rctx.logger, rctx.tplConfig)
103-
// Stop
108+
// Stop here because no error are present
104109
return
105110
}
106111
}

0 commit comments

Comments
 (0)