Copy passkey auth fix from Mk plugin repo
This commit is contained in:
parent
90667d96c7
commit
1dbdec1905
4 changed files with 250 additions and 1 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/mstarongithub/passkey"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/goutils/other"
|
||||
|
||||
"gitlab.com/mstarongitlab/linstrom/config"
|
||||
"gitlab.com/mstarongitlab/linstrom/storage"
|
||||
)
|
||||
|
@ -29,7 +30,13 @@ func NewServer(store *storage.Storage, pkey *passkey.Passkey, reactiveFS, static
|
|||
|
||||
func buildRootHandler(pkey *passkey.Passkey, reactiveFS, staticFS fs.FS) http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
pkey.MountRoutes(mux, "/webauthn/")
|
||||
mux.Handle(
|
||||
"/webauthn/",
|
||||
http.StripPrefix(
|
||||
"/webauthn",
|
||||
forceCorrectPasskeyAuthFlowMiddleware(buildPasskeyAuthRouter(pkey)),
|
||||
),
|
||||
)
|
||||
mux.Handle("/", setupFrontendRouter(reactiveFS, staticFS))
|
||||
mux.Handle("/pk/", http.StripPrefix("/pk", http.FileServer(http.Dir("pk-auth"))))
|
||||
mux.HandleFunc("/alive", isAliveHandler)
|
||||
|
@ -63,6 +70,12 @@ func buildRootHandler(pkey *passkey.Passkey, reactiveFS, staticFS fs.FS) http.Ha
|
|||
return mux
|
||||
}
|
||||
|
||||
func buildPasskeyAuthRouter(pkey *passkey.Passkey) http.Handler {
|
||||
router := http.NewServeMux()
|
||||
pkey.MountRoutes(router, "/")
|
||||
return router
|
||||
}
|
||||
|
||||
func (s *Server) Start(addr string) error {
|
||||
log.Info().Str("addr", addr).Msg("Starting server")
|
||||
return http.ListenAndServe(addr, s.router)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue