Skip to content

Commit 1504fda

Browse files
authored
Merge pull request #30 from r7wx/development
v1.2.1
2 parents a4b4a19 + 47a0ab1 commit 1504fda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2120
-2459
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
- name: Setup Go
2020
uses: actions/setup-go@v3
2121
with:
22-
go-version: 1.18
22+
go-version: 1.19
2323

2424
- name: Setup Node
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: 17
27+
node-version: 19
2828

2929
- name: Build React
3030
run: |

.github/workflows/coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Go
2020
uses: actions/setup-go@v3
2121
with:
22-
go-version: 1.18
22+
go-version: 1.19
2323

2424
- name: Coverage
2525
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- name: Setup Go
1818
uses: actions/setup-go@v3
1919
with:
20-
go-version: 1.18
20+
go-version: 1.19
2121

2222
- name: Setup Node
2323
uses: actions/setup-node@v3
2424
with:
25-
node-version: 17
25+
node-version: 19
2626

2727
- name: Go Releaser
2828
uses: goreleaser/goreleaser-action@v3

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v3
2020
with:
21-
go-version: 1.18
21+
go-version: 1.19
2222

2323
- name: Test
2424
run: go test -v ./...

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ yarn-debug.log*
2424
yarn-error.log*
2525
easy_gate_test_*
2626
.vscode/
27-
example.json
27+
test.json

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM node:17 AS web-builder
1+
FROM node:19 AS web-builder
22
WORKDIR /easy-gate-web
33
COPY ./web .
44
RUN yarn install && yarn build
55

6-
FROM golang:1.18 AS go-builder
6+
FROM golang:1.20 AS go-builder
77
WORKDIR /easy-gate
88
COPY . .
99
COPY --from=web-builder ./easy-gate-web/build ./web/build

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ A service entry is used to define a service that is available in the infrastruct
258258
259259
- **name:** the name of the service (ex. Internal Git, Jenkins, ...)
260260
- **url:** the service url (must be a valid url starting with http(s)://)
261+
- **category:** service category (each service will appear under its own category).
261262
- **groups:** list of groups associated to this service (defined in the groups section). If no group is provided the item can be seen by all users:
262263
- **icon (optional):** the icon parameter accepts image URLs or data URI. If the icon parameter is not provided or empty, Easy Gate will try to fetch the service favicon and display it or fallback to a default icon.
263264
@@ -276,6 +277,7 @@ A service entry is used to define a service that is available in the infrastruct
276277
{
277278
"name": "Portainer",
278279
"url": "https://portainer.example.all",
280+
"category": "Test",
279281
"icon": "data:image/png;base64,[...]",
280282
"groups": []
281283
}
@@ -290,6 +292,7 @@ A service entry is used to define a service that is available in the infrastruct
290292
- vpn
291293
- name: Portainer
292294
url: https://portainer.example.all
295+
category: "Test"
293296
icon: data:image/png;base64,[...]
294297
groups: []
295298
```

cmd/easy-gate/main.go

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2022 r7wx
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
21-
*/
22-
231
package main
242

253
import (
@@ -28,8 +6,8 @@ import (
286
"time"
297

308
"github.com/r7wx/easy-gate/internal/config"
9+
"github.com/r7wx/easy-gate/internal/engine"
3110
"github.com/r7wx/easy-gate/internal/routine"
32-
"github.com/r7wx/easy-gate/internal/service"
3311
)
3412

3513
func main() {
@@ -47,6 +25,5 @@ func main() {
4725
}
4826
go cfgRoutine.Start()
4927

50-
service := service.NewService(cfgRoutine)
51-
service.Serve()
28+
engine.NewEngine(cfgRoutine).Serve()
5229
}

easy-gate.json

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"services": [
2323
{
2424
"name": "Git",
25+
"category": "",
2526
"url": "https://git.example.internal",
2627
"groups": [
2728
"internal",
@@ -30,18 +31,21 @@
3031
},
3132
{
3233
"name": "Files",
34+
"category": "",
3335
"url": "https://files.example.internal",
3436
"groups": [
3537
"internal"
3638
]
3739
},
3840
{
3941
"name": "Google",
42+
"category": "",
4043
"url": "https://www.google.com",
4144
"groups": []
4245
},
4346
{
4447
"name": "Youtube",
48+
"category": "",
4549
"url": "https://www.youtube.com",
4650
"groups": []
4751
}

easy-gate.yml

+4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,22 @@ groups:
1414
subnet: 10.8.1.1/24
1515
services:
1616
- name: Git
17+
category: ""
1718
url: https://git.example.internal
1819
groups:
1920
- internal
2021
- vpn
2122
- name: Files
23+
category: ""
2224
url: https://files.example.internal
2325
groups:
2426
- internal
2527
- name: Google
28+
category: ""
2629
url: https://www.google.com
2730
groups: []
2831
- name: Youtube
32+
category: ""
2933
url: https://www.youtube.com
3034
groups: []
3135
notes:

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/r7wx/easy-gate
22

3-
go 1.18
3+
go 1.20
44

55
require gopkg.in/yaml.v3 v3.0.1

internal/config/config.go

+23-45
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,43 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2022 r7wx
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
21-
*/
22-
231
package config
242

253
import (
264
"encoding/json"
5+
"fmt"
276

28-
"github.com/r7wx/easy-gate/internal/errors"
29-
"github.com/r7wx/easy-gate/internal/models"
7+
"github.com/r7wx/easy-gate/internal/group"
8+
"github.com/r7wx/easy-gate/internal/theme"
309
"gopkg.in/yaml.v3"
3110
)
3211

3312
// Service - Easy Gate service configuration struct
3413
type Service struct {
35-
Icon string `json:"icon" yaml:"icon"`
36-
Name string `json:"name" yaml:"name"`
37-
URL string `json:"url" yaml:"url"`
38-
Groups []string `json:"groups" yaml:"groups"`
14+
Icon string `json:"icon" yaml:"icon"`
15+
Name string `json:"name" yaml:"name"`
16+
URL string `json:"url" yaml:"url"`
17+
Category string `json:"category" yaml:"category"`
18+
Groups []string `json:"groups" yaml:"groups"`
3919
}
4020

4121
// Note - Easy Gate note configuration struct
4222
type Note struct {
43-
Name string `json:"name" yaml:"name"`
44-
Text string `json:"text" yaml:"text"`
45-
Groups []string `json:"groups" yaml:"groups"`
23+
Name string `json:"name" yaml:"name"`
24+
Text string `json:"text" yaml:"text"`
25+
Category string `json:"category" yaml:"category"`
26+
Groups []string `json:"groups" yaml:"groups"`
4627
}
4728

4829
// Config - Easy Gate configuration struct
4930
type Config struct {
50-
Theme models.Theme `json:"theme" yaml:"theme"`
51-
Addr string `json:"addr" yaml:"addr"`
52-
Title string `json:"title" yaml:"title"`
53-
CertFile string `json:"cert_file" yaml:"cert_file"`
54-
KeyFile string `json:"key_file" yaml:"key_file"`
55-
Groups []models.Group `json:"groups" yaml:"groups"`
56-
Services []Service `json:"services" yaml:"services"`
57-
Notes []Note `json:"notes" yaml:"notes"`
58-
BehindProxy bool `json:"behind_proxy" yaml:"behind_proxy"`
59-
UseTLS bool `json:"use_tls" yaml:"use_tls"`
31+
Theme theme.Theme `json:"theme" yaml:"theme"`
32+
Addr string `json:"addr" yaml:"addr"`
33+
Title string `json:"title" yaml:"title"`
34+
CertFile string `json:"cert_file" yaml:"cert_file"`
35+
KeyFile string `json:"key_file" yaml:"key_file"`
36+
Groups []group.Group `json:"groups" yaml:"groups"`
37+
Services []Service `json:"services" yaml:"services"`
38+
Notes []Note `json:"notes" yaml:"notes"`
39+
BehindProxy bool `json:"behind_proxy" yaml:"behind_proxy"`
40+
UseTLS bool `json:"use_tls" yaml:"use_tls"`
6041
}
6142

6243
type format int
@@ -86,8 +67,5 @@ func Unmarshal(configBytes []byte) (*Config, error) {
8667
}
8768
}
8869

89-
return nil, errors.NewEasyGateError(
90-
errors.InvalidFormat,
91-
errors.ConfigurationFile, "",
92-
)
70+
return nil, fmt.Errorf("Invalid configuration file format")
9371
}

internal/config/config_test.go

-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2022 r7wx
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
21-
*/
22-
231
package config
242

253
import (

internal/config/load.go

-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2022 r7wx
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
21-
*/
22-
231
package config
242

253
import (

internal/config/path.go

-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2022 r7wx
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20-
SOFTWARE.
21-
*/
22-
231
package config
242

253
import (

0 commit comments

Comments
 (0)