Access tokens, server, moving things
- Added placeholder funcs for access tokens - Moved an error definition and added another constant - Changed (passkey) auth fail to return a json error for now - TODO: Change that into checking for a provided access token before failing
This commit is contained in:
parent
4f761c20c0
commit
391d8b1b48
5 changed files with 56 additions and 6 deletions
|
@ -13,4 +13,5 @@ const (
|
|||
HttpErrIdPlaceholder = iota
|
||||
HttpErrIdMissingContextValue
|
||||
HttpErrIdDbFailure
|
||||
HttpErrIdNotAuthenticated
|
||||
)
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/mstarongithub/passkey"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/goutils/other"
|
||||
"gitlab.com/mstarongitlab/linstrom/storage"
|
||||
)
|
||||
|
||||
|
@ -38,7 +38,14 @@ func buildRootHandler(pkey *passkey.Passkey, reactiveFS, staticFS fs.FS) http.Ha
|
|||
pkey.Auth(
|
||||
ContextKeyPasskeyUsername,
|
||||
nil,
|
||||
passkey.RedirectUnauthorized(url.URL{Path: "/"}),
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
other.HttpErr(
|
||||
w,
|
||||
HttpErrIdNotAuthenticated,
|
||||
"Not authenticated",
|
||||
http.StatusUnauthorized,
|
||||
)
|
||||
},
|
||||
)(ChainMiddlewares(setupTestEndpoints(), passkeyIdToAccountIdTransformerMiddleware)),
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue