-
Notifications
You must be signed in to change notification settings - Fork 941
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'hanko/feat/692-webhooks' into feat/692-…
…webhooks
- Loading branch information
Showing
16 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"github.com/knadh/koanf/providers/file" | ||
"github.com/teamhanko/hanko/backend/ee/saml/config" | ||
"golang.org/x/exp/slices" | ||
zeroLogger "github.com/rs/zerolog/log" | ||
"log" | ||
"strings" | ||
"time" | ||
|
@@ -20,6 +21,7 @@ import ( | |
type Config struct { | ||
Server Server `yaml:"server" json:"server,omitempty" koanf:"server"` | ||
Webauthn WebauthnSettings `yaml:"webauthn" json:"webauthn,omitempty" koanf:"webauthn"` | ||
Smtp SMTP `yaml:"smtp" json:"smtp,omitempty" koanf:"smtp"` | ||
Passcode Passcode `yaml:"passcode" json:"passcode" koanf:"passcode"` | ||
Password Password `yaml:"password" json:"password,omitempty" koanf:"password"` | ||
Database Database `yaml:"database" json:"database" koanf:"database"` | ||
|
@@ -71,6 +73,8 @@ func Load(cfgFile *string) (*Config, error) { | |
return nil, fmt.Errorf("failed to post process config: %w", err) | ||
} | ||
|
||
c.arrangeSmtpSettings() | ||
|
||
if err = c.Validate(); err != nil { | ||
return nil, fmt.Errorf("failed to validate config: %s", err) | ||
} | ||
|
@@ -97,15 +101,18 @@ func DefaultConfig() *Config { | |
UserVerification: "preferred", | ||
Timeout: 60000, | ||
}, | ||
Smtp: SMTP{ | ||
Port: "465", | ||
}, | ||
Passcode: Passcode{ | ||
Smtp: SMTP{ | ||
Port: "465", | ||
}, | ||
TTL: 300, | ||
Email: Email{ | ||
FromAddress: "[email protected]", | ||
FromName: "Hanko", | ||
}, | ||
Smtp: SMTP{ | ||
Port: "465", | ||
}, | ||
}, | ||
Password: Password{ | ||
MinPasswordLength: 8, | ||
|
@@ -163,6 +170,10 @@ func (c *Config) Validate() error { | |
if err != nil { | ||
return fmt.Errorf("failed to validate webauthn settings: %w", err) | ||
} | ||
err = c.Smtp.Validate() | ||
if err != nil { | ||
return fmt.Errorf("failed to validate smtp settings: %w", err) | ||
} | ||
err = c.Passcode.Validate() | ||
if err != nil { | ||
return fmt.Errorf("failed to validate passcode settings: %w", err) | ||
|
@@ -352,19 +363,16 @@ func (e *Email) Validate() error { | |
|
||
type Passcode struct { | ||
Email Email `yaml:"email" json:"email,omitempty" koanf:"email"` | ||
Smtp SMTP `yaml:"smtp" json:"smtp" koanf:"smtp"` | ||
TTL int `yaml:"ttl" json:"ttl,omitempty" koanf:"ttl" jsonschema:"default=300"` | ||
//Deprecated: Use root level Smtp instead | ||
Smtp SMTP `yaml:"smtp" json:"smtp,omitempty" koanf:"smtp,omitempty" required:"false" envconfig:"smtp,omitempty"` | ||
} | ||
|
||
func (p *Passcode) Validate() error { | ||
err := p.Email.Validate() | ||
if err != nil { | ||
return fmt.Errorf("failed to validate email settings: %w", err) | ||
} | ||
err = p.Smtp.Validate() | ||
if err != nil { | ||
return fmt.Errorf("failed to validate smtp settings: %w", err) | ||
} | ||
return nil | ||
} | ||
|
||
|
@@ -643,6 +651,17 @@ func (c *Config) PostProcess() error { | |
|
||
} | ||
|
||
func (c *Config) arrangeSmtpSettings() { | ||
if c.Passcode.Smtp.Validate() == nil { | ||
if c.Smtp.Validate() == nil { | ||
zeroLogger.Warn().Msg("Both root smtp and passcode.smtp are set. Using smtp settings from root configuration") | ||
return | ||
} | ||
|
||
c.Smtp = c.Passcode.Smtp | ||
} | ||
} | ||
|
||
type LoggerConfig struct { | ||
LogHealthAndMetrics bool `yaml:"log_health_and_metrics,omitempty" json:"log_health_and_metrics" koanf:"log_health_and_metrics" jsonschema:"default=true"` | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ database: | |
host: localhost | ||
port: 5432 | ||
dialect: postgres | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
smtp: | ||
host: smtp.example.com | ||
user: example | ||
password: example | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
passcode: | ||
smtp: | ||
smtp: | ||
host: smtp.example.com | ||
user: example | ||
password: example | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
database: | ||
user: hanko | ||
password: hanko | ||
host: localhost | ||
port: 5432 | ||
dialect: postgres | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
host: smtp.example.com | ||
user: example | ||
password: example | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
service: | ||
name: Hanko Authentication Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
database: | ||
user: hanko | ||
password: hanko | ||
host: localhost | ||
port: 5432 | ||
dialect: postgres | ||
smtp: | ||
host: smtp1.example.com | ||
user: example1 | ||
password: example1 | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
host: smtp2.example.com | ||
user: example2 | ||
password: example2 | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
service: | ||
name: Hanko Authentication Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,11 @@ var DefaultConfig = config.Config{ | |
Secrets: config.Secrets{ | ||
Keys: []string{"abcdefghijklmnop"}, | ||
}, | ||
Smtp: config.SMTP{ | ||
Host: "localhost", | ||
Port: "2500", | ||
}, | ||
Passcode: config.Passcode{ | ||
Smtp: config.SMTP{ | ||
Host: "localhost", | ||
Port: "2500", | ||
}, | ||
Email: config.Email{ | ||
FromAddress: "[email protected]", | ||
FromName: "Hanko Test", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ database: | |
host: postgresd | ||
port: 5432 | ||
dialect: postgres | ||
smtp: | ||
host: "mailslurper" | ||
port: "2500" | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
host: "mailslurper" | ||
port: "2500" | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ database: | |
host: postgresd | ||
port: 5432 | ||
dialect: postgres | ||
smtp: | ||
host: "mailslurper" | ||
port: "2500" | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
host: "mailslurper" | ||
port: "2500" | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ database: | |
host: postgresd | ||
port: 5432 | ||
dialect: postgres | ||
smtp: | ||
host: "mailslurper" | ||
port: "2500" | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
host: "mailslurper" | ||
port: "2500" | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ database: | |
host: postgres | ||
port: 5432 | ||
dialect: postgres | ||
smtp: | ||
host: "mailhog" | ||
port: "2500" | ||
passcode: | ||
email: | ||
from_address: [email protected] | ||
smtp: | ||
host: "mailhog" | ||
port: "2500" | ||
secrets: | ||
keys: | ||
- abcedfghijklmnopqrstuvwxyz | ||
|
@@ -40,4 +40,4 @@ third_party: | |
github: | ||
enabled: true | ||
apple: | ||
enabled: true | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v16.15.1 | ||
v18.6.0 |