mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 09:13:09 -06:00
Make changes backward compatible - when user provides no flows, default are provided
This commit is contained in:
parent
c5854039d9
commit
7ebb9c625d
|
|
@ -89,18 +89,6 @@ type Dendrite struct {
|
||||||
|
|
||||||
// TODO: Kill Derived
|
// TODO: Kill Derived
|
||||||
type Derived struct {
|
type Derived struct {
|
||||||
Registration struct {
|
|
||||||
// Flows is a slice of flows, which represent one possible way that the client can authenticate a request.
|
|
||||||
// http://matrix.org/docs/spec/HEAD/client_server/r0.3.0.html#user-interactive-authentication-api
|
|
||||||
// As long as the generated flows only rely on config file options,
|
|
||||||
// we can generate them on startup and store them until needed
|
|
||||||
Flows []authtypes.Flow `json:"flows"`
|
|
||||||
|
|
||||||
// Params that need to be returned to the client during
|
|
||||||
// registration in order to complete registration stages.
|
|
||||||
Params map[string]interface{} `json:"params"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used for request to identity server
|
// Used for request to identity server
|
||||||
HttpClient *http.Client
|
HttpClient *http.Client
|
||||||
|
|
||||||
|
|
@ -277,18 +265,29 @@ func loadConfig(
|
||||||
func (config *Dendrite) Derive() error {
|
func (config *Dendrite) Derive() error {
|
||||||
// Determine registrations flows based off config values
|
// Determine registrations flows based off config values
|
||||||
|
|
||||||
config.Derived.Registration.Params = make(map[string]interface{})
|
config.ClientAPI.Registration.Params = make(map[string]interface{})
|
||||||
|
|
||||||
// TODO: Add email auth type
|
|
||||||
// TODO: Add MSISDN auth type
|
// TODO: Add MSISDN auth type
|
||||||
|
|
||||||
if config.ClientAPI.RecaptchaEnabled {
|
// Setup default m.login.dummy flow for registration if no flows are provided.
|
||||||
config.Derived.Registration.Params[authtypes.LoginTypeRecaptcha] = map[string]string{"public_key": config.ClientAPI.RecaptchaPublicKey}
|
if len(config.ClientAPI.Registration.Flows) == 0 {
|
||||||
config.Derived.Registration.Flows = append(config.Derived.Registration.Flows,
|
// Handle recaptcha configuration.
|
||||||
authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeRecaptcha}})
|
if config.ClientAPI.RecaptchaEnabled {
|
||||||
} else {
|
config.ClientAPI.Registration.Params[authtypes.LoginTypeRecaptcha] = map[string]string{"public_key": config.ClientAPI.RecaptchaPublicKey}
|
||||||
config.Derived.Registration.Flows = append(config.Derived.Registration.Flows,
|
config.ClientAPI.Registration.Flows = append(config.ClientAPI.Registration.Flows,
|
||||||
authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeDummy}})
|
authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeRecaptcha}})
|
||||||
|
} else {
|
||||||
|
config.ClientAPI.Registration.Flows = append(config.ClientAPI.Registration.Flows,
|
||||||
|
authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeDummy}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Setup default m.login.password flow for login if no flows are provided.
|
||||||
|
if len(config.ClientAPI.Login.Flows) == 0 {
|
||||||
|
config.ClientAPI.Login.Flows = []authtypes.Flow{
|
||||||
|
{Stages: []authtypes.LoginType{
|
||||||
|
authtypes.LoginTypePassword,
|
||||||
|
}},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load application service configuration files
|
// Load application service configuration files
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue