2019-04-24 21:52:08 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2020-05-04 19:39:25 +00:00
|
|
|
"time"
|
|
|
|
|
2021-03-13 05:06:19 +00:00
|
|
|
"github.com/fasthttp/session/v2"
|
|
|
|
"github.com/fasthttp/session/v2/providers/redis"
|
2019-04-24 21:52:08 +00:00
|
|
|
"github.com/tstranex/u2f"
|
2020-04-05 12:37:21 +00:00
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/authentication"
|
|
|
|
"github.com/authelia/authelia/v4/internal/authorization"
|
2019-04-24 21:52:08 +00: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-09 23:03:05 +00:00
|
|
|
config session.Config
|
|
|
|
redisConfig *redis.Config
|
|
|
|
redisSentinelConfig *redis.FailoverConfig
|
|
|
|
providerName string
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// U2FRegistration is a serializable version of a U2F registration.
|
2019-11-17 01:05:46 +00:00
|
|
|
type U2FRegistration struct {
|
|
|
|
KeyHandle []byte
|
|
|
|
PublicKey []byte
|
|
|
|
}
|
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
// UserSession is the structure representing the session of a user.
|
|
|
|
type UserSession struct {
|
2020-06-19 10:50:21 +00:00
|
|
|
Username string
|
|
|
|
DisplayName string
|
2019-04-24 21:52:08 +00:00
|
|
|
// TODO(c.michaud): move groups out of the session.
|
|
|
|
Groups []string
|
|
|
|
Emails []string
|
|
|
|
|
|
|
|
KeepMeLoggedIn bool
|
|
|
|
AuthenticationLevel authentication.Level
|
|
|
|
LastActivity int64
|
|
|
|
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
FirstFactorAuthnTimestamp int64
|
|
|
|
SecondFactorAuthnTimestamp int64
|
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
// 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 01:05:46 +00:00
|
|
|
U2FRegistration *U2FRegistration
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// Represent an OIDC workflow session initiated by the client if not null.
|
|
|
|
OIDCWorkflowSession *OIDCWorkflowSession
|
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
// This boolean is set to true after identity verification and checked
|
|
|
|
// while doing the query actually updating the password.
|
|
|
|
PasswordResetUsername *string
|
2020-05-04 19:39:25 +00:00
|
|
|
|
|
|
|
RefreshTTL time.Time
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Identity identity of the user who is being verified.
|
|
|
|
type Identity struct {
|
|
|
|
Username string
|
|
|
|
Email string
|
|
|
|
}
|
2021-05-04 22:06:05 +00:00
|
|
|
|
|
|
|
// OIDCWorkflowSession represent an OIDC workflow session.
|
|
|
|
type OIDCWorkflowSession struct {
|
|
|
|
ClientID string
|
|
|
|
RequestedScopes []string
|
|
|
|
GrantedScopes []string
|
|
|
|
RequestedAudience []string
|
|
|
|
GrantedAudience []string
|
|
|
|
TargetURI string
|
|
|
|
AuthURI string
|
|
|
|
RequiredAuthorizationLevel authorization.Level
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
CreatedTimestamp int64
|
2021-05-04 22:06:05 +00:00
|
|
|
}
|