diff --git a/scaffoldTpl/app.js b/scaffoldTpl/app.js index 1ed98d2..9430875 100644 --- a/scaffoldTpl/app.js +++ b/scaffoldTpl/app.js @@ -1,77 +1,79 @@ -let express = require('express'); -let path = require('path'); -let favicon = require('serve-favicon'); -let logger = require('morgan'); -let cookieParser = require('cookie-parser'); -let bodyParser = require('body-parser'); +let express = require("express"); +let path = require("path"); +let favicon = require("serve-favicon"); +let logger = require("morgan"); +let cookieParser = require("cookie-parser"); +let bodyParser = require("body-parser"); -let index = require('./routes/index'); -let users = require('./routes/users'); +let index = require("./routes/index"); +let users = require("./routes/users"); let app = express(); const staffbaseKey = null; const pluginID = null; let ssoMiddleWare; -ssoMiddleWare = require('@staffbase/staffbase-plugin-sdk').middleware(staffbaseKey, pluginID); - +ssoMiddleWare = require("@staffbase/staffbase-plugin-sdk").middleware( + staffbaseKey, + pluginID +); // view engine setup -app.set('views', path.join(__dirname, 'views')); -app.set('view engine', 'pug'); +app.set("views", path.join(__dirname, "views")); +app.set("view engine", "pug"); // uncomment after placing your favicon in /public // app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); -app.use(logger('dev')); +app.use(logger("dev")); app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({extended: false})); +app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); -app.use(express.static(path.join(__dirname, 'public'))); +app.use(express.static(path.join(__dirname, "public"))); -app.use('/', index); -app.use('/users', users); +app.use("/", index); +app.use("/users", users); // Frontend Handler -app.use('/frontEnd', ssoMiddleWare); -app.get('/frontEnd', function(req, res) { - res.render('plugin', req.sbSSO); +app.use("/frontEnd", ssoMiddleWare); +app.get("/frontEnd", function (req, res) { + res.render("plugin", req.sbSSO); }); // Setup SSO Milleware on the endpoint server -app.use('/staffbase/sso/backoffice', ssoMiddleWare); +app.use("/staffbase/sso/backoffice", ssoMiddleWare); // Handle SSO response from server with decoded data -app.get('/staffbase/sso/backoffice', function(req, res) { +app.get("/staffbase/sso/backoffice", function (req, res) { // Middleware was able to decode the token if (req.sbSSO) { - console.log('Decoded data on backend(admin):', req.sbSSO); - res.render('plugin', req.sbSSO); + console.log("Decoded data on backend(admin):", req.sbSSO); + res.render("plugin", req.sbSSO); return res.end(); } res.json({ error: { - msg: 'Unable to get token information.', + msg: "Unable to get token information.", }, }); return res.end(); }); // catch 404 and forward to error handler -app.use(function(req, res, next) { - let err = new Error('Not Found'); +app.use(function (req, res, next) { + let err = new Error("Not Found"); err.status = 404; next(err); }); // error handler -app.use(function(err, req, res, next) { +app.use(function (err, req, res, next) { // set locals, only providing error in development res.locals.message = err.message; - res.locals.error = req.app.get('env') === 'development' ? err : {}; + res.locals.error = req.app.get("env") === "development" ? err : {}; // render the error page res.status(err.status || 500); - res.render('error'); + res.render("error"); }); module.exports = app; diff --git a/scaffoldTpl/views/index.html b/scaffoldTpl/views/index.html index dbd8eb4..36b0df5 100644 --- a/scaffoldTpl/views/index.html +++ b/scaffoldTpl/views/index.html @@ -1,19 +1,40 @@ -
Welcome to your Staffbase SSO plugin server. Please follow the following instructions -to get started with your Plugin Application.
+
+
+
+ Welcome to your Staffbase SSO plugin server. Please follow the following + instructions to get started with your Plugin Application. +
In order to get connected with the Staffbase SSO interface, you need a Valid Secret and an Audience ID.
-If you are here, you probably have a secret and audience ID registered with Staffbase. If you are not sure about it or you need more information about Staffbase SSO, feel free to contact the Customer Success team at Staffbase.
++ In order to get connected with the Staffbase SSO interface, you need a Valid + Secret and an Audience ID. +
++ If you are here, you probably have a secret and audience ID registered with + Staffbase. If you are not sure about it or you need more information about + Staffbase SSO, feel free to contact the Customer Success team at Staffbase. +
After the scaffolding is complete, you need to provide some values for configuring your -plugin server. The following values need to be configured.
++ After the scaffolding is complete, you need to provide some values for + configuring your plugin server. The following values need to be configured. +
You can either specify these values in environment variables or directly passing
-the values in the app.js file where the middleware is initialized.
To configure values in app.js file, change the following lines:
+ You can either specify these values in environment variables or directly
+ passing the values in the app.js file where the middleware is
+ initialized.
+
+ To configure values in app.js file, change the following lines:
+
app.js
12 ...
13 ...
@@ -21,40 +42,56 @@ Configuration
15 const pluginID = null;
16 ...
-You can also specify these values using environment variables. -Refer to the table to see which environment variables can be used.
++ You can also specify these values using environment variables. Refer to the + table to see which environment variables can be used. +
| Value | -Environment Variable | -
|---|---|
| Secret | -STAFFBASE_SSO_SECRET | -
| Audience | -STAFFBASE_SSO_AUDIENCE | -
| Server Port | -PORT | -
| Value | +Environment Variable | +
| Secret | +STAFFBASE_SSO_SECRET | +
| Audience | +STAFFBASE_SSO_AUDIENCE | +
| Server Port | +PORT | +
create-staffbase-plugin installs the project dependencies for you. -After configurations is done, the only thing you need to do is navigate to the -folder where your app was generated and start the express server.
++ create-staffbase-plugin installs the project dependencies for you. + After configurations is done, the only thing you need to do is navigate to the + folder where your app was generated and start the express server. +
$ cd [path of generated app]
$ npm start
For getting more information about Staffbase SSO, please check out the following links:
++ For getting more information about Staffbase SSO, please check out the + following links: +