Add support for oauth adminAuth configs

This commit is contained in:
Nick O'Leary
2017-04-12 10:09:03 +01:00
parent bfb548636e
commit c54cf26848
8 changed files with 180 additions and 44 deletions

View File

@@ -96,9 +96,7 @@ function init(_server,_runtime) {
editorApp.get("/",ensureRuntimeStarted,ui.ensureSlash,ui.editor);
editorApp.get("/icons/:module/:icon",ui.icon);
theme.init(runtime);
if (settings.editorTheme) {
editorApp.use("/theme",theme.app());
}
editorApp.use("/theme",theme.app());
editorApp.use("/",ui.editorResources);
adminApp.use(editorApp);
}
@@ -109,14 +107,17 @@ function init(_server,_runtime) {
adminApp.get("/auth/login",auth.login,errorHandler);
if (settings.adminAuth) {
//TODO: all passport references ought to be in ./auth
adminApp.use(passport.initialize());
adminApp.post("/auth/token",
auth.ensureClientSecret,
auth.authenticateClient,
auth.getToken,
auth.errorHandler
);
if (settings.adminAuth.type === "oauth") {
auth.oauthStrategy(adminApp,settings.adminAuth.strategy);
} else if (settings.adminAuth.type === "credentials") {
adminApp.use(passport.initialize());
adminApp.post("/auth/token",
auth.ensureClientSecret,
auth.authenticateClient,
auth.getToken,
auth.errorHandler
);
}
adminApp.post("/auth/revoke",needsPermission(""),auth.revoke,errorHandler);
}
if (settings.httpAdminCors) {