Skip to content

Commit 2654f28

Browse files
authored
Fixed trigger check (#251)
1 parent d081119 commit 2654f28

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

handlers/auth.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ var (
1818
errNotAuthorized = errors.New("no or invalid jwt token provided. You are not authorized")
1919

2020
// Non-protected URL paths which are prefix checked
21-
nonProtectedPathsPrefix = []string {
21+
nonProtectedPathsPrefix = []string{
2222
"/login",
2323
"/pipeline/githook",
24-
"/trigger",
2524
"/worker/register",
2625
"/js/",
2726
"/img/",
2827
"/fonts/",
2928
"/css/",
3029
}
3130

31+
// Non-protected URL paths which are suffix checked
32+
nonProtectedPathsSuffix = []string{
33+
"/trigger",
34+
}
35+
3236
// Non-protected URL paths which are explicitly checked
33-
nonProtectedPaths = []string {
37+
nonProtectedPaths = []string{
3438
"/",
3539
"/favicon.ico",
3640
}
@@ -59,6 +63,14 @@ func AuthMiddleware(roleAuth *AuthConfig) echo.MiddlewareFunc {
5963
}
6064
}
6165

66+
// Check if it matches a suffix-based paths
67+
for _, suffix := range nonProtectedPathsSuffix {
68+
switch {
69+
case strings.HasSuffix(c.Path(), suffix):
70+
return next(c)
71+
}
72+
}
73+
6274
token, err := getToken(c)
6375
if err != nil {
6476
return c.String(http.StatusUnauthorized, err.Error())

0 commit comments

Comments
 (0)