From: Alexandre Terrasa Date: Sun, 14 Aug 2016 18:39:24 +0000 (-0400) Subject: nitweb: add API user login/logout end points X-Git-Url: http://nitlanguage.org nitweb: add API user login/logout end points Signed-off-by: Alexandre Terrasa --- 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