-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
13e8d36
commit 1aa024e
Showing
11 changed files
with
396 additions
and
2 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
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 |
---|---|---|
@@ -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" | ||
}) | ||
} |
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 |
---|---|---|
|
@@ -29,5 +29,5 @@ func AutoMigrate(dst ...interface{}) error { | |
} | ||
|
||
func GetDb() *gorm.DB { | ||
return db; | ||
return db | ||
} |
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
Oops, something went wrong.