From 39ca1fbd44076b860447bb0014f149e6c20f55a0 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Sun, 14 Aug 2016 14:39:24 -0400 Subject: [PATCH] nitweb: add API user login/logout end points Signed-off-by: Alexandre Terrasa --- src/nitweb.nit | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/nitweb.nit b/src/nitweb.nit index a953fcb..9484425 100644 --- a/src/nitweb.nit +++ b/src/nitweb.nit @@ -16,9 +16,27 @@ module nitweb import popcorn::pop_config +import popcorn::pop_auth import frontend import web +redef class NitwebConfig + + # Github client id used for Github OAuth login. + # + # * key: `github.client_id` + # * default: `` + var github_client_id: String is lazy do return value_or_default("github.client.id", "") + + # Github client secret used for Github OAuth login. + # + # * key: `github.client_secret` + # * default: `` + var github_client_secret: String is lazy do + return value_or_default("github.client.secret", "") + end +end + redef class ToolContext # Path to app config file. @@ -91,6 +109,9 @@ private class NitwebPhase app.use_before("/*", new SessionInit) app.use_before("/*", new RequestClock) app.use("/api", new NitwebAPIRouter(config, catalog)) + app.use("/login", new GithubLogin(config.github_client_id)) + app.use("/oauth", new GithubOAuthCallBack(config.github_client_id, config.github_client_secret)) + app.use("/logout", new GithubLogout) app.use("/*", new StaticHandler(toolcontext.share_dir / "nitweb", "index.html")) app.use_after("/*", new ConsoleLog) @@ -120,6 +141,7 @@ class NitwebAPIRouter use("/graph/", new APIGraphRouter(config)) use("/docdown/", new APIDocdown(config)) use("/metrics/", new APIMetricsRouter(config)) + use("/user", new GithubUser) end end -- 1.7.9.5