2019-04-25 04:52:08 +07:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2020-05-05 02:39:25 +07:00
|
|
|
"time"
|
|
|
|
|
2021-03-13 12:06:19 +07:00
|
|
|
"github.com/fasthttp/session/v2"
|
|
|
|
"github.com/fasthttp/session/v2/providers/redis"
|
2019-04-25 04:52:08 +07:00
|
|
|
"github.com/tstranex/u2f"
|
2020-04-05 19:37:21 +07:00
|
|
|
|
|
|
|
"github.com/authelia/authelia/internal/authentication"
|
2019-04-25 04:52:08 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
// ProviderConfig is the configuration used to create the session provider.
|
|
|
|
type ProviderConfig struct {
|
feat(session): add redis sentinel provider (#1768)
* feat(session): add redis sentinel provider
* refactor(session): use int for ports as per go standards
* refactor(configuration): adjust tests and validation
* refactor(configuration): add err format consts
* refactor(configuration): explicitly map redis structs
* refactor(session): merge redis/redis sentinel providers
* refactor(session): add additional checks to redis providers
* feat(session): add redis cluster provider
* fix: update config for new values
* fix: provide nil certpool to affected tests/mocks
* test: add additional tests to cover uncovered code
* docs: expand explanation of host and nodes relation for redis
* ci: add redis-sentinel to suite highavailability, add redis-sentinel quorum
* fix(session): sentinel password
* test: use redis alpine library image for redis sentinel, use expose instead of ports, use redis ip, adjust redis ip range, adjust redis config
* test: make entrypoint.sh executable, fix entrypoint.sh if/elif
* test: add redis failover tests
* test: defer docker start, adjust sleep, attempt logout before login, attempt visit before login and tune timeouts, add additional logging
* test: add sentinel integration test
* test: add secondary node failure to tests, fix password usage, bump test timeout, add sleep
* feat: use sentinel failover cluster
* fix: renamed addrs to sentineladdrs upstream
* test(session): sentinel failover
* test: add redis standard back into testing
* test: move redis standalone test to traefik2
* fix/docs: apply suggestions from code review
2021-03-10 06:03:05 +07:00
|
|
|
config session.Config
|
|
|
|
redisConfig *redis.Config
|
|
|
|
redisSentinelConfig *redis.FailoverConfig
|
|
|
|
providerName string
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|
|
|
|
|
2020-05-02 12:06:39 +07:00
|
|
|
// U2FRegistration is a serializable version of a U2F registration.
|
2019-11-17 08:05:46 +07:00
|
|
|
type U2FRegistration struct {
|
|
|
|
KeyHandle []byte
|
|
|
|
PublicKey []byte
|
|
|
|
}
|
|
|
|
|
2019-04-25 04:52:08 +07:00
|
|
|
// UserSession is the structure representing the session of a user.
|
|
|
|
type UserSession struct {
|
2020-06-19 17:50:21 +07:00
|
|
|
Username string
|
|
|
|
DisplayName string
|
2019-04-25 04:52:08 +07:00
|
|
|
// TODO(c.michaud): move groups out of the session.
|
|
|
|
Groups []string
|
|
|
|
Emails []string
|
|
|
|
|
|
|
|
KeepMeLoggedIn bool
|
|
|
|
AuthenticationLevel authentication.Level
|
|
|
|
LastActivity int64
|
|
|
|
|
|
|
|
// The challenge generated in first step of U2F registration (after identity verification) or authentication.
|
|
|
|
// This is used reused in the second phase to check that the challenge has been completed.
|
|
|
|
U2FChallenge *u2f.Challenge
|
|
|
|
// The registration representing a U2F device in DB set after identity verification.
|
|
|
|
// This is used in second phase of a U2F authentication.
|
2019-11-17 08:05:46 +07:00
|
|
|
U2FRegistration *U2FRegistration
|
2019-04-25 04:52:08 +07:00
|
|
|
|
|
|
|
// This boolean is set to true after identity verification and checked
|
|
|
|
// while doing the query actually updating the password.
|
|
|
|
PasswordResetUsername *string
|
2020-05-05 02:39:25 +07:00
|
|
|
|
|
|
|
RefreshTTL time.Time
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Identity identity of the user who is being verified.
|
|
|
|
type Identity struct {
|
|
|
|
Username string
|
|
|
|
Email string
|
|
|
|
}
|