File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- github.com/codeshelldev/gotl v0.0.9 h1:cdLA6XzPt+f4RIW24Yx3dqBbRAq5JO0obzuwhaOgsEo =
2- github.com/codeshelldev/gotl v0.0.9 /go.mod h1:rDkJma6eQSRfCr7ieX9/esn3/uAWNzjHfpjlr9j6FFk =
31github.com/codeshelldev/gotl v0.0.12 h1:VM3W6hiEfPgK+cCLT70S004tYAdhQWXD72FtFqCF+2Q =
42github.com/codeshelldev/gotl v0.0.12 /go.mod h1:rDkJma6eQSRfCr7ieX9/esn3/uAWNzjHfpjlr9j6FFk =
53github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c =
Original file line number Diff line number Diff line change @@ -5,8 +5,11 @@ type ENV struct {
55 DEFAULTS_PATH string
66 FAVICON_PATH string
77 TOKENS_DIR string
8+
89 INSECURE bool
910
11+ TOKENS []string
12+
1013 CONFIGS map [string ]* CONFIG
1114}
1215
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ func InitTokens() {
7171 if len (apiTokens ) > 0 {
7272 log .Debug ("Registered " + strconv .Itoa (len (apiTokens )) + " Tokens" )
7373 }
74+
75+ ENV .TOKENS = apiTokens
7476}
7577
7678func parseTokenConfigs (configArray []structure.CONFIG ) map [string ]structure.CONFIG {
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package middlewares
33import (
44 "context"
55 "encoding/base64"
6- "maps"
76 "net/http"
87 "slices"
98 "strings"
@@ -18,15 +17,14 @@ var Auth Middleware = Middleware{
1817}
1918
2019func authHandler (next http.Handler ) http.Handler {
21- tokenKeys := maps . Keys ( config . ENV . CONFIGS )
22- tokens := slices . Collect ( tokenKeys )
20+ return http . HandlerFunc ( func ( w http. ResponseWriter , req * http. Request ) {
21+ tokens := config . ENV . TOKENS
2322
24- if tokens == nil {
25- tokens = []string {}
26- }
23+ if tokens == nil {
24+ tokens = []string {}
25+ }
2726
28- return http .HandlerFunc (func (w http.ResponseWriter , req * http.Request ) {
29- if len (tokens ) <= 0 {
27+ if config .ENV .INSECURE || len (tokens ) <= 0 {
3028 next .ServeHTTP (w , req )
3129 return
3230 }
You can’t perform that action at this time.
0 commit comments