feat: support webauthn login (#4945)

* feat: support webauthn login

* manually merge

* fix: clear user cache after updating authn

* decrease db size of Authn

* change authn type to text

* simplify code structure

---------

Co-authored-by: Andy Hsu <i@nn.ci>
This commit is contained in:
itsHenry
2023-08-14 22:54:38 +08:00
committed by GitHub
parent 13e8d36e1a
commit 1aa024ed6b
11 changed files with 396 additions and 2 deletions

25
internal/authn/authn.go Normal file
View File

@ -0,0 +1,25 @@
package authn
import (
"net/http"
"net/url"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/setting"
"github.com/alist-org/alist/v3/server/common"
"github.com/go-webauthn/webauthn/webauthn"
)
func NewAuthnInstance(r *http.Request) (*webauthn.WebAuthn, error) {
siteUrl, err := url.Parse(common.GetApiUrl(r))
if err != nil {
return nil, err
}
return webauthn.New(&webauthn.Config{
RPDisplayName: setting.GetStr(conf.SiteTitle),
RPID: siteUrl.Hostname(),
//RPOrigin: siteUrl.String(),
RPOrigins: []string{siteUrl.String()},
// RPOrigin: "http://localhost:5173"
})
}