Adjustment to the environment reading, so that *all* settings can be
overridden, not just the OIDC values.
Showing
4 changed files
with
11 additions
and
5 deletions
1 | import 'dotenv/config' | 1 | import 'dotenv/config' |
2 | import oidcMiddleware, { fileStoreOptions } from './oidc-middleware.mjs' | 2 | import oidcMiddleware, { fileStoreOptions } from './oidc-middleware.mjs' |
3 | import { oidcParams } from './options.mjs' | 3 | import { allParams } from './options.mjs' |
4 | 4 | ||
5 | const clientLocalsSymbol = Symbol.for("astro.locals") | 5 | const clientLocalsSymbol = Symbol.for("astro.locals") |
6 | 6 | ||
... | @@ -9,7 +9,7 @@ export default (options) => { | ... | @@ -9,7 +9,7 @@ export default (options) => { |
9 | name: 'session', | 9 | name: 'session', |
10 | hooks: { | 10 | hooks: { |
11 | 'astro:server:setup': async ({ server }) => { | 11 | 'astro:server:setup': async ({ server }) => { |
12 | server.middlewares.use(await oidcMiddleware({ oidc: oidcParams() }, fileStoreOptions)) | 12 | server.middlewares.use(await oidcMiddleware(fileStoreOptions, allParams())) |
13 | server.middlewares.use((req, res, next) => { | 13 | server.middlewares.use((req, res, next) => { |
14 | req[ clientLocalsSymbol ] = res.locals | 14 | req[ clientLocalsSymbol ] = res.locals |
15 | next() | 15 | next() | ... | ... |
1 | export { default as FixRacyStore } from './fix-racy-store.mjs' | 1 | export { default as FixRacyStore } from './fix-racy-store.mjs' |
2 | export { default as oidcMiddleware, fileStoreOptions } from './oidc-middleware.mjs' | 2 | export { default as oidcMiddleware, fileStoreOptions } from './oidc-middleware.mjs' |
3 | export { readEnvOptions, oidcParams } from './options.mjs' | 3 | export { readEnvOptions, oidcParams, authParams, sessionParams, allParams } from './options.mjs' |
4 | export { default as AstroIntegration } from './astro-integration.mjs' | 4 | export { default as AstroIntegration } from './astro-integration.mjs' | ... | ... |
... | @@ -62,7 +62,7 @@ const parseRawToken = (rawToken, def) => { | ... | @@ -62,7 +62,7 @@ const parseRawToken = (rawToken, def) => { |
62 | 62 | ||
63 | export default async (...options) => { | 63 | export default async (...options) => { |
64 | options = merge({}, defaultOptions, ...options) | 64 | options = merge({}, defaultOptions, ...options) |
65 | console.log('options', options.oidc) | 65 | console.log('options', options) |
66 | const app = express.Router() | 66 | const app = express.Router() |
67 | 67 | ||
68 | const sessionStore = await options.session.store(options) | 68 | const sessionStore = await options.session.store(options) | ... | ... |
... | @@ -20,4 +20,10 @@ export const oidcParams = () => _.pickBy(_.merge({ | ... | @@ -20,4 +20,10 @@ export const oidcParams = () => _.pickBy(_.merge({ |
20 | return !_.startsWith(key, 'http') | 20 | return !_.startsWith(key, 'http') |
21 | }) | 21 | }) |
22 | 22 | ||
23 | 23 | export const authParams = () => readEnv('AUTH', readEnvOptions) | |
24 | export const sessionParams = () => readEnv('SESSION', readEnvOptions) | ||
25 | export const allParams = () => ({ | ||
26 | auth: authParams(), | ||
27 | session: sessionParams(), | ||
28 | oidc: oidcParams(), | ||
29 | }) | ... | ... |
-
Please register or sign in to post a comment