2019-04-25 04:52:08 +07:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2020-05-05 02:39:25 +07:00
|
|
|
"time"
|
|
|
|
|
2020-05-18 09:45:47 +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 {
|
2020-05-18 09:45:47 +07:00
|
|
|
config session.Config
|
|
|
|
redisConfig *redis.Config
|
|
|
|
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
|
|
|
|
}
|