feat: login via passkey

This commit is contained in:
Jacky 2024-09-15 20:32:03 +08:00
parent 44c3180df7
commit bdfbbd0e8f
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
37 changed files with 1529 additions and 643 deletions

View file

@ -29,6 +29,7 @@ var sections = map[string]interface{}{
"cluster": &ClusterSettings,
"auth": &AuthSettings,
"crypto": &CryptoSettings,
"webauthn": &WebAuthnSettings,
}
func init() {
@ -66,6 +67,7 @@ func Setup() {
parseEnv(&LogrotateSettings, "LOGROTATE_")
parseEnv(&AuthSettings, "AUTH_")
parseEnv(&CryptoSettings, "CRYPTO_")
parseEnv(&WebAuthnSettings, "WEBAUTHN_")
// if in official docker, set the restart cmd of nginx to "nginx -s stop",
// then the supervisor of s6-overlay will start the nginx again.

View file

@ -53,6 +53,10 @@ func TestSetup(t *testing.T) {
_ = os.Setenv("NGINX_UI_LOGROTATE_CMD", "logrotate /custom/logrotate.conf")
_ = os.Setenv("NGINX_UI_LOGROTATE_INTERVAL", "60")
_ = os.Setenv("NGINX_UI_WEBAUTHN_RP_DISPLAY_NAME", "WebAuthn")
_ = os.Setenv("NGINX_UI_WEBAUTHN_RPID", "localhost")
_ = os.Setenv("NGINX_UI_WEBAUTHN_RP_ORIGINS", "http://localhost:3002")
ConfPath = "app.testing.ini"
Setup()
@ -98,6 +102,10 @@ func TestSetup(t *testing.T) {
assert.Equal(t, "logrotate /custom/logrotate.conf", LogrotateSettings.CMD)
assert.Equal(t, 60, LogrotateSettings.Interval)
assert.Equal(t, "WebAuthn", WebAuthnSettings.RPDisplayName)
assert.Equal(t, "localhost", WebAuthnSettings.RPID)
assert.Equal(t, []string{"http://localhost:3002"}, WebAuthnSettings.RPOrigins)
os.Clearenv()
_ = os.Remove("app.testing.ini")
}

9
settings/webauthn.go Normal file
View file

@ -0,0 +1,9 @@
package settings
type WebAuthn struct {
RPDisplayName string
RPID string
RPOrigins []string
}
var WebAuthnSettings = WebAuthn{}