@opengis/fastify-table 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -2
- package/dist/server/plugins/auth/index.js +16 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,8 +81,8 @@ async function plugin(fastify, opt) {
|
|
|
81
81
|
config.templates?.forEach((el) => addTemplateDir(el));
|
|
82
82
|
addTemplateDir(path.join(cwd, "module/core"));
|
|
83
83
|
// plugins / utils / funcs
|
|
84
|
-
await authPlugin(fastify, config); // fastify-auth api + hooks integrated to core
|
|
85
84
|
policyPlugin(fastify);
|
|
85
|
+
await authPlugin(fastify, config); // fastify-auth api + hooks integrated to core
|
|
86
86
|
metricPlugin();
|
|
87
87
|
redisPlugin(fastify);
|
|
88
88
|
await pgPlugin(fastify, opt);
|
|
@@ -113,7 +113,6 @@ async function plugin(fastify, opt) {
|
|
|
113
113
|
menuRoutes(fastify, opt);
|
|
114
114
|
templatesRoutes(fastify, opt);
|
|
115
115
|
authRoutes(fastify, opt); // from fastify-auth
|
|
116
|
-
// fastify.register(import("./server/routes/auth/index.js"));
|
|
117
116
|
// from fastify-file
|
|
118
117
|
await fastify.register(import("@fastify/multipart"), {
|
|
119
118
|
limits: {
|
|
@@ -12,6 +12,22 @@ async function plugin(fastify, opt = config) {
|
|
|
12
12
|
if (!opt.redis) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
+
await fastify.register(cookie, {
|
|
16
|
+
parseOptions: opt?.auth?.cookieOptions || { secure: false },
|
|
17
|
+
});
|
|
18
|
+
await fastify.register(session, {
|
|
19
|
+
secret: opt?.auth?.secret || "61b820e12858570a4b0633020d4394a17903d9a9",
|
|
20
|
+
cookieName: "session_auth",
|
|
21
|
+
cookie: opt?.auth?.cookieOptions || { secure: false },
|
|
22
|
+
store: new RedisStore({ client: getRedis({ db: 10 }) }),
|
|
23
|
+
});
|
|
24
|
+
// register passport AFTER session is ready
|
|
25
|
+
await fastify.register(fastifyPassport.initialize());
|
|
26
|
+
await fastify.register(fastifyPassport.secureSession());
|
|
27
|
+
// serialize user used to store user info in session store
|
|
28
|
+
fastifyPassport.registerUserSerializer(async (user) => ({ user }));
|
|
29
|
+
// deserialize user used to add user info from session store to req
|
|
30
|
+
fastifyPassport.registerUserDeserializer(async (passport) => passport?.user || passport);
|
|
15
31
|
fastify.addHook("onRequest", async (req, reply) => {
|
|
16
32
|
const { pg, hostname, headers, routeOptions } = req;
|
|
17
33
|
const { policy = [] } = routeOptions?.config || {};
|
|
@@ -90,21 +106,5 @@ async function plugin(fastify, opt = config) {
|
|
|
90
106
|
}
|
|
91
107
|
return null;
|
|
92
108
|
});
|
|
93
|
-
await fastify.register(cookie, {
|
|
94
|
-
parseOptions: opt?.auth?.cookieOptions || { secure: false },
|
|
95
|
-
});
|
|
96
|
-
await fastify.register(session, {
|
|
97
|
-
secret: opt?.auth?.secret || "61b820e12858570a4b0633020d4394a17903d9a9",
|
|
98
|
-
cookieName: "session_auth",
|
|
99
|
-
cookie: opt?.auth?.cookieOptions || { secure: false },
|
|
100
|
-
store: new RedisStore({ client: getRedis({ db: 10 }) }),
|
|
101
|
-
});
|
|
102
|
-
// register passport AFTER session is ready
|
|
103
|
-
await fastify.register(fastifyPassport.initialize());
|
|
104
|
-
await fastify.register(fastifyPassport.secureSession());
|
|
105
|
-
// serialize user used to store user info in session store
|
|
106
|
-
fastifyPassport.registerUserSerializer(async (user) => ({ user }));
|
|
107
|
-
// deserialize user used to add user info from session store to req
|
|
108
|
-
fastifyPassport.registerUserDeserializer(async (passport) => passport?.user || passport);
|
|
109
109
|
}
|
|
110
110
|
export default plugin;
|