1
0
mirror of https://github.com/0rangebananaspy/authelia.git synced 2024-09-14 22:47:21 +07:00
authelia/internal/session/types.go
James Elliott 0a970aef8a
feat(oidc): persistent storage ()
This moves the OpenID Connect storage from memory into the SQL storage, making it persistent and allowing it to be used with clustered deployments like the rest of Authelia.
2022-04-07 15:33:53 +10:00

74 lines
1.8 KiB
Go

package session
import (
"context"
"time"
"github.com/fasthttp/session/v2"
"github.com/fasthttp/session/v2/providers/redis"
"github.com/go-webauthn/webauthn/webauthn"
"github.com/google/uuid"
"github.com/sirupsen/logrus"
"github.com/authelia/authelia/v4/internal/authentication"
"github.com/authelia/authelia/v4/internal/logging"
"github.com/authelia/authelia/v4/internal/oidc"
)
// ProviderConfig is the configuration used to create the session provider.
type ProviderConfig struct {
config session.Config
redisConfig *redis.Config
redisSentinelConfig *redis.FailoverConfig
providerName string
}
// UserSession is the structure representing the session of a user.
type UserSession struct {
Username string
DisplayName string
// TODO(c.michaud): move groups out of the session.
Groups []string
Emails []string
KeepMeLoggedIn bool
AuthenticationLevel authentication.Level
LastActivity int64
FirstFactorAuthnTimestamp int64
SecondFactorAuthnTimestamp int64
AuthenticationMethodRefs oidc.AuthenticationMethodsReferences
// Webauthn holds the session registration data for this session.
Webauthn *webauthn.SessionData
// ConsentChallengeID is the OpenID Connect Consent Session challenge ID.
ConsentChallengeID *uuid.UUID
// This boolean is set to true after identity verification and checked
// while doing the query actually updating the password.
PasswordResetUsername *string
RefreshTTL time.Time
}
// Identity identity of the user who is being verified.
type Identity struct {
Username string
Email string
DisplayName string
}
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...)
}