-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate to lucia auth (#2242)
- Once redis/ioredis#1822 is fixed, remove patch to ioredis - Once Azure/azure-functions-host#162 is fixed, remove patch to nitro that wraps console log. - Once nitrojs/nitro#1753 is merged and released, remove corresponding patch to nitro - Once lucia-auth/lucia#1153 is fixed, rename models/fields in prisma - Once lucia-auth/lucia#1155 is merged and released, remove custom h3 lucia middleware - Once lucia-auth/lucia#1074 is fixed, remove lucia types shims - Enable CSRF protection in lucia (but then login doesn't work anymore...)
- Loading branch information
1 parent
2b212f5
commit 59f82ed
Showing
28 changed files
with
703 additions
and
784 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 was deleted.
Oops, something went wrong.
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,124 @@ | ||
diff --git a/built/index.js b/built/index.js | ||
index 24a189578794dc3073278788fc443e6c8dc957d5..2152cb839b54377fb4fa423151839bfb5cdaed23 100644 | ||
--- a/built/index.js | ||
+++ b/built/index.js | ||
@@ -2,61 +2,61 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.print = exports.ReplyError = exports.SentinelIterator = exports.SentinelConnector = exports.AbstractConnector = exports.Pipeline = exports.ScanStream = exports.Command = exports.Cluster = exports.Redis = exports.default = void 0; | ||
exports = module.exports = require("./Redis").default; | ||
-var Redis_1 = require("./Redis"); | ||
-Object.defineProperty(exports, "default", { enumerable: true, get: function () { return Redis_1.default; } }); | ||
-var Redis_2 = require("./Redis"); | ||
-Object.defineProperty(exports, "Redis", { enumerable: true, get: function () { return Redis_2.default; } }); | ||
-var cluster_1 = require("./cluster"); | ||
-Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return cluster_1.default; } }); | ||
-/** | ||
- * @ignore | ||
- */ | ||
-var Command_1 = require("./Command"); | ||
-Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return Command_1.default; } }); | ||
-/** | ||
- * @ignore | ||
- */ | ||
-var ScanStream_1 = require("./ScanStream"); | ||
-Object.defineProperty(exports, "ScanStream", { enumerable: true, get: function () { return ScanStream_1.default; } }); | ||
-/** | ||
- * @ignore | ||
- */ | ||
-var Pipeline_1 = require("./Pipeline"); | ||
-Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return Pipeline_1.default; } }); | ||
-/** | ||
- * @ignore | ||
- */ | ||
-var AbstractConnector_1 = require("./connectors/AbstractConnector"); | ||
-Object.defineProperty(exports, "AbstractConnector", { enumerable: true, get: function () { return AbstractConnector_1.default; } }); | ||
-/** | ||
- * @ignore | ||
- */ | ||
-var SentinelConnector_1 = require("./connectors/SentinelConnector"); | ||
-Object.defineProperty(exports, "SentinelConnector", { enumerable: true, get: function () { return SentinelConnector_1.default; } }); | ||
-Object.defineProperty(exports, "SentinelIterator", { enumerable: true, get: function () { return SentinelConnector_1.SentinelIterator; } }); | ||
-// No TS typings | ||
-exports.ReplyError = require("redis-errors").ReplyError; | ||
-/** | ||
- * @ignore | ||
- */ | ||
-Object.defineProperty(exports, "Promise", { | ||
- get() { | ||
- console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."); | ||
- return Promise; | ||
- }, | ||
- set(_lib) { | ||
- console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."); | ||
- }, | ||
-}); | ||
-/** | ||
- * @ignore | ||
- */ | ||
-function print(err, reply) { | ||
- if (err) { | ||
- console.log("Error: " + err); | ||
- } | ||
- else { | ||
- console.log("Reply: " + reply); | ||
- } | ||
-} | ||
-exports.print = print; | ||
+// var Redis_1 = require("./Redis"); | ||
+// Object.defineProperty(exports, "default", { enumerable: true, get: function () { return Redis_1.default; } }); | ||
+// var Redis_2 = require("./Redis"); | ||
+// Object.defineProperty(exports, "Redis", { enumerable: true, get: function () { return Redis_2.default; } }); | ||
+// var cluster_1 = require("./cluster"); | ||
+// Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return cluster_1.default; } }); | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// var Command_1 = require("./Command"); | ||
+// Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return Command_1.default; } }); | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// var ScanStream_1 = require("./ScanStream"); | ||
+// Object.defineProperty(exports, "ScanStream", { enumerable: true, get: function () { return ScanStream_1.default; } }); | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// var Pipeline_1 = require("./Pipeline"); | ||
+// Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return Pipeline_1.default; } }); | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// var AbstractConnector_1 = require("./connectors/AbstractConnector"); | ||
+// Object.defineProperty(exports, "AbstractConnector", { enumerable: true, get: function () { return AbstractConnector_1.default; } }); | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// var SentinelConnector_1 = require("./connectors/SentinelConnector"); | ||
+// Object.defineProperty(exports, "SentinelConnector", { enumerable: true, get: function () { return SentinelConnector_1.default; } }); | ||
+// Object.defineProperty(exports, "SentinelIterator", { enumerable: true, get: function () { return SentinelConnector_1.SentinelIterator; } }); | ||
+// // No TS typings | ||
+// exports.ReplyError = require("redis-errors").ReplyError; | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// Object.defineProperty(exports, "Promise", { | ||
+// get() { | ||
+// console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."); | ||
+// return Promise; | ||
+// }, | ||
+// set(_lib) { | ||
+// console.warn("ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used."); | ||
+// }, | ||
+// }); | ||
+// /** | ||
+// * @ignore | ||
+// */ | ||
+// function print(err, reply) { | ||
+// if (err) { | ||
+// console.log("Error: " + err); | ||
+// } | ||
+// else { | ||
+// console.log("Reply: " + reply); | ||
+// } | ||
+// } | ||
+// exports.print = print; |
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,114 @@ | ||
diff --git a/dist/runtime/entries/azure.mjs b/dist/runtime/entries/azure.mjs | ||
index 2ed72eb8e5f5f6b740d909bb12f62cf761599569..ac3dad70537e585d63c713048c545238a83d0d5f 100644 | ||
--- a/dist/runtime/entries/azure.mjs | ||
+++ b/dist/runtime/entries/azure.mjs | ||
@@ -3,6 +3,8 @@ import { parseURL } from "ufo"; | ||
import { nitroApp } from "../app.mjs"; | ||
import { getAzureParsedCookiesFromHeaders } from "../utils.azure.mjs"; | ||
import { normalizeLambdaOutgoingHeaders } from "../utils.lambda.mjs"; | ||
+import { createConsola } from "consola"; | ||
+ | ||
export async function handle(context, req) { | ||
let url; | ||
if (req.headers["x-ms-original-url"]) { | ||
@@ -11,6 +13,25 @@ export async function handle(context, req) { | ||
} else { | ||
url = "/api/" + (req.params.url || ""); | ||
} | ||
+ const _getLogFn = (level) => { | ||
+ if (level < 1) { | ||
+ return context.log.error; | ||
+ } | ||
+ if (level === 1) { | ||
+ return context.log.warn; | ||
+ } | ||
+ return context.log; | ||
+ } | ||
+ const consola = createConsola({ | ||
+ reporters: [ | ||
+ { | ||
+ log: (logObj) => { | ||
+ _getLogFn(logObj.level)(logObj.args); | ||
+ }, | ||
+ }, | ||
+ ], | ||
+ }); | ||
+ consola.wrapConsole(); | ||
const { body, status, statusText, headers } = await nitroApp.localCall({ | ||
url, | ||
headers: req.headers, | ||
@@ -18,6 +39,7 @@ export async function handle(context, req) { | ||
// https://github.com/Azure/azure-functions-host/issues/293 | ||
body: req.rawBody | ||
}); | ||
+ consola.restoreConsole(); | ||
context.res = { | ||
status, | ||
// cookies https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=typescript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v4#http-response | ||
diff --git a/dist/runtime/utils.azure.mjs b/dist/runtime/utils.azure.mjs | ||
index d0e27bd1b36683f7834ed097c07702429da3c152..0dd0309f7c73ccb709c7bee85360267f7198a4da 100644 | ||
--- a/dist/runtime/utils.azure.mjs | ||
+++ b/dist/runtime/utils.azure.mjs | ||
@@ -1,13 +1,56 @@ | ||
import { parse } from "cookie-es"; | ||
import { splitCookiesString } from "h3"; | ||
-import { joinHeaders } from "./utils.mjs"; | ||
export function getAzureParsedCookiesFromHeaders(headers) { | ||
- const c = String(headers["set-cookie"]); | ||
- if (!c || c.length === 0) { | ||
+ const raw = headers["set-cookie"]; | ||
+ if (!raw || typeof raw === "number" || raw.length === 0) { | ||
return []; | ||
} | ||
- const cookies = splitCookiesString(joinHeaders(c)).map( | ||
- (cookie) => parse(cookie) | ||
- ); | ||
+ const rawCookies = Array.isArray(raw) ? raw : splitCookiesString(String(raw)); | ||
+ const cookies = rawCookies.flatMap((cookie) => { | ||
+ const entries = Object.entries(parse(cookie)); | ||
+ if (entries.length > 0) { | ||
+ const [entry, ...rest] = entries; | ||
+ const options = Object.fromEntries( | ||
+ rest.map(([k, v]) => [k.toLowerCase(), v]) | ||
+ ); | ||
+ const res = { | ||
+ name: entry[0], | ||
+ value: entry[1], | ||
+ domain: options.domain, | ||
+ path: options.path, | ||
+ expires: parseNumberOrDate(options.expires), | ||
+ // secure: options.secure, | ||
+ // httponly: options.httponly, | ||
+ samesite: options.samesite, | ||
+ maxAge: parseNumber(options.maxAge) | ||
+ }; | ||
+ for (const key in res) { | ||
+ if (res[key] === void 0) { | ||
+ delete res[key]; | ||
+ } | ||
+ } | ||
+ return [res]; | ||
+ } | ||
+ return []; | ||
+ }); | ||
return cookies; | ||
} | ||
+function parseNumberOrDate(expires) { | ||
+ const expiresAsNumber = parseNumber(expires); | ||
+ if (expiresAsNumber !== void 0) { | ||
+ return expiresAsNumber; | ||
+ } | ||
+ const expiresAsDate = new Date(expires); | ||
+ if (!Number.isNaN(expiresAsDate.getTime())) { | ||
+ return expiresAsDate; | ||
+ } | ||
+} | ||
+function parseNumber(maxAge) { | ||
+ if (!maxAge) { | ||
+ return void 0; | ||
+ } | ||
+ const maxAgeAsNumber = Number(maxAge); | ||
+ if (!Number.isNaN(maxAgeAsNumber)) { | ||
+ return maxAgeAsNumber; | ||
+ } | ||
+} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.