mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
fix(session): handle redis logging properly (#2350)
This catches redis logs and displays them via our logging utility.
This commit is contained in:
parent
f1b2b4d79e
commit
2f03b02fc9
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
||||||
|
"github.com/authelia/authelia/v4/internal/logging"
|
||||||
"github.com/authelia/authelia/v4/internal/utils"
|
"github.com/authelia/authelia/v4/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,6 +81,7 @@ func NewProviderConfig(configuration schema.SessionConfiguration, certPool *x509
|
||||||
|
|
||||||
providerName = "redis-sentinel"
|
providerName = "redis-sentinel"
|
||||||
redisSentinelConfig = &redis.FailoverConfig{
|
redisSentinelConfig = &redis.FailoverConfig{
|
||||||
|
Logger: &redisLogger{logger: logging.Logger()},
|
||||||
MasterName: configuration.Redis.HighAvailability.SentinelName,
|
MasterName: configuration.Redis.HighAvailability.SentinelName,
|
||||||
SentinelAddrs: addrs,
|
SentinelAddrs: addrs,
|
||||||
SentinelPassword: configuration.Redis.HighAvailability.SentinelPassword,
|
SentinelPassword: configuration.Redis.HighAvailability.SentinelPassword,
|
||||||
|
@ -108,6 +110,7 @@ func NewProviderConfig(configuration schema.SessionConfiguration, certPool *x509
|
||||||
}
|
}
|
||||||
|
|
||||||
redisConfig = &redis.Config{
|
redisConfig = &redis.Config{
|
||||||
|
Logger: newRedisLogger(),
|
||||||
Network: network,
|
Network: network,
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Username: configuration.Redis.Username,
|
Username: configuration.Redis.Username,
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fasthttp/session/v2"
|
"github.com/fasthttp/session/v2"
|
||||||
"github.com/fasthttp/session/v2/providers/redis"
|
"github.com/fasthttp/session/v2/providers/redis"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/tstranex/u2f"
|
"github.com/tstranex/u2f"
|
||||||
|
|
||||||
"github.com/authelia/authelia/v4/internal/authentication"
|
"github.com/authelia/authelia/v4/internal/authentication"
|
||||||
"github.com/authelia/authelia/v4/internal/authorization"
|
"github.com/authelia/authelia/v4/internal/authorization"
|
||||||
|
"github.com/authelia/authelia/v4/internal/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProviderConfig is the configuration used to create the session provider.
|
// ProviderConfig is the configuration used to create the session provider.
|
||||||
|
@ -75,3 +78,15 @@ type OIDCWorkflowSession struct {
|
||||||
RequiredAuthorizationLevel authorization.Level
|
RequiredAuthorizationLevel authorization.Level
|
||||||
CreatedTimestamp int64
|
CreatedTimestamp int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newRedisLogger() *redisLogger {
|
||||||
|
return &redisLogger{logger: logging.Logger()}
|
||||||
|
}
|
||||||
|
|
||||||
|
type redisLogger struct {
|
||||||
|
logger *logrus.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *redisLogger) Printf(_ context.Context, format string, v ...interface{}) {
|
||||||
|
l.logger.Tracef(format, v...)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user