Search in sources :

Example 1 with OIDCController

use of org.molgenis.emx2.web.controllers.OIDCController in project molgenis-emx2 by molgenis.

the class MolgenisWebservice method start.

public static void start(int port) {
    sessionManager = new MolgenisSessionManager();
    oidcController = new OIDCController(sessionManager, new SecurityConfigFactory().build());
    port(port);
    staticFiles.location("/public_html");
    /*
     * WARNING !! SPARK JAVA USES DESIGN WHERE THE ORDER OF REQUEST DEFINITION DETERMINES THE HANDLER
     */
    get(("/" + OIDC_CALLBACK_PATH), (request, response) -> oidcController.handleLoginCallback(request, response));
    get(("/" + OIDC_LOGIN_PATH), oidcController::handleLoginRequest);
    get("/" + ROBOTS_TXT, MolgenisWebservice::robotsDotTxt);
    // get setting for home
    get("/", ACCEPT_HTML, (request, response) -> {
        // check for setting
        String ladingPagePath = sessionManager.getSession(request).getDatabase().getSettingValue(LANDING_PAGE);
        if (ladingPagePath != null) {
            response.redirect(ladingPagePath);
        } else {
            response.redirect("/apps/central/");
        }
        return response;
    });
    redirect.get("/api", "/api/");
    get("/api/", ACCEPT_HTML, (request, response) -> "Welcome to MOLGENIS EMX2 POC <br/>" + listSchemas(request, response));
    // documentation operations
    get("/api/openapi", ACCEPT_JSON, MolgenisWebservice::listSchemas);
    // docs per schema
    get("/:schema/api/openapi", OpenApiUiFactory::getOpenApiUserInterface);
    get("/:schema/api/openapi.yaml", MolgenisWebservice::openApiYaml);
    get("/:schema/api", (request, response) -> "Welcome to schema api. Check <a href=\"api/openapi\">openapi</a>");
    SiteMapService.create();
    CsvApi.create();
    ZipApi.create();
    ExcelApi.create();
    FileApi.create();
    JsonYamlApi.create();
    TaskApi.create();
    GraphqlApi.createGraphQLservice(sessionManager);
    LinkedDataFragmentsApi.create(sessionManager);
    BootstrapThemeService.create();
    get("/:schema", (req, res) -> {
        final String redirectLocation = "/" + req.params(SCHEMA) + "/";
        logger.debug(String.format("handle '/:schema' redirect: from: %s to: %s", req.pathInfo(), redirectLocation));
        res.redirect(redirectLocation);
        return "";
    });
    get("/:schema/", MolgenisWebservice::redirectSchemaToFirstMenuItem);
    // greedy proxy stuff, always put last!
    GroupPathMapper.create();
    // schema members operations
    // handling of exceptions
    exception(Exception.class, (e, req, res) -> {
        logger.error(e.getMessage());
        res.status(400);
        res.type(ACCEPT_JSON);
        res.body(molgenisExceptionToJson(e));
    });
}
Also used : OIDCController(org.molgenis.emx2.web.controllers.OIDCController)

Aggregations

OIDCController (org.molgenis.emx2.web.controllers.OIDCController)1