feat: add mfa session to secure otp login
This commit is contained in:
@@ -7,18 +7,20 @@ import (
|
||||
)
|
||||
|
||||
type provider struct {
|
||||
mutex sync.Mutex
|
||||
sessionStore *stores.SessionStore
|
||||
stateStore *stores.StateStore
|
||||
envStore *stores.EnvStore
|
||||
mutex sync.Mutex
|
||||
sessionStore *stores.SessionStore
|
||||
mfasessionStore *stores.SessionStore
|
||||
stateStore *stores.StateStore
|
||||
envStore *stores.EnvStore
|
||||
}
|
||||
|
||||
// NewInMemoryStore returns a new in-memory store.
|
||||
func NewInMemoryProvider() (*provider, error) {
|
||||
return &provider{
|
||||
mutex: sync.Mutex{},
|
||||
envStore: stores.NewEnvStore(),
|
||||
sessionStore: stores.NewSessionStore(),
|
||||
stateStore: stores.NewStateStore(),
|
||||
mutex: sync.Mutex{},
|
||||
envStore: stores.NewEnvStore(),
|
||||
sessionStore: stores.NewSessionStore(),
|
||||
mfasessionStore: stores.NewSessionStore(),
|
||||
stateStore: stores.NewStateStore(),
|
||||
}, nil
|
||||
}
|
||||
|
@@ -42,6 +42,24 @@ func (c *provider) DeleteSessionForNamespace(namespace string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *provider) SetMfaSession(email, key string, expiration int64) error {
|
||||
c.mfasessionStore.Set(email, key, email, expiration)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *provider) GetMfaSession(email, key string) (string, error) {
|
||||
val := c.mfasessionStore.Get(email, key)
|
||||
if val == "" {
|
||||
return "", fmt.Errorf("Not found")
|
||||
}
|
||||
return val, nil
|
||||
}
|
||||
|
||||
func (c *provider) DeleteMfaSession(email, key string) error {
|
||||
c.mfasessionStore.Remove(email, key)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetState sets the state in the in-memory store.
|
||||
func (c *provider) SetState(key, state string) error {
|
||||
if os.Getenv("ENV") != constants.TestEnv {
|
||||
|
Reference in New Issue
Block a user