mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-07-18 17:38:07 +08:00
27 lines
736 B
Go
27 lines
736 B
Go
package authn
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
|
"github.com/OpenListTeam/OpenList/v4/internal/setting"
|
|
"github.com/OpenListTeam/OpenList/v4/server/common"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-webauthn/webauthn/webauthn"
|
|
)
|
|
|
|
func NewAuthnInstance(c *gin.Context) (*webauthn.WebAuthn, error) {
|
|
siteUrl, err := url.Parse(common.GetApiUrl(c.Request.Context()))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return webauthn.New(&webauthn.Config{
|
|
RPDisplayName: setting.GetStr(conf.SiteTitle),
|
|
RPID: siteUrl.Hostname(),
|
|
//RPOrigin: siteUrl.String(),
|
|
RPOrigins: []string{fmt.Sprintf("%s://%s", siteUrl.Scheme, siteUrl.Host)},
|
|
// RPOrigin: "http://localhost:5173"
|
|
})
|
|
}
|