diff --git a/.github/workflows/ci-outpost.yml b/.github/workflows/ci-outpost.yml
index 209e7d4da1..4369d97404 100644
--- a/.github/workflows/ci-outpost.yml
+++ b/.github/workflows/ci-outpost.yml
@@ -29,7 +29,7 @@ jobs:
- name: Generate API
run: make gen-client-go
- name: golangci-lint
- uses: golangci/golangci-lint-action@v6
+ uses: golangci/golangci-lint-action@v7
with:
version: latest
args: --timeout 5000s --verbose
diff --git a/internal/config/config.go b/internal/config/config.go
index a7d3eeb5d0..ca1ec09424 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -162,13 +162,14 @@ func (c *Config) parseScheme(rawVal string) string {
if err != nil {
return rawVal
}
- if u.Scheme == "env" {
+ switch u.Scheme {
+ case "env":
e, ok := os.LookupEnv(u.Host)
if ok {
return e
}
return u.RawQuery
- } else if u.Scheme == "file" {
+ case "file":
d, err := os.ReadFile(u.Path)
if err != nil {
return u.RawQuery
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 0687e84a2b..066592f48e 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -10,7 +10,7 @@ import (
)
func TestConfigEnv(t *testing.T) {
- os.Setenv("AUTHENTIK_SECRET_KEY", "bar")
+ assert.NoError(t, os.Setenv("AUTHENTIK_SECRET_KEY", "bar"))
cfg = nil
if err := Get().fromEnv(); err != nil {
panic(err)
@@ -19,8 +19,8 @@ func TestConfigEnv(t *testing.T) {
}
func TestConfigEnv_Scheme(t *testing.T) {
- os.Setenv("foo", "bar")
- os.Setenv("AUTHENTIK_SECRET_KEY", "env://foo")
+ assert.NoError(t, os.Setenv("foo", "bar"))
+ assert.NoError(t, os.Setenv("AUTHENTIK_SECRET_KEY", "env://foo"))
cfg = nil
if err := Get().fromEnv(); err != nil {
panic(err)
@@ -33,13 +33,15 @@ func TestConfigEnv_File(t *testing.T) {
if err != nil {
log.Fatal(err)
}
- defer os.Remove(file.Name())
+ defer func() {
+ assert.NoError(t, os.Remove(file.Name()))
+ }()
_, err = file.Write([]byte("bar"))
if err != nil {
panic(err)
}
- os.Setenv("AUTHENTIK_SECRET_KEY", fmt.Sprintf("file://%s", file.Name()))
+ assert.NoError(t, os.Setenv("AUTHENTIK_SECRET_KEY", fmt.Sprintf("file://%s", file.Name())))
cfg = nil
if err := Get().fromEnv(); err != nil {
panic(err)
diff --git a/internal/debug/debug.go b/internal/debug/debug.go
index ddd90ffa9e..3897df12e5 100644
--- a/internal/debug/debug.go
+++ b/internal/debug/debug.go
@@ -35,7 +35,7 @@ func EnableDebugServer() {
if err != nil {
return nil
}
- _, err = w.Write([]byte(fmt.Sprintf("%[1]s
", tpl)))
+ _, err = fmt.Fprintf(w, "%[1]s
", tpl)
if err != nil {
l.WithError(err).Warning("failed to write index")
return nil
diff --git a/internal/gounicorn/gounicorn.go b/internal/gounicorn/gounicorn.go
index a3692f3106..6478b91981 100644
--- a/internal/gounicorn/gounicorn.go
+++ b/internal/gounicorn/gounicorn.go
@@ -44,10 +44,11 @@ func New(healthcheck func() bool) *GoUnicorn {
signal.Notify(c, syscall.SIGHUP, syscall.SIGUSR2)
go func() {
for sig := range c {
- if sig == syscall.SIGHUP {
+ switch sig {
+ case syscall.SIGHUP:
g.log.Info("SIGHUP received, forwarding to gunicorn")
g.Reload()
- } else if sig == syscall.SIGUSR2 {
+ case syscall.SIGUSR2:
g.log.Info("SIGUSR2 received, restarting gunicorn")
g.Restart()
}
diff --git a/internal/outpost/ak/api_ws.go b/internal/outpost/ak/api_ws.go
index d92941f760..62f4e9ea48 100644
--- a/internal/outpost/ak/api_ws.go
+++ b/internal/outpost/ak/api_ws.go
@@ -148,7 +148,8 @@ func (ac *APIController) startWSHandler() {
"outpost_type": ac.Server.Type(),
"uuid": ac.instanceUUID.String(),
}).Set(1)
- if wsMsg.Instruction == WebsocketInstructionTriggerUpdate {
+ switch wsMsg.Instruction {
+ case WebsocketInstructionTriggerUpdate:
time.Sleep(ac.reloadOffset)
logger.Debug("Got update trigger...")
err := ac.OnRefresh()
@@ -163,7 +164,7 @@ func (ac *APIController) startWSHandler() {
"build": constants.BUILD(""),
}).SetToCurrentTime()
}
- } else if wsMsg.Instruction == WebsocketInstructionProviderSpecific {
+ case WebsocketInstructionProviderSpecific:
for _, h := range ac.wsHandlers {
h(context.Background(), wsMsg.Args)
}
diff --git a/internal/outpost/ldap/ldap.go b/internal/outpost/ldap/ldap.go
index 383682c78a..f9d4ad61bb 100644
--- a/internal/outpost/ldap/ldap.go
+++ b/internal/outpost/ldap/ldap.go
@@ -66,7 +66,12 @@ func (ls *LDAPServer) StartLDAPServer() error {
return err
}
proxyListener := &proxyproto.Listener{Listener: ln, ConnPolicy: utils.GetProxyConnectionPolicy()}
- defer proxyListener.Close()
+ defer func() {
+ err := proxyListener.Close()
+ if err != nil {
+ ls.log.WithError(err).Warning("failed to close proxy listener")
+ }
+ }()
ls.log.WithField("listen", listen).Info("Starting LDAP server")
err = ls.s.Serve(proxyListener)
diff --git a/internal/outpost/ldap/ldap_tls.go b/internal/outpost/ldap/ldap_tls.go
index 48d4bcf8d9..40dfc25d9b 100644
--- a/internal/outpost/ldap/ldap_tls.go
+++ b/internal/outpost/ldap/ldap_tls.go
@@ -49,7 +49,12 @@ func (ls *LDAPServer) StartLDAPTLSServer() error {
}
proxyListener := &proxyproto.Listener{Listener: ln, ConnPolicy: utils.GetProxyConnectionPolicy()}
- defer proxyListener.Close()
+ defer func() {
+ err := proxyListener.Close()
+ if err != nil {
+ ls.log.WithError(err).Warning("failed to close proxy listener")
+ }
+ }()
tln := tls.NewListener(proxyListener, tlsConfig)
diff --git a/internal/outpost/ldap/search/memory/memory.go b/internal/outpost/ldap/search/memory/memory.go
index 0236cd9f28..c4f23a60e8 100644
--- a/internal/outpost/ldap/search/memory/memory.go
+++ b/internal/outpost/ldap/search/memory/memory.go
@@ -98,7 +98,7 @@ func (ms *MemorySearcher) Search(req *search.Request) (ldap.ServerSearchResult,
entries := make([]*ldap.Entry, 0)
- scope := req.SearchRequest.Scope
+ scope := req.Scope
needUsers, needGroups := ms.si.GetNeededObjects(scope, req.BaseDN, req.FilterObjectClass)
if scope >= 0 && strings.EqualFold(req.BaseDN, baseDN) {
diff --git a/internal/outpost/proxyv2/application/endpoint.go b/internal/outpost/proxyv2/application/endpoint.go
index c9cc50d40c..6137de2254 100644
--- a/internal/outpost/proxyv2/application/endpoint.go
+++ b/internal/outpost/proxyv2/application/endpoint.go
@@ -56,7 +56,7 @@ func GetOIDCEndpoint(p api.ProxyOutpostConfig, authentikHost string, embedded bo
if !embedded && hostBrowser == "" {
return ep
}
- var newHost *url.URL = aku
+ var newHost = aku
var newBrowserHost *url.URL
if embedded {
if authentikHost == "" {
diff --git a/internal/outpost/proxyv2/proxyv2.go b/internal/outpost/proxyv2/proxyv2.go
index eed0ef18ac..1a83081d35 100644
--- a/internal/outpost/proxyv2/proxyv2.go
+++ b/internal/outpost/proxyv2/proxyv2.go
@@ -130,7 +130,12 @@ func (ps *ProxyServer) ServeHTTP() {
return
}
proxyListener := &proxyproto.Listener{Listener: listener, ConnPolicy: utils.GetProxyConnectionPolicy()}
- defer proxyListener.Close()
+ defer func() {
+ err := proxyListener.Close()
+ if err != nil {
+ ps.log.WithError(err).Warning("failed to close proxy listener")
+ }
+ }()
ps.log.WithField("listen", listenAddress).Info("Starting HTTP server")
ps.serve(proxyListener)
@@ -149,7 +154,12 @@ func (ps *ProxyServer) ServeHTTPS() {
return
}
proxyListener := &proxyproto.Listener{Listener: web.TCPKeepAliveListener{TCPListener: ln.(*net.TCPListener)}, ConnPolicy: utils.GetProxyConnectionPolicy()}
- defer proxyListener.Close()
+ defer func() {
+ err := proxyListener.Close()
+ if err != nil {
+ ps.log.WithError(err).Warning("failed to close proxy listener")
+ }
+ }()
tlsListener := tls.NewListener(proxyListener, tlsConfig)
ps.log.WithField("listen", listenAddress).Info("Starting HTTPS server")
diff --git a/internal/outpost/proxyv2/redisstore/redisstore.go b/internal/outpost/proxyv2/redisstore/redisstore.go
index 21c812412a..643e2d11da 100644
--- a/internal/outpost/proxyv2/redisstore/redisstore.go
+++ b/internal/outpost/proxyv2/redisstore/redisstore.go
@@ -72,11 +72,13 @@ func (s *RedisStore) New(r *http.Request, name string) (*sessions.Session, error
session.ID = c.Value
err = s.load(r.Context(), session)
- if err == nil {
- session.IsNew = false
- } else if err == redis.Nil {
- err = nil // no data stored
+ if err != nil {
+ if errors.Is(err, redis.Nil) {
+ return session, nil
+ }
+ return session, err
}
+ session.IsNew = false
return session, err
}
diff --git a/internal/web/web.go b/internal/web/web.go
index 6729b688e8..d25ee688c9 100644
--- a/internal/web/web.go
+++ b/internal/web/web.go
@@ -156,7 +156,12 @@ func (ws *WebServer) listenPlain() {
return
}
proxyListener := &proxyproto.Listener{Listener: ln, ConnPolicy: utils.GetProxyConnectionPolicy()}
- defer proxyListener.Close()
+ defer func() {
+ err := proxyListener.Close()
+ if err != nil {
+ ws.log.WithError(err).Warning("failed to close proxy listener")
+ }
+ }()
ws.log.WithField("listen", config.Get().Listen.HTTP).Info("Starting HTTP server")
ws.serve(proxyListener)
diff --git a/internal/web/web_tls.go b/internal/web/web_tls.go
index 7ccaf4dff9..9e006fbdd8 100644
--- a/internal/web/web_tls.go
+++ b/internal/web/web_tls.go
@@ -46,7 +46,12 @@ func (ws *WebServer) listenTLS() {
return
}
proxyListener := &proxyproto.Listener{Listener: web.TCPKeepAliveListener{TCPListener: ln.(*net.TCPListener)}, ConnPolicy: utils.GetProxyConnectionPolicy()}
- defer proxyListener.Close()
+ defer func() {
+ err := proxyListener.Close()
+ if err != nil {
+ ws.log.WithError(err).Warning("failed to close proxy listener")
+ }
+ }()
tlsListener := tls.NewListener(proxyListener, tlsConfig)
ws.log.WithField("listen", config.Get().Listen.HTTPS).Info("Starting HTTPS server")