Skip to content

Commit

Permalink
feature: add support for electrode-sso (#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
divyakarippath authored Sep 1, 2020
1 parent d21eb81 commit 771273f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/subapp-server/lib/fastify-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ async function registerFastifyRoutesFromFile({ fastify, srcDir, routes, topOpts
});

const handler = makeRouteHandler({ path, routeRenderer, routeOptions });
if (routeOptions.auth) {
const authStrategies = [].concat(routeOptions.auth).map(auth => fastify[auth]);
const userPreHandler = _.get(route, "settings.preHandler");

if (userPreHandler) {
route.settings.preHandler = fastify.auth([...authStrategies, route.settings.preHandler], {
run: "all"
});
} else {
_.set(route, "settings.preHandler", fastify.auth(authStrategies));
}
}

getRoutePaths(route, path).forEach(pathObj => {
_.each(pathObj, (method, xpath) => {
Expand Down

0 comments on commit 771273f

Please sign in to comment.