all repos — litestore @ ec288b393b7c899272d39b35f8f7b1203e76a95c

A minimalist nosql document store.

Ensured that JWT is accessible in middleware.
h3rald h3rald@h3rald.com
Fri, 05 Jan 2024 14:12:58 +0100
commit

ec288b393b7c899272d39b35f8f7b1203e76a95c

parent

6363a58f31488ccfbcff2433bc426d1977b5ab3f

1 files changed, 5 insertions(+), 5 deletions(-)

jump to
M src/litestorepkg/lib/server.nimsrc/litestorepkg/lib/server.nim

@@ -39,7 +39,7 @@ echo ""

LOG.info("Exiting...") quit() -template auth(uri: string, LS: LiteStore): void = +template auth(uri: string, LS: LiteStore, jwt: JWT): void = let cfg = access[uri] if cfg.hasKey(reqMethod): LOG.debug("Authenticating: " & reqMethod & " " & uri)

@@ -48,7 +48,7 @@ return resError(Http401, "Unauthorized - No token")

let token = req.headers["Authorization"].replace(peg"^ 'Bearer '", "") # Validate token try: - let jwt = token.newJwt + jwt = token.newJwt var x5c: string if LS.config.hasKey("jwks_uri"): LOG.debug("Selecting x5c...")

@@ -123,12 +123,12 @@ let access = LS.auth["access"]

while true: # Match exact url if access.hasKey(uri): - auth(uri, LS) + auth(uri, LS, jwt) break # Match exact url adding /* (e.g. /docs would match also /docs/* in auth.json) elif uri[^1] != '*' and uri[^1] != '/': if access.hasKey(uri & "/*"): - auth(uri & "/*", LS) + auth(uri & "/*", LS, jwt) break var parts = uri.split("/") if parts[^1] == "*":

@@ -141,7 +141,7 @@ else:

# If at the end of the URL, check generic URL uri = "/*" if access.hasKey(uri): - auth(uri, LS) + auth(uri, LS, jwt) break if info.version == "v8": if info.resource.match(peg"^assets / docs / info / tags / indexes / stores$"):